Tuesday, January 26, 2010

Run Multiple Collada Animations at once

I tweaked the Away3d SkinAnimation class to allow me to run multiple animations at once(as long as they don't effect the same bones). So for instance you could have a walking animation with the legs moving, while you animate a hand waving animation. Here is the code you will need to replace in your SkinAnimation class*:

*Note, you will need to update the IMeshAnimation Interface class, to change the update definition to:
function update(time:Number, interpolate:Boolean = true, onlyChannels:Array = null):void;

/**
* Updates all channels in the animation with the given time in seconds.
*
* @param time Defines the time in seconds of the playhead of the animation.
* @param interpolate [optional] Defines whether the animation interpolates between channel points Defaults to true.
* @param onlyChannels [optional] Will only update the channels whose name contain part of the strings in this array. If this value is null, all channels will be updated
*/
public function update(time:Number, interpolate:Boolean = true, onlyChannels:Array = null ):void
{
if (time > start + length ) {
if (loop) {
time = start + (time - start) % length;
}else{
time = start + length;
}
} else if (time < time =" start" time =" start;" onlychannels ="="" uint =" 0;">= 0)
return true;
}
return false;
}

No comments: