Running mesh animations simultaneously - how can we synchronise model parts?

Software: Away3D 4.x

TheBard, Newbie
Posted: 06 November 2013 05:08 PM   Total Posts: 8

I am new to Away3D.  I have created a DAE model in Blender and loaded it in Away3D.  The model has 3 meshes and one animation - the animation affects all 3 meshes.  When I parse the DAE, the DAEParser separates the animation into 3 animation nodes giving each mesh its own animation.  I gave each mesh its own SkeletonAnimator as I couldn’t figure a way of sharing the animator between all 3 meshes.


1st Problem:

When I play the animations, naturally they don’t synch, for example the coat runs faster than the body etc:

an = new Array(3);// SkeletonClipNode;
    
an [BODY] mesh[BODY].animator.animationSet.getAnimation("node_0");
an [HAT] mesh[HAT].animator.animationSet.getAnimation("node_1");
an [COAT] mesh[COAT].animator.animationSet.getAnimation("node_2");

mesh[BODY].animator.play(an[BODY].namenull0);
mesh[HAT].animator.play(an[HAT].namenull0);
mesh[COAT].animator.play(an[COAT].namenull0); 

How can we synchronise these animations so that they start and end at the same time?


2nd Problem:

Also how do I break the animation up into clips e.g. Walk 0-1 secs, Run 1-2 secs etc?

The animators seem only able to play() each animation from the beginning root “node_0” for BODY, “node_1” for HAT etc. right the way through to the end, and looping by default.

I have checked the node names for each animationSet, and each animationSet seems to have been given just one single node which is named with an underscore and a number reflecting the order they were loaded - I did not give them these names in Blender.

trace(mesh[BODY].animator.animationSet.animationNames);
trace(mesh[HAT].animator.animationSet.animationNames);
trace(mesh[COAT].animator.animationSet.animationNames); 

returns:

node_0
node_1
node_2

What I really want is either to add more nodes to the AnimationSets OR to add more AnimationSets to the Animation.

Is there an easier solution?

Thanks for looking.

   

TheBard, Newbie
Posted: 06 November 2013 05:44 PM   Total Posts: 8   [ # 1 ]

Solution to Problem 1:

I fixed the synch problem, literally 5 mins after I posted!

A lack of understanding on my part.

Here is the code:

an = new Array(3);// SkeletonClipNode;
    
an [0] mesh[BODY].animator.animationSet.getAnimation("node_0");
an [1] mesh[HAT].animator.animationSet.getAnimation("node_1");
an [2] mesh[COAT].animator.animationSet.getAnimation("node_2");

animationSet[COAT].addAnimation(an[0]);
animationSet[HAT].addAnimation(an[0]);
animationSet[COAT].addAnimation(an[1]);
animationSet[BODY].addAnimation(an[1]);
animationSet[HAT].addAnimation(an[2]);
animationSet[BODY].addAnimation(an[2]);

mesh[BODY].animator.play(an[0].namenull0);
mesh[HAT].animator.play(an[0].namenull0);
mesh[COAT].animator.play(an[0].namenull0); 

The reason I can’t add the animation nodes to all animationSets at the parsing stage is that each animation node is parsed AFTER each animation set, so I had to wait until all 3 animation sets were parsed before adding the later animations gleaned towards the end of the parse procedure.

I hope this makes sense to somebody!

 

   

TheBard, Newbie
Posted: 06 November 2013 09:50 PM   Total Posts: 8   [ # 2 ]

Solution to Problem 2

Sorted, I can now divide up the parsed animation into clips. 

Using an[0] as the full animation as before:

var clip:Array = new Array(numClips); //SkeletonClipNode;
var pose:Array = new Array(an[0].frames.length); //SkeletonPose;
    
for (var f:int 0an[0].frames.lengthf++)
{
    pose[f] 
an[0].frames[f];
}

clip[0] 
= new SkeletonClipNode();
clip[0].addFrame(pose[0]1);
clip[0].addFrame(pose[1]1);
clip[0].addFrame(pose[2]1);
clip[0].name "clip_0";
clip[0].looping false;

mesh[BODY].animator.animationSet.addAnimation(clip[0]);
mesh[HAT].animator.animationSet.addAnimation(clip[0]);
mesh[COAT].animator.animationSet.addAnimation(clip[0]);

mesh[BODY].animator.play(clip[0].namenull0);
mesh[HAT].animator.play(clip[0].namenull0);
mesh[COAT].animator.play(clip[0].namenull0); 

Hope this helps someone!

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X