Local and global axis

I’ve got my little space ship, in say list 1, and I have the angles that the players wants to rotate it by, but whenever I rotate it by those angles with

glRotatef(x_angle, 1, 0, 0);
glRotatef(y_angle, 0, 1, 0);
glRotatef(z_angle, 0, 0, 1);

but when the user wants to roll back, it rotates it round the global x axis rather than the local axis. So I do a nice bit of complex 3D trig to calculate the vectors to rotate around, but it still screws up as the vectors have also been rotated!

Help me please! An A level maths student who can’t do trig!

Simon Hall

Originally posted by simonjhall:
Help me please! An A level maths student who can’t do trig!

Eventually, even if you get this ‘right’, you will
run into the problem of “gimbal lock” (sp?)

I have also written a small spaceship flying around a
solar system OpenGL program just for kicks and
quickly ran into the sorts of problems you’re having.

I now use quaternions to represent the orientation
(rotation) of my space ship and it works great.

Here are some references:


The <a href=“http://plib.sourceforge.net” target="_blank">Portable Game
Library</a> also has some nice quaternion
classes ready to use.

Hope this helps

[This message has been edited by rts (edited 09-26-2000).]