View Full Version : rotating the camera around y axis
11-07-2002, 01:02 PM
My camera can pitch and yaw but I would like it to yaw NOT relative to the new camera's rotation. In other words, I would like the yaw to always rotate around an axis (0,1,0) in world coordinates relative to the camera position.
I tried translating back to the origin, rotating the Y axis and translating back but that didn't work. I also tried rotating around an arbitrary axis.
Could someone please point me in the right direction? Thanks!
11-08-2002, 04:57 AM
I don't understand... do you rotate the camera in one glRotatef() call? Remember you can call that function multiple times, so you can rotate around all axes independently. I think I've had the same problem. If you _do_ use multiple calls, try to change the order, that should help.
[This message has been edited by mm_freak (edited 11-08-2002).]
11-08-2002, 05:48 AM
Have you looked at glulookat
11-09-2002, 12:36 PM
Here is my code to do it (Z is up):
inline void TerrainCamera::Yaw( float angle )
// Yaw for this camera is always around the __terrain's__ Z axis so
// the camera's Z axis is un-oriented to get that axis.
Turn( angle, Vector3f( Vector3f::ZAxis() ).Rotate( -GetOrientation() ) );
11-11-2002, 06:59 AM
I already store a current matrix for my camera and I do glLoadMatrixf(cameraMatrix) in the beginning of my drawing.
So, I guess I should do the y rotation as the very first transformation and then multiply that matrix by my current camera matrix to get the new camera matrix rotated in the way I need it?
11-11-2002, 05:17 PM
OK, I got it working now. I needed to convert my camera matrix to its inverse before doing glLoadMatrix because I was treating the camera matrix just like any other object.
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.