AlbertTJames Posted August 25, 2016 Share Posted August 25, 2016 Hey guys, I have just made a little mesh and a simple animation on maya, but since there is no exporter from maya and no 3dsmax on mac.. im using unity to export. It works great for the mesh, texture etc, but I cant manage to access the animation... it is in the babylon file, but it's exploded by property like in the picture, I have two of those for each property probably because my mesh has two separate parts... Somebody knows how I can call the animation to run once ? https://www.dropbox.com/s/uoyoxfu55x33kl6/jumpAnim.mov?dl=0 Thanks Quote Link to comment Share on other sites More sharing options...
AlbertTJames Posted August 25, 2016 Author Share Posted August 25, 2016 In fact importing the mesh from unity does not work either... Probably because there are sub meshes in the main character ? Quote Link to comment Share on other sites More sharing options...
Nabroski Posted August 25, 2016 Share Posted August 25, 2016 Hello Questions & Answers in Babylonjs Forum has 162 Pages, i'm pretty sure at least 2 Topics of them are related to unity. I have no idea of Unity Export, but someone will catch up soon. I like your idea to contribute to Babylonjs with a Statemanager, and i'm always on the Ship of Fools. If you run into a deadline in your protect try to import your Model and export it through an other Program 3dMax has a 30Days Trial Period and Blender is free. If you feel you just discover a new better way to handle things feel free to submit your code here https://github.com/BabylonJS Forum search:http://www.html5gamedevs.com/search/?&q=unity&type=forums_topic&nodes=16,28 AlbertTJames 1 Quote Link to comment Share on other sites More sharing options...
AlbertTJames Posted August 25, 2016 Author Share Posted August 25, 2016 (edited) Ok so I managed to do it, maybe those 5 hours of my life will help somebody else The process was quite tedious and maybe with 3Dsmax or rigging the import would have been ok, but my options were only Maya to Unity then Unity to Babylon. I am very new to 3d (started a month ago) so bear with me So as you can see on the previous image I had a parent object "rogerRobot" that was directly imported from maya, I think this is really the Maya scene since there are lights and camera inside the prefab (deleted on the picture). I have only two mesh of interest the head (polysurface4) and the body (polysurface3), those are not rigged (i dont know how to do it...). In the parent object rogerRobot I have 2 sub-objects (Sphere03, polysurface2, sorry for the names...) that maya used for transforming both head and body mesh together (mainly a little 90 degree rotation...) and I do not need then really. (EDIT: well maybe i do need those transformations for the animation to work perfectly.. maybe that the cause of the quirks.. ?) The two sub-meshes head and body have the same PBR material. The jump animation only works on that prefab, not on the submeshes in unity. So when you export to a babylon file, the animation was concatenated inside the "parent mesh" rogerRobot (no vertice position, just an empty mesh object) with in the animation array two copies of rotation.x .y .z rotationQuaternion.x .y .z etc.. those two copies are for each submeshes head and body (polysurface4 and 3). The two copy names are the same and there is no easy way to distinguish the animation, I found which of those two copies belong to which mesh by looking at the frames. Once you have found one then you see that the concatenation is done as follows : rotation.x.y.z.w Mesh 1, rotation.x.y.z.w Mesh2, position.x.y.z Mesh 1, position.x.y.z Mesh 2, scale.x.y.z Mesh 1, scale.x.y.z Mesh 2 I copied the animation array manually for each mesh with its corresponding animation. In the code, the import went well but then when rendering the scene I had the very common "can't change property .x of undefined" or something. I am glad I had this error dozens of time before.. and I created the quaternion for each mesh at import, allowing the animation to run: BABYLON.SceneLoader.ImportMesh("", this.ASSETS_FOLDER + "/rogerRobot/", "rogerRobot.babylon", scene, function (newMeshes, particleSystems, skeleton) { for (var i = 0; i < newMeshes.length; i++) { newMeshes[i].isVisible = true; if (!newMeshes[i].rotationQuaternion) { newMeshes[i].rotationQuaternion = BABYLON.Quaternion.RotationYawPitchRoll(newMeshes[i].rotation.y, newMeshes[i].rotation.x, newMeshes[i].rotation.z); newMeshes[i].rotation = BABYLON.Vector3.Zero(); } } }); And voila ! Worked, although there are some quirks on the animation i will try to change it by hand.. later ! EDIT2: Ok so the glitches came from the fact multiple frame with the same number had different values. Also some values seemed a bit extreme but... I dunno.. Edited August 25, 2016 by AlbertTJames found the glitch ! Nabroski and GameMonetize 2 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.