Animation Techniques

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
brianempson
Posts: 14
Joined: Sun Apr 24, 2011 4:10 am

Animation Techniques

Post 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?
nespa
Posts: 167
Joined: Wed Feb 24, 2010 12:02 pm

Post by nespa »

case 3 only
Virror
Posts: 191
Joined: Mon May 02, 2011 3:15 pm

Post 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.
brianempson
Posts: 14
Joined: Sun Apr 24, 2011 4:10 am

Post by brianempson »

Perhaps animation mixing can be a new feature? :)
CuteAlien
Admin
Posts: 9718
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post 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.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
brianempson
Posts: 14
Joined: Sun Apr 24, 2011 4:10 am

Post 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.
brianempson
Posts: 14
Joined: Sun Apr 24, 2011 4:10 am

Post 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?
brianempson
Posts: 14
Joined: Sun Apr 24, 2011 4:10 am

Post 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...
CuteAlien
Admin
Posts: 9718
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post 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?)
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
brianempson
Posts: 14
Joined: Sun Apr 24, 2011 4:10 am

Post 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.
brianempson
Posts: 14
Joined: Sun Apr 24, 2011 4:10 am

Post 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...
Virror
Posts: 191
Joined: Mon May 02, 2011 3:15 pm

Post by Virror »

Would be nice to see a video on this feature, with two separate animation and a mixed result : )
Post Reply