Sign in to follow this  
mecanicus

[SOLVED]multiple animations

Recommended Posts

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

Share this post


Link to post
Share on other sites

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));
                    }

Share this post


Link to post
Share on other sites

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".

Share this post


Link to post
Share on other sites

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.

 

 

Share this post


Link to post
Share on other sites

@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 :)

actions.png

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

@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 :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.