Page 1 of 1

Animation Techniques

Posted: Mon May 16, 2011 10:22 am
by brianempson
Hello, I am just beginning a project in my spare time and ran into a problem when thinking about how I'm going to handle animation in my game. How do you play two animations at once? For example, if my character is both blocking and strafing sideways, is there a way to combine a blocking and a strafing sideways animation?

The only ways I've come up with so far is:

1. Try to blend the two and see if that works
2. Chop the model in half and tell irrlicht to animate both parts separately
3. Animate every possible action the character will do (hopefully we can avoid this!)
4. Something else I'm not aware of?

Number 3 would definitely work if I had enough time, but a technical problem arises because of the format I am using (.x), the files will be astronomically large. I guess changing formats could solve that problem.

Number 2 would be awkward in the modeling program, but if you model the whole thing and then chop it in half, animate it, and tell irrlicht to just stitch them together with parenting or something it may just work.

Number 1 would be easy if it "just worked", I doubt blending can take two completely different animations and just slap them together? Maybe?

Any tips?

Posted: Mon May 16, 2011 10:26 am
by nespa
case 3 only

Posted: Mon May 16, 2011 10:30 am
by Virror
I guess 2 would work as well, but then you have to make two separate models and attach the top part to the bottom part in irrlicht?
But maybe it wont look so good though.

Posted: Mon May 16, 2011 10:52 am
by brianempson
Perhaps animation mixing can be a new feature? :)

Posted: Mon May 16, 2011 1:35 pm
by CuteAlien
I also recommend 3. It will be easier to code, it will look better and even animators will have it easier as mixing animations in an animation tool is probably easier than doing that in code/xml/init-files.

Posted: Mon May 16, 2011 10:57 pm
by brianempson
I will probably wind up going with option 3. I'll look into animation mixing in blender, thanks for all the input guys. Looking at the API, it seems like it would be possible to manipulate parts of the armature individually, but would probably turn out to be more trouble than it's worth.

Posted: Mon May 23, 2011 2:35 am
by brianempson
It turns out that option number 3 isn't going to be practical at this time. We have about 2000 frames from trying to mix in an animation program (blender) which results in a 9meg file and really eats up memory.

I made a simple animation wrapper to try to combine two (or more) animations at once but I am having trouble find the appropriate Irrlicht methods to get/set joint positions based on the frame number of each animation.

I was thinking:

-Make a frame counter for each animation to be mixed.
-Keep track of the frame counters individually

A routine like this for animating:
1. mesh->getMeshForCurrentFrame(animAFrame)
2. for (each bone in AnimA's bone list) copy (pos,rot,scale) to some array
3. do this for each animation to mix
4. for (each bone in the mesh) copy from the array
5. render

Seems kind of clunky, maybe i could add my own animation function to do that in one of the Irrlicht classes without setting the mesh position constantly. Perhaps using separate invisible models animating simultaneously and doing it that way would be easier?

Am I overlooking some obvious easy way to do this?

Posted: Mon May 23, 2011 4:03 am
by brianempson
It turns out I can get/set positions using the methods in the SceneNode class. However, the function getMeshForCurrentFrame() is private. Crap, I guess I'll have to figure out a different function to use...

Posted: Mon May 23, 2011 8:36 am
by CuteAlien
9 MB don't really sound yet like a problem. Or is this 9 MB per animation? That would indeed be very high (we're talking about bone-animations here, right?)

Posted: Mon May 23, 2011 9:15 am
by brianempson
Well it was 9MB for everything with about a third of the animations implemented.

Yes, bone animations. When all the characters are made the animations alone would take a really long time to load in game. (takes about 3 - 5 seconds to load one model at 9MB)

Hence the need for in-engine animation mixing. I'm working on a crude setup right now, just having issues with my model getting flipped upside down when joint control is enabled.

Posted: Mon May 23, 2011 10:48 am
by brianempson
I've gotten animation mixing to work in the actual engine itself.

What I did:

1. Create an invisible copy of the mesh for each animation to mix.
2. Animated each mesh with their respective animations
3. Copied the bone position and rotation for each animation to the actual visible mesh each tick.

Still testing it out...

Posted: Mon May 23, 2011 11:38 am
by Virror
Would be nice to see a video on this feature, with two separate animation and a mixed result : )