Jump to content

how to load animations from multiple files?


satguru
 Share

Recommended Posts

I have 4 fbx files.

 

First one has  a mesh and a skeleton but no animations (skeleton is in T Pose).

 

The other files have skeletons with animations but no mesh 

(Second has skeleton with idle animation

Third has skeleton with walk animation

Fourth has skeleton with run animation)

 

The skeleton is same in all four files.

I do not have any program to merge the files together.

Is there a way I can load the 4 files into BabylonJS  and play the three animations on the  mesh?

(I am using the BabylonJs FBX exporter to convert the FBX file to BabylonJs format)

 

Thanks

Link to comment
Share on other sites

I would be interested in this also... it would be nice if there was some kind of method of adding and removing animations from a skeleton, and being able to name them as their own kind of object type. hen you could reference them by name instead of specific frame numbers.

Link to comment
Share on other sites

http://www.html5gamedevs.com/topic/17875-translating-an-acm-file-to-babylonanimation/

This topic has gotten me thinking about this a little more. I don't really want to hi-jack this topic, but I also don't want to start a new one and mix everything up that ultimately related to the same thing...

 

 

The same kind of idea from JCPalmer's thread about loading in MOCAP info could potentially be used to seperate animations into unique files and keep them off the skeleton in the skeleton's babylon file.

 

 

What I would suggest with animations is below. It would give you all the tools you could ever need to really control the fine points of animating without a lot of user involved complexities or having to make multiple copies of your animations and further bloating your mesh / skeleton files. If I already have 300 animationsin a file with over 4,000 keyframes of animations, I sure don't want to have to make 300~400 more animations to combine multiple animations on the fly... we'd have a character file that's 500MB by itself before we were done, and that's just not going to work long term.

 

  • Maybe make a *.aniBabylon file that is just animation data. I suppose you could just use a normal *.Babylon extension though. It's really all the same, so this may be pointless.
  • Add a naming method to each animation so you don't have to call them by frame numbers
  • load animations similar to the importMesh function as a member function of skeleton. This way we're only streaming the bear minimum of data down to the player and as needed. Could take several minutes to preload a 50~100MB animation file just due to the shear size that needs to be downloaded. Plus I worry about max cahce size limits at some point.
    dude.skeleton.loadAinmation("[walk, Run, Dance, scratch_head, pick_nose]", "./dude_animations.aniBabylon");  // animation names, animation file
  • If you already have all your animations on the skeleton or want to keep then that way, then you could name those multiple animations cycles.
    dude.skeleton.nameAnimation("walk", <frame_start>, <frame_end>);
  • Then we can simplify the animation calls and handling.

    dude.skeleton.startAnimation("walk", true);  // Animation name, loop animation bool
  • Also have an animation hirarchy so you could have multiple animations firing at once. Think walking while attacking in a real world game application. This animations priorities will now be higher than the current walking animation, so overlapping bone rotations etc will be taken from the higher priority animation.

    dude.skeleton.blendAnimation("pick_nose"); // starts the animation or combines with current animationdude.skeleton.blendAnimation("scratch_head"); // overlap with pick_nose will be handled by scratch_head  
  • If you want to end one of the blended animations, or the primary animation...

    dude.skeleton.endAnimation("pick_nose"); // stop this particular animation and control of the bones passed back to walking due to priorities
  • Now if i'm tired of walking and scratching my head, and want to blend the whole animation cycle into running...
    dude.skeleton.currentAnimation could be an array of all current animations for quicker calls, or you could name everything you would want to replace in case you want to keep attacking an enemy, but move from walking to running without changing the attack animation... The priority of this new animation would have to be lower than any animations that have been left running.

    dude.skeleton.changeAnimation(dude.skeleton.currentAnimation, "run");  // end the selected animation(s) and blend into the new animation.// ordude.skeleton.changeAnimation(["walk", "scratch_head"], "run");  // end the selected animation(s) and blend into the new animation.
Link to comment
Share on other sites

That is a lot for me to comment on (I am not that familiar with BABYLON.Animation), but for me separation of animation from the skeleton until run time is very desirable.  It helps having a massive library of Mocaps though.  Being separate means, if I "make" a mesh with a skeleton, I do not have to go back and edit the .blend file & re-export it if I want to add a new animation.  If it is separate, putting it can also be put in multiple meshes having the same rig type.

 

If it helps, Bone's property "animations" has an "s" on the end, because it is an array.  If you can specify the index into this array when starting, then that may solve the using frame ranges problem.  I do not use the official animation system.  I do know that all but animation[0] is ignored by fileLoader, but that just re-enforces separation.

 

As far as "queuing" a series of distinct animations,  the POV system has a queue where you can put each of your animations on, and let it work them off.  There is a special stall event that can also be queued.  I am hesitant to really promote it right now as I am half through a major improvement, which breaks compatibility.

Link to comment
Share on other sites

So!

 

many interesting things here:

- Being able to name a range with animation.tag("run", 10, 50) and start it with scene.beginAnimation(animation, "run") is an excellent idea!

- For external file to save animation: OK but how do you want to produce them? Manually? Do I need to create a tool to extract them from .babylon?

- Adding a startAnimation, stopAnimation shortcut on the skeleton: no problem

- For blending, this is a different topic which will require more work

Link to comment
Share on other sites

That's awesome DK! This alone will make keeping up with and using animations much simpler.

 

I would suppose that a splitting tool would be useful for everyone not exporting from Max or Blender. Then the Max and Blender guys could follow your lead on file format for the split export. I would think the only new things to potentially define or add would be like animation name, and total frames. then this could be used to add the new animation to the end of the frame list and call your new function to make a new createAnimationRange using the name.

 

Would we want the skeleton in the animation files, or strictly the animation data. Either way I could see. I suppose whichever would make it easier for you to bring the data in and apply it to the existing skeleton.

 

 

While we're on the subjects, how does Babylon handle the skin pose of skeletons? Is there anyhting I would need to do to set it into the skin pose to apply it to a new mesh?

 

Edit:

maybe also include frame speed etc into start animation function that uses the new animation name? so player "buffs" could say increase walking speed etc.

Link to comment
Share on other sites

DK,

 

1) Regarding FBX Reroute Skeleton. My understanding was that this is to create a file containing multiple meshes with same animation. I am looking for a way to create a file containing multiple animations with same mesh. Is my understanding wrong ?

 

2) Is there an example at this link http://www.babylonjs...d.com/#WBIXK#2 ? I just see the basic scene.

 

3) Yes it would be nice if we could decouple the animation from the skeleton and the skeleton from the mesh. An API which allows one to play animation "a" on skeleton "b" and mesh "c" would be nice. The user, maybe, should be be  responsible to ensure that the animation is suitable for the skeleton and the skeleton is suitable for the mesh.

 

4) could you explain what you meant by "just apply the skeleton to your new mesh.". Are you saying I can apply a skeleton upload with one mesh to  another mesh? and then if I play anim on skeleton it would  animate both the meshes?

 

Thanks

Link to comment
Share on other sites

1. Correct, I misunderstood your ask. Sorry

 

2. Link seems wrong: here is it again-> http://www.babylonjs-playground.com/#WBIXK#2

 

3. Already the case. Skeleton can be affected to many meshes: http://www.babylonjs.com/?BONES (3 rabbits but one single skeleton). Animations are hosted by bones so far. But they can be decoupled as long as you provide a valid animation for each bones. Even with a .any.babylon file, the goal will be to provide individual animations for each bone (Not sure I'm really clear here :))

 

4. Yes :) mesh.skeleton = otherMesh.skeleton and you're done :)

Link to comment
Share on other sites

DK

 

2. Regarding animation range example. If I clone the skeleton would the cloned skeleton get the range too?

 

so

 

skeleton1.createAnimationRange("walk", 10, 50);
skeleton1.beginAnimation("walk", true);
 
skel2 = skeleton1.clone("s2");
skel2.beginAnimation("walk", true) ; ??
 

3 & 4. I checked the BONES example. It is great that we can clone skeleton and add to different mesh. This way I can play same animation on different meshes.

 

Is it possible to load a file containing only skeleton and animation (no mesh)?  If yes then , after  uploading it , I can clone the skeleton and add it to different mesh.

 

Thanks

Link to comment
Share on other sites

 

Is it possible to load a file containing only skeleton and animation (no mesh)?  If yes then , after  uploading it , I can clone the skeleton and add it to different mesh

 

Me and DK have talk about this a couple times I'm sure... he's probably tired of hearing from me... lol

What we're doing is adding a plane to the scene, so you're only adding 2 normals.  We named our plane "playerSkeleton". Naming doesn't really matter.

 

playerSkel = scene.getMeshByName("playerSkeleton");

newPlayer.skeleton = playerSkel.skeleton;

Link to comment
Share on other sites

reddozen,

 

That worked for me. Thanks

 

Now I am struggling with an other issue,

Mixamo (http://www.mixamo.com) is offering lots of free characters and animations for a limited time.

I downloaded some of them, imported them io blender  and edited them there.

But exporting them as babylonjs messes them up.

 

I had better luck with fbxexporter.

But for that  i have to download each animation with character as fbx.

Cannot do just animation due to above issue :(

Link to comment
Share on other sites

  • 6 months later...
On 17/10/2015 at 2:01 PM, satguru said:

2. Regarding animation range example. If I clone the skeleton would the cloned skeleton get the range too?

so

skeleton1.createAnimationRange("walk", 10, 50);

skeleton1.beginAnimation("walk", true);
 
skel2 = skeleton1.clone("s2");
skel2.beginAnimation("walk", true) ; ??
 

I just tried this on a cloned mesh and skeleton and it didn't work.  I had to create the animation ranges again

Link to comment
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...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...