PDA

View Full Version : CameraRotation with Quaternion



SebastianB
07-10-2002, 05:40 AM
hey, i spent the last days reading quaternion stuff, and thought i understood what theyre about. but after i recoded my camera-rotation, it DOES rotate, but not only around x- and y-axis, but also around z when i rotate a lot to the left or right ....

------------------------------
// compute quatRotation
BasicQuaternion *quatRotation = new BasicQuaternion(angleX, angleY, 0);

// multiply quatRotation with quatOrientation
quatOrientation.PostMult(*quatRotation);

// compute direction from new quatOrientation
quatOrientation.GetDirectionVector(&direction);

BasicQuaternion quatTemp;
memcpy(&quatTemp, &quatOrientation, sizeof(BasicQuaternion));

// compute strafeVector from new quatOrientation
quatOrientation.PostMult(BasicQuaternion(0.0f, 90.0f, 0.0f));
quatOrientation.GetDirectionVector(&strafeDirection);
memcpy(&quatOrientation, &quatTemp, sizeof(BasicQuaternion));

// compute upVector from new quatOrientation
quatOrientation.PostMult(BasicQuaternion(90.0f, 0.0f, 0.0f));
quatOrientation.GetDirectionVector(&upVector);
memcpy(&quatOrientation, &quatTemp, sizeof(BasicQuaternion));
------------------------------

it should only rotate around x and y.
quatOrientation is the quaternion that stores the orientation of the camera.
angleX and angleY come from my mouseDeltaMovement ...

any idea ??


:)
seb