Recommended Posts

In my engine I am adding support for models in the X format. I am not using D3DX but my own skeletal animation system. The importer seem to work fine because the mesh is correctly visualized, both in the character pose (without skinning) and in the bind pose (applying the offset matrices and combined joint transformations).
The problems start when I try to animate the joints, using information extracted from the loaded animation controller. These information come in the form of a set of keyframes, one for rotations (as quaternions), one for translation and one for scaling. The algorithm I'm using is the standard one and it works perfectly with Milkshape3D models for example, so my fear is that DirectX stores keyframes using a convention different than the one used by my engine.
For example, what order and coordinate system (this should not matter as long as everything is consistent) are the rotation, translation and scaling applied?
My algorithm:
.for each joint {
. interpolate rotation, translation, scaling
. build matrix M = translation*rotation*scaling (scaling is always identity in my samples, ignore it..)
. if (joint->parent) {
. joint->combined = joint->parent->combined*joint->relative*M
. }
. else {
. joint->combined = joint->relative*M
. }
.}
.for each bone {
bone->matrix = bone->joint->combined * bone->offsetMatrix
}
The bones' matrices are then passed to a vertex shader and used for skinning.
As I said, everything works as long as M = identity and it also works for Milkshape models so the problem is my interpretation of the keyframes imported from the X model.
I have looked everywhere on the net all tutorials, examples etc but I didn't find any information specific to my problem. Any help will be very appreciated!!!

Another difference I found by chance is that I had to negate the w component of all quaternions of the rotational keyframes. This has the effect of rotating the joints in the opposite direction with respect to their parents and it gives me correct animations. Go figure why.

If only Microsoft put some effort in documenting their classes and algorithms; reverse engineering is really not that fun.