CustomAnimation Class for (COLLADAMax) SkinAnimation

14 views
Skip to first unread message

Revalis

unread,
Nov 23, 2009, 10:44:01 AM11/23/09
to away3d.dev
Heyo all,
Been working on getting a 3DS Max biped-rigged and animated character
over into Away3D and have had great success! Thought I'd share the
class I built with the group in case it makes life easier for anyone
else. :)

Download here: http://revalis.dbinspiredarts.com/CustomAnimation.zip
I'll also be uploading it to the GoogleGroup. Just didn't see a way to
attach it to this message. =/

It's a very easy setup to use once you've saved the file down.

(With the example below, in 3DS Max, frames 0-25 are a walk cycle and
frame 26 is a single frame idle state.)



//Just add another global variable to accompany your SkinAnimation
private var skinAnim :SkinAnimation;
private var MyAnim :CustomAnimation;

Then after you setup your SkinAnimation Class as you normally would,
add:

skinAnim = (model.animationLibrary["default"] as
AnimationData).animation as SkinAnimation; // as normal

MyAnim = new CustomAnimation(skinAnim);
MyAnim.addAnimationSequence("walk",0,25,true);
MyAnim.addAnimationSequence("idle",26,1,false);


And that's it.

It will automatically assign the "active" animation sequence to the
last one you entered. But you can switch between the different
animation sets by using .playSequence(name) or .nextSequence() if you
just want to iterate through the different sets.

I wrote more detailed instructions in the class file, also copied them
below.

Enjoy!



Save this to your (actionscript)/away3d/animators folder. Same folder
as SkinAnimation.as
You will need to edit SkinAnimation.as to change private var
_channels:Array; to public
(note: I included the editted SkinAnimation.as in the .zip file.
This is the only thing different in it)

*******************************************************************************************************
* USEAGE: *
.addAnimationSequence(name, start, length, loop) - Adds a sequence
name: whatever you want to call the sequence. ie, "walk", "idle",
"dance", "jump", ...
start: keyframe it begins on in 3d package. ie, 0, 1, 2, ...
length: total frames. ie, 3, 25, 5, ...
loop: does the sequence loop, true/false
Example: .addAnimationSequence("walk", 0, 25, true);

.playSequence(name) - sets the active sequence
name: the name specified when adding the sequence.
Example: .playSequence("walk");

.nextSequence() - increments to the next sequence in the Array, based
on the order added.
Example: .nextSequence();

*******************************************************************************************************

Revalis

unread,
Nov 23, 2009, 12:31:55 PM11/23/09
to away3d.dev
Heh, already updated it. When I started working on my jump cycle, I
noticed that .update will always be long after the length of the
animation cycle. Couldn't tell with the idle, because he was standing
still... Anyways, I added a new function:

So instead of using in your loop:
skinAnim.update(getTimer()/1000);

You can use:
MyAnim.updateOffset();


And this will ensure that the animation sequence always plays from the
start frame, through the duration of length you specified. Then it
will either loop or not.
> ***************************************************************************­****************************
> * USEAGE: *
> .addAnimationSequence(name, start, length, loop) - Adds a sequence
>         name:   whatever you want to call the sequence. ie, "walk", "idle",
> "dance", "jump", ...
>         start:  keyframe it begins on in 3d package. ie, 0, 1, 2, ...
>         length: total frames. ie, 3, 25, 5, ...
>         loop:   does the sequence loop, true/false
>                 Example:  .addAnimationSequence("walk", 0, 25, true);
>
> .playSequence(name) - sets the active sequence
>         name:   the name specified when adding the sequence.
>                 Example:  .playSequence("walk");
>
> .nextSequence() - increments to the next sequence in the Array, based
> on the order added.
>                 Example: .nextSequence();
>
> ***************************************************************************­****************************
Reply all
Reply to author
Forward
0 new messages