Applying transformations to a bone over the animation

Topics: Developer Forum, User Forum
Jul 11, 2007 at 12:17 PM
Hi there.

Following up on a tweak on the BonePose class I mentioned a few months ago, I was asked to explain it in a little more detail by one of the users of this library. I will post that here as someone else may be interested too.

The question was the following:

Hi jnogueira,
I'm contacting you for the following reason:
In this post from Feb 12, you had stated that you can have extra control of boneposes by adding "one more matrix in each BonePose instance that enables the coder to transform the bone on top of the animation's own transformation".
That's pretty cool...
Would you please explain me how exactly did you do that? I have a character that I would like to rotate the torso and it's childrens without losing the existing animation. Like an Offset Rotation.

I no longer have the modified code I was talking about but I will walk you through this little tweak:

In the BonePose class there is a method called GetCurrentTransform(). It returns a matrix that describes the bone's transformation for that frame. This accounts for its initial position, animation transformation, animation blending and its parent's position: the whole deal!

All you have to do to add an additional transformations (e.g. rotating the torso but keeping the previous transformation data) is to modify that method and multiply the matrix that would be returned by your own transformation before actually returning it.

As you can see, there are actually 3 possible return values that correspond to:

1) No animation at all: the default transformation is retured: return defaultMatrix;

2) One animation (no blending): return currentMatrixBuffer;

3) Blended animation: the SlerpMatrix stuff + return returnMatrix;

So you will probably want to multiply each of those matrixes by your own transformation (e.g. the torso rotation matrix) before returning them. Of course you may keep your transform matrix inside the BonePose class (e.g. as a property) or wherever you like.

I hope it was clear enough ... and correct (I did this modification a few months ago and I no longer have that source code, so the explanation above was not tested). Let me know if I can help any further.

Jul 11, 2007 at 5:20 PM
Thanks a lot João!.
The idea is clear enough, which should work like a charm.,
I have to dig in the animation component source code though, never seen it before.
Will test it right away. For anyone else interested, as soon as I have a modified working code I'll post it here.