mecanicus Posted July 24, 2017 Share Posted July 24, 2017 Hello,I exported a scene since blender. There is two meshes with animation.I created a function which gets back animation and creates two variables "Scene.beginAnimation" which allow me to make stop and restart afterward.I have for it makes a loop for to get back the frames of the beginning and from the end of every animation and associate them with the "target". var frameFrom = []; var frameTo =[]; var anime = []; for (var j = 0; j < Scene.Animatables.length; j++) { frameFrom.push(Scene.Animatables[j]['fromFrame']); frameTo.push(Scene.Animatables[j]['toFrame']); anime.push(Scene.beginAnimation(Scene.Animatables[j]['target'], frameFrom[j],frameTo[j], true, 1)); console.log(frameFrom); console.log(frameTo); console.log(anime); } Here is the display of the console: Array [ 311 ] vue3dTest.js:118:7 Array [ 610 ] vue3dTest.js:119:7 Array [ Object ] vue3dTest.js:120:7 Array [ 311, 311 ] vue3dTest.js:118:7 Array [ 610, 610 ] vue3dTest.js:119:7 Array [ Object, Object ] The values of the array 118:7 and 119:7 are identical, what is not normal.If I delete the line: lanime.push(Scene.beginAnimation(Scene.Animatables[j]['target'], frameFrom[j],frameTo[j], true, 1));I obtain: Array [ 311 ] vue3dTest.js:118:7 Array [ 610 ] vue3dTest.js:119:7 Array [ ] vue3dTest.js:120:7 Array [ 311, 2 ] vue3dTest.js:118:7 Array [ 610, 300 ] vue3dTest.js:119:7 Array [ ] What is the expected result. I does not understand where from comes the difference. Thank you for your help. This a reverso translate Quote Link to comment Share on other sites More sharing options...
Nesh108 Posted July 25, 2017 Share Posted July 25, 2017 Hello @mecanicus, It does seem weird but, in my opinion, you would definitely want to first get the frames for beginning and end for all the meshes and then start them all up. Perhaps checking out the content of `Scene.Animatables` will tell you more about it. Quote Link to comment Share on other sites More sharing options...
mecanicus Posted July 25, 2017 Author Share Posted July 25, 2017 Thank you for the answer, but I found a solution. I make a decremental loop and it works. I can use the button stop and restart. for (var j = (Scene.Animatables.length -1) ; j >= 0; j--) { frameFrom.push(Scene.Animatables[j]['fromFrame']); frameTo.push(Scene.Animatables[j]['toFrame']); anime.push(Scene.beginAnimation(Scene.Animatables[j]['target'], frameFrom[j],frameTo[j], true, 1)); } Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted July 25, 2017 Share Posted July 25, 2017 I did not really follow your code, but should mention that if you are exporting from Blender, then the Blender Actions are transferred as BJS AnimationRanges. The begin and end are recorded for you. Also, if you have a .blend where multiple meshes participate in actions, you cannot detect via python that one mesh is the only one that uses a given action. If an action operates on a specific mesh, make sure the name of the action is in the format "meshname-something". Quote Link to comment Share on other sites More sharing options...
mecanicus Posted July 25, 2017 Author Share Posted July 25, 2017 Can you give me a example : "make sure the name of the action is in the format "meshname-something"." How to use AnimationRange ? This is my first steps with two mesh with their own animation, but in the babylon file each mesh have the same two animations action and the same range animation. Quote Link to comment Share on other sites More sharing options...
gryff Posted July 25, 2017 Share Posted July 25, 2017 @mecanicus : maybe this image will help explain it. Upper part of image (A) shows the animation names in the action editor in Blender - no hyphen "-". If those names are used then each animated object - the sphere and the cube - will have two animations assigned to them like this: "ranges":[{"name":"CubeAction","from":0,"to":60},{"name":"SphereAction","from":70,"to":130}] However, if you add the hyphen as shown in the image (B) then each object will only have the animation assigned to it : For the sphere : "ranges":[{"name":"Action","from":0,"to":60}] and the cube: "ranges":[{"name":"Action","from":0,"to":60}] Hope that helps. cheers, gryff mecanicus 1 Quote Link to comment Share on other sites More sharing options...
mecanicus Posted July 25, 2017 Author Share Posted July 25, 2017 Thank you very, very much, I get better to sleep. It has been two days since I tried to by-pass this problem of animations.For the use with babylon.js, is it preferable to use always the same word like "action" or to change it for every animation? Quote Link to comment Share on other sites More sharing options...
gryff Posted July 26, 2017 Share Posted July 26, 2017 @mecanicus : As far as I know, you can name them what ever you like, for example : Cube1-moveX, Cube1-moveZ, Cube1-RotateZ Sphere1-moveY, Sphere1-Jump I was just using Action because it defaulted to that word. They are just names. cheers, gryff mecanicus 1 Quote Link to comment Share on other sites More sharing options...
mecanicus Posted July 26, 2017 Author Share Posted July 26, 2017 Thanks 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.