Help! Calculate a matrix form S, R, T is wrong.

Started by
3 comments, last by codewings 14 years, 1 month ago
Hi, I am a new guy of game industry. Now I am writing a exporter for animation. I use two vector3 and a quaternion to store the bind pose and the key frame of each bone. But I found sometimes these component cannot be revert to the original matrix. I disassemble the matrix into S,R,T and calculate the transform by these value. The each value of the 3x3 part in the result matrix is the negative one of the original matrix. Currently I only found one bone has this situation. All others are correct. I tried my matrix class and D3D matrix. It still has this problem. I have not idea now. Can anyone give me some hint or answer? Thanks in advance.
Advertisement
How are you extracting the components? If you're not careful, you can get a reflection in the rotation, and another in the scale.
At beginning, I use my matrix class. But after I found this problem, I tried the matrix class supported by 3dsmax SDK and D3D matrix.

The methods in all these class can give the correct result except a bone in a simple animation.

Now I am using GMatrix::Scaling(), GMatrix::Rotation() and GMatrix::Translation().
Some things you should check:

Are you multiplying the matrices in the right order, to get your original matrix again? So like scale * rot * pos versus pos * rot * scale. I assume you do this correct since you say it works for most cases.

It sounds like you might be using non-uniform scale. Check if the scale.x == scale.y == scale.z. If not, you need to introduce a scale rotation matrix as well to perform the scaling in another space. Since it happens on just one node so far this might very well be your problem.
There is no scaling in my animation. I have checked everything I know. And I also found that the angle of the quaternion exact from the new matrix plus the angle of the original quaternion is nearly 2PI.

But I don't know if it is the key of the problem.

This topic is closed to new replies.

Advertisement