Swapping columns or any other such procedure is likely to lead into difficult to find bugs.  What you really want to do is define a coordinate transform (ie, a matrix) that transforms the Max coordinate system into your own.  This transform should be applied to the root joint of the character.  At that point, all child joints should come out in the correct system.  Switching handedness can also be accomplished with a matrix, if required.

Transforming any joint into world space (essential if you don’t want to go insane trying to debug CCD) is accomplished by simply applying the joint chain as you would to pose the character.  Transforming back into joint space requires building that world space transform as its own matrix and inverting it.  Transforming a chain back into local space is a bit tricky.  I’m not going to try to provide a solution off the top of my head.  Suffice it to say, it is worth looking up to make sure you have it right.  To do IK, transform the interesting bones to world space, figure out the solution and then carefully get those transforms back into joint space.  The main reason for working in world space is then you can use your debug draw utilities to draw everything you are doing.  (If you have sufficiently clever debug drawing code, you can work in local space and let the debug drawing code transform to world space).

-----Original Message-----
Sent: Monday, March 29, 2004 9:53 PM
To: gdalgorithms-list@lists.sourceforge.net
Subject: [Algorithms] Using animation keys from 3DSMax

Apologies if this isn't the right place for this, I've tried a few online forums, including Discreet's Sparks website without much response. Here's my issue.

For the rotations on my animation keys I'm using the quats defined by Max. The only issue that I had to overcome with that was that my engine understands y to be up, whereas Max understands z to be up. This was easily solved by swapping columns 2 & 3 when I converted animation keys into matrices before sending to the skinning routine (thereby swapping the y/z axes -- effectively the animation engine works in "Max's space").

Now that I'm trying to do some simple IK stuff, I'm having problems. Since all of the rotation keys that I use are considered to be in your parent's bone space, I need to calculate the rotation for a bone in Max's z-up quat space. I'm trying to do a simple CCD system, and I thought it would be sufficient to simply swizzle y/z of the axis of rotation when I build my quats, but that doesn't seem to be working -- I'm getting results that look just plain wrong.

Obviously I'm missing something obvious, can somebody help me out here?

Thanks,

Ryan Greene