View Full Version : Matrix Conversion

10-03-2002, 08:03 AM
I am adding skeletal animation to my max exporter and am running up onto a problem
my brain cannot visualize...

Max's orients everything with the Y axis pointing out of the screen and the Z axis pointing

When I export verts, I just set y=z, and z=-y and all is good.

Now that I am exporting bone matrices and quaternions I'd like to convert them to my more
conventional axis.

Perhaps someone who has done something similar can give me a few pointers.



10-03-2002, 10:06 AM
Hi Joe. What you are really doing when you set y = z and z = -y is a 90 degree rotation around the x axis. This sort of operation can be encoded in a 3x3 matrix (call it M).

You can use OpenGL's glRotatef() and glGet() calls to create this matrix if you need to.

Once you have it, you can use it to fix your vertices and matrices (and quaternions).

To fix your vertices, just do this:

new vertex = M * old vertex

To convert your matrices and quaternions to the new space is slightly more complicated. I believe you'll have to do this:

new matrix = M * old matrix * M^(-1)

Where M^(-1) is the inverse of M, which, for rotation matrices, is the same as the transpose.

-- Zeno