• Advertisement
Sign in to follow this  

Rotations Blending

This topic is 1005 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've been doing graphics programming stuff for quite some time now and surprisingly never had to deal with animations much. Now I needed to blend more than two transforms (each transform is represented by position vector3 and roation quaternion). With two transforms it's easy. You do lerp for the translation and slerp to the rotation, providing "blend progress" parameter. Now how do I do the same for more than two transforms? For tanslation it's easy and intuitive - just do lerp of more than two translation vectors, whose weights sum up to 1. Check. Now the rotations... So how do I slerp more than two transforms? I searched the web and turns out it's not that simple problem. So I asked a fellow animation programmer and to my surprise he told me I got it all wrong. Slerping two rotations is not the same as blending them, he told me. Instead of slerping rotations I should do this:

Quaternion q1 = Quaternion.Slerp(Quaternion.identity, rotation1, weight1);
Quaternion q2 = Quaternion.Slerp(Quaternion.identity, rotation2, weight2);
Quaternion blendedQ = q1 * q2;

And when I need more rotations I just add more identity-to-rotation slerps and compose them with the total blended quaternion. Now that is easy and seems pretty intuitive. We just rotate by (weightN of rotationN) for each N.

So eventually I tried googling for rotations blending or animation blending, expecting many people askng this question and getting similar answer to the one I was given by my friend. But turns out it's rather hard to find this solution. Is this because that solution is so obvious and nobody ask about it or do you guys have some different ways for blending rotations?

Share this post


Link to post
Share on other sites
Advertisement

You simply NLERP or SLERP each rotation with his weight using identity as start and the sum of the weight must be 1.0f.

Share this post


Link to post
Share on other sites
I keep animations in their most general form, as interpolating/blending between rotations (either in quaternion form or matrix form) comes with a huge set of problems and loss of fine control.

That is, each run-time animation track remains just how it is: a track. This is important for reproducing animations exactly how they were authored.
This means 1, 2, or 3 tracks will manipulate an object’s X, Y, and Z rotations separately and then the final matrix will be generated.

This has huge advantages in the amount of control you have and its accuracy. You can use a track to manipulate the X rotation while separately manually manipulating the Y or Z, for example. It is impossible to handle all cases equally if instead you try to handle everything in matrix or quaternion format, since you are always manipulating all 3 components at once.

For blending, you simply blend between tracks, taking the weighted value from one and the inversely weighted value from the other. The final values are used for generating the matrices/quaternions.

This gives you further greater control since you can then blend tracks independently. This can be used for any number of reasons, but one simple example is to assume you have 1 set of tracks for an idle animation and you want to blend into a punch animation. By randomly slightly altering the blending periods for each track, the arm can raise into a punch slightly differently every time, adding a nice touch to your game.


L. Spiro Edited by L. Spiro

Share this post


Link to post
Share on other sites

The weighted average of orientations (unit quaternions) can be computed by taking the normalized eigenvector with the largest eigenvalue of the matrix consisting of the summed outer products of the quaternions.

 

http://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/20070017872_2007014421.pdf (eqn.12 and the text below it)

 

Slerping with the unit matrix then multiplying together is order dependent which you don't want while blending.

Share this post


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

  • Advertisement