View Full Version : Flight sim type game

04-01-2001, 01:11 AM
Im having some problems with opengl, flightsims and cameras
first of all, to move and rotate the camera i do:

glRotatef(camera.angles[ROLL], 0.0f, 0.0f, 1.0f);
glRotatef(camera.angles[PITCH], 1.0f, 0.0f, 0.0f);
glRotatef(camera.angles[YAW], 0.0f, 1.0f, 0.0f);
glTranslatef(camera.origin[0], camera.origin[1], camera.origin[2]);

Then i draw all the stuff. You can press the arrow keys to rotate the spacecraft similar to a flight-sim:

change in yaw = sin(roll)*turn speed
change in pitch = cos(roll)*turn speed

for some reason, when the pitch gets > 90 and < 270, so around 180, everything screws up and it doesnt pitch up, but when you pull up it starts rotating sideways.
I tried changing the order of the glRotatef stuff, but that just makes it screw up when the yaw gets around 180
There is a way to do this, i saw it on a web page about this game called Airlock, it said something about using quarters or something instead of euler angles

04-01-2001, 04:02 AM
This really isn't an Advanced question, and it has been covered seventeen billion times already on this forum and many, many others. Try a search for "gimbal lock" and/or "quaternion".