Computed rotation matrix to quaternion?

Recommended Posts

Hello! I've got a problem, and don't even know whenever this is possible to solve in that way. The best way to explain is to demonstrate what I do:
LocalBoneMatrix = Matrix.Identity;
LocalBoneMatrix = Matrix.CreateRotationX(x) * Matrix.CreateRotationY(y) * Matrix.CreateRotationX(z);
LocalBoneMatrix.Translation = new Vector3(x,y,z); //sets M._41, _42, _43

Okay, so far it is clear and simple. But the problem appears whenever I try to create a quaternion and translation like this:
Quaternion rotation = Quaternion.FromMatrix(LocalBOneMatrix);
Vector3 position = LocalBoneMatrix.Translation;
Matrix comp = new Matrix.FromQuaterion(rotation);
comp.Translation = position;

The wierd stuff is that the comp matrix is not the same as LocalBoneMatrix and the animaton gets messed up. Is it possible to store 3 different rotation into one quaternion and restore it?!

Share on other sites
Looks to me like you are setting the matrix to a translation after you apply rotation, instead of multiplying rotation by translation and then setting.

But I use Dx10 and I have no idea what you are using with matrix properties. I guess its XNA. So, I can't follow what's going on.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

• Forum Statistics

• Total Topics
628346
• Total Posts
2982203

• 10
• 9
• 24
• 11
• 9