Jump to content
  • Advertisement
Sign in to follow this  
M4573R

Blending two animations

This topic is 3322 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have keyframed animations working. Now I'm trying to blend multiple animations together. It almost works when I add all the bone transform matrices together, but it also adds the scales together, so the model gets twice as big when blending two animations. I've tried accounting for this scale in multiple places, but have been unsuccessful. What is the proper way to blend animations? Thanks

Share this post


Link to post
Share on other sites
Advertisement
When I always thought about animating models, I never thought of transforming the same bone by 2 different animations, id keep each animation for each separate part of the body and never mix them into a single bone.

So the running frames only include the legs, and gun pointing or weapon pointing frames never touch the legs.

Theyd do all sorts of strange things if you combined them together, i probably would never do it.

Share this post


Link to post
Share on other sites
I'm not trying to blend between two animations, I'm trying to play two animations at once. So I could have one animation of the legs running, and then play different animations for the torso. Its all the same skeleton, I just want to add the animations together. The problem comes when each bone has its translations, and when these get added together, the model gets bigger. So I can't just add all the translations together. But if a bone is animated to move up and down, I still want to mix that in with any other animation.

Lets say I have an a waving and a walking animation. If I blend them and play them each 50/50, they each move half as much. If I use each animation's transforms 100/100 then the model gets twice as big.

[Edited by - M4573R on September 12, 2009 5:51:51 AM]

Share this post


Link to post
Share on other sites
you are additively blending the animations, which has the effects you are seeing. Typically you'll mask off a set of bones to ensure the addition only affects a few bones out of the model (it's rare to see it applied to every bone because 95% of the time it just looks plain wrong).

Most commercial animation engines do not support scale - because it's a royal pita (multiply the bones transform by the inverse parents scale matrix to correctly fix the weird scale problems - or better yet, remove it completely).

Mind you, the effects shouldn't be 'that' noticeable if you are doing the blending in local space?

Share this post


Link to post
Share on other sites
Well I'm actually not using scale. It just has the effect of scaling. Since each bone has it's own offset from its parent, adding animations together will give each bone twice the offset, essentially scaling it up. I'm only using translation and rotation when creating my bone matrices. I may need to change the way I export my bone matrices. I tried fixing the problem by only adding in changes from the bind position. However I found out that my bind matrices are much different from the keyframe matrices on the first frame of the animations. I could mask the effects, but I like having the power to add any animations together that I want. Is this easier to fix when it's a translations problem? Or does it actually become a scale problem when I add all the transform matrices together for each bone?

Share this post


Link to post
Share on other sites
Have you tried computing averages instead of adding? Each animation will have a rotation at each joint plus an "alpha" value that is a soft mask indicating what parts of the body are affected by the animation. For each joint, take the rotation indicated by each animation and blend them together with weights proportional to the alpha values.

In order to blend together several rotations, you'll probably get better results using nlerp with quaternions. In any case, make sure you normalize the quaternion or orthonormalize the rotation matrix at the end, or you'll get shrinking and enlarging models.

Share this post


Link to post
Share on other sites
Quote:
Original post by rouncED
When I always thought about animating models, I never thought of transforming the same bone by 2 different animations, id keep each animation for each separate part of the body and never mix them into a single bone.

So the running frames only include the legs, and gun pointing or weapon pointing frames never touch the legs.

Theyd do all sorts of strange things if you combined them together, i probably would never do it.


Combining them together is done often in commercial games. For instance, you can blend from one animation to another to get rid of that "poppy" effect that happens when you abruptly change animations :P

But hey, to the OP:

what you might try doing is keeping your translations, scales, and rotations around, add them together (or blend, or do whatever you want to do) and then AFTER all that stuff is done, then make matrices out of them.

It's a lot easier to blend translations, scales, and rotations seperately then trying to blend a matrix (:

Share this post


Link to post
Share on other sites
Quote:
Original post by Atrix256
But hey, to the OP:

what you might try doing is keeping your translations, scales, and rotations around, add them together (or blend, or do whatever you want to do) and then AFTER all that stuff is done, then make matrices out of them.

It's a lot easier to blend translations, scales, and rotations seperately then trying to blend a matrix (:


That's actually what I changed it to. Although I'm still getting the same problem. Perhaps I need to normalize the quaternions like alvaro said. But won't the position offsets from the parent of each bone still add together and cause the model to grow?

Share this post


Link to post
Share on other sites
the translations (like the scale and rotations) are local to the joint (ie depend on the parent) so that won't be a problem.

You might have to subtract out the reference skeleton while blending... I'm not 100% on that though sorry :/

One thing that might help you too is make an animation with only one of the components (scaling, rotating, translating) and get that working, and then move onto the next one just to isolate them into individual problems.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!