I have some understanding problem concerning quaternions.
In order to have my world object rotate in the correct way, I need to invert their quaternion rotation while refreshing the object world matrix.
I create the object rotation with this code:
Rotation = Quaternion.RotationMatrix(Matrix.LookAtRH(Position, Position + new Vector3(_moveDirection.X, 0, _moveDirection.Y), Vector3.Up));
and refresh the object World matrix like this:
Object.World = Matrix.RotationQuaternion(Rotation) * Matrix.Translation(Position);
This is not working; it makes the object rotate in the opposite way compared to what it should!
The is the way that makes my object rotate correctly:
Object.World = Matrix.RotationQuaternion(Quaternion.invert(Rotation)) * Matrix.Translation(Position);
Why do I have to invert the object rotation?
I have quaternion mainly because its a more compact way of sharing a rotation than a matrix. (you have a network layer exchanging the quaternion data).
So you thing that it could come from the Matrix.LookAtRH ? I will check it.
– Fabian Sep 20 '11 at 06:30