I'll talk about my issue with quaternions.
So, i've changed a lot the code, hoping that it solves my problem but nothing changes.
Now the "lookAt" function doesn't receive a vector, but two angles: pitch and yaw. First i compute the pitch rotation (Quaternion q), then the yaw rotation (Quaternion r), and last multiply the two quaternions and rotate the camera using the result.
void MyCamera::lookAt(Ogre::Real pitch, Ogre::Real yaw) {
Quaternion q(Degree(pitch), Vector3::NEGATIVE_UNIT_X);
Quaternion r(Degree(yaw), Vector3::NEGATIVE_UNIT_Y);
q=q*r;
mCamera->rotate(q);
}
This is what happens.
in the upper-left panel now i display the "right" vector of the camera. Ok?
- First i rotate around Y axis (yaw), keeping pitch==0 all the time: you can see that right vector has his y coords always = 0. It's correct: the y component of right vector defines the "roll" rotation. If it's always 0, camera does not rolls.
- Next i rotate around X (pitch), keeping yaw==0 al the time. Now the right vector is = (1,0,0), always. In the video you can see not properly (1,0,0) because of the Ogre::Real resolution, but it's something like (1,0.00000001,0.00000001). And it's correct; when i pitch changes the look at, changes the up vector, but the right vector remains normal to plane YZ. Again: the y component of right vector is always = 0, so no "roll" of the camera. Perfect.
- Finally i unlock both rotation and start to combine it: the camera starts to roll, and you can see tha the y component of right vector grows... if it's > 0 camera rolls left, if it's <>
My questions now are: WHY!?!? What's wrong? And what is the correct way?
Thank you for the patience. I'm a noob about rotation.