spritefire Posted March 2, 2015 Share Posted March 2, 2015 Heyas Where would I find info about exporting a 3ds max animation where I can import it into blender and press a key for a walk animation, a different key for a run animation and another key for a jump animation?What would be the best practice, should I create the different animations at different frames and then loop through the different frames when key is pressed? or is there a different way? Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 2, 2015 Share Posted March 2, 2015 Should I create the different animations at different frames and then loop through the different frames when key is pressed?Yes, this solution is the good. Quote Link to comment Share on other sites More sharing options...
spritefire Posted March 3, 2015 Author Share Posted March 3, 2015 hmm this doesn't seem to be working. no matter what frames I place in the code it cycles through all of the frames. ie I have:scene.beginAnimation(scene.manModel.skeletons, 20, 40, true, 1.0);and it loops from 0 frame to 120 frame.Actually even if I don't have any code with beginAnimation and just import the model it cycles through all animations :/ Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 3, 2015 Share Posted March 3, 2015 The problem is this place here so: scene.manModel.skeletons At home it works fine. Try:scene.manModel.skeletons[0] Quote Link to comment Share on other sites More sharing options...
spritefire Posted March 3, 2015 Author Share Posted March 3, 2015 maybe the issue is something else. The mesh is named human in 3ds max and when i export and debug I can see it named human, but it doesn't appear the name is linking to the mesh?It doesn't scale, change position or do the animations in the frames. It does load though, and even if I don't tell it what mesh to import.. :/Here is my code: var canvas = document.getElementById("renderCanvas"); var engine = new BABYLON.Engine(canvas, true); var createScene = function () { var scene = new BABYLON.Scene(engine); var light = new BABYLON.PointLight("Omni", new BABYLON.Vector3(10, 10, 10), scene); var light0 = new BABYLON.HemisphericLight("Hemi0", new BABYLON.Vector3(0, 1, 0), scene); light0.diffuse = new BABYLON.Color3(1, 1, 1); light0.specular = new BABYLON.Color3(1, 1, 1); light0.groundColor = new BABYLON.Color3(0, 0, 0); var myCamera = new BABYLON.FreeCamera("Camera", new BABYLON.Vector3(0, 525, -500), scene); myCamera.rotation = new BABYLON.Vector3(Math.PI/12,Math.PI*2,0); scene.activeCamera = myCamera; BABYLON.SceneLoader.ImportMesh("human", "", "man.babylon", scene, function (newMeshes, particleSystems, skeleton) { scene.clearColor = new BABYLON.Color4(0,0,0,0); scene.manModel = scene.getMeshByName("human"); scene.manModel.position = new BABYLON.Vector3(0, 0, 0); scene.manModel.scaling = new BABYLON.vector3(0.5, 0.5, 0.5); scene.beginAnimation(scene.manModel.skeleton[0], 20, 40, true, 1.0); //scene.manModel.materialmesh; }); return scene; } var scene = createScene(); engine.runRenderLoop(function () { scene.render(); }); window.addEventListener("resize", function () { engine.resize(); }); // Resize engine Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 4, 2015 Share Posted March 4, 2015 Hello here is a good example:https://github.com/BabylonJS/Samples/blob/master/Scenes/Customs/bones.js I think in your case this should work:scene.beginAnimation(scene.manModel.skeleton, 20, 40, true, 1.0); Quote Link to comment Share on other sites More sharing options...
spritefire Posted March 4, 2015 Author Share Posted March 4, 2015 That's the example I used. I've also switched the code to the code you have written and still the same result. It's strange because it should work which is why I am stumped. Nothing seems to be affecting the model, rotation, position, scale etc also don't work. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 4, 2015 Share Posted March 4, 2015 Try this: See line 3, 4 and 11BABYLON.SceneLoader.ImportMesh("human", "", "man.babylon", scene, function (newMeshes, particleSystems, skeleton) { var mesh = newMeshes[0]; var skeleton = skeleton[0]; scene.clearColor = new BABYLON.Color4(0,0,0,0); mesh.position = new BABYLON.Vector3(0, 0, 0); mesh.scaling = new BABYLON.Vector3(0.5, 0.5, 0.5); scene.beginAnimation(skeleton, 20, 40, true, 1.0);}); Quote Link to comment Share on other sites More sharing options...
spritefire Posted March 4, 2015 Author Share Posted March 4, 2015 still no luck. I've been clearing cache as well just to insure it hasn't been that. I'm using the latest exporter but have also tried older versions and still the same results. I think maybe its to do with the layers and naming in 3ds max but it all looks fine to me. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 4, 2015 Share Posted March 4, 2015 The problem comes from your model can be. the code works for me. You said console.log (skeleton) you have error? Oh. I just saw the error. Try (I remove the Name of ImportMesh)BABYLON.SceneLoader.ImportMesh("", "", "man.babylon", scene, function (newMeshes, particleSystems, skeleton) { var mesh = newMeshes[0]; var skeleton = skeleton[0]; scene.clearColor = new BABYLON.Color4(0,0,0,0); mesh.position = new BABYLON.Vector3(0, 0, 0); mesh.scaling = new BABYLON.Vector3(0.5, 0.5, 0.5); scene.beginAnimation(skeleton, 20, 40, true, 1.0); console.log(skeleton);}); Quote Link to comment Share on other sites More sharing options...
spritefire Posted March 4, 2015 Author Share Posted March 4, 2015 Yes it was the model. I removed the edit poly modifiers I had on the human mesh and things started working better. I have now exported the model and used the new code you have supplied and everything is working perfectly! So it appears exporting meshes that have a skin modifer with animation/rigging attached and also an edit poly modifier is a no no. Thanks! Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 4, 2015 Share Posted March 4, 2015 Good to know @dad72: perhaps we should add this info to the doc you did about 3dsmax and bones Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 4, 2015 Share Posted March 4, 2015 I do not think it comes from the modifier 'edit Poly' because my models uses all this modifier. It was really the name that was information in the ImportMesh Quote Link to comment Share on other sites More sharing options...
spritefire Posted March 5, 2015 Author Share Posted March 5, 2015 That is strange because I had tried it without the name before I had removed the edit poly modifier and still was unable to get it to work. Maybe it was what I had done in the edit poly and where I had placed it (had created it above the skin modifier and then dragged it below it). I still have the archive of the file that has it set up that way. I will do some testing on it (ie export that model with the code that is working with the updated model) and see what the results are. 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.