Jump to content

[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

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

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

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.

 

 

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

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?

Link to post
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...