Animation Techniques
-
- Posts: 14
- Joined: Sun Apr 24, 2011 4:10 am
Animation Techniques
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?
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?
-
- Posts: 14
- Joined: Sun Apr 24, 2011 4:10 am
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
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
-
- Posts: 14
- Joined: Sun Apr 24, 2011 4:10 am
-
- Posts: 14
- Joined: Sun Apr 24, 2011 4:10 am
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?
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?
-
- Posts: 14
- Joined: Sun Apr 24, 2011 4:10 am
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
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
-
- Posts: 14
- Joined: Sun Apr 24, 2011 4:10 am
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.
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.
-
- Posts: 14
- Joined: Sun Apr 24, 2011 4:10 am
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...
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...