Please help me wrap my head around this 3d graphics math. :(
I'm writing an application in OpenGL for learning purposes and I'm trying to allow the user to modify the angle by which I rotate an object around the X axis, the Y axis, and the Z axis.
My problem is that I only know how to do the following:
glRotatef(xAngle,1,0,0);
glRotatef(yAngle,0,1,0);
glRotatef(zAngle,0,0,1);
(basically, rotate around the x axis, then around the y axis, then around the z axis)
This doesn't work because, essentially, after rotating, say, 90 degrees about the x-axis, the y and z axes are no longer where they used to be. See
this crude picture for more information on what I'm talking about.
What I'm looking for is best practice on what to do in this situation. I have two opengl books and I've searched the internet and I haven't been able to find out anything about this. Surely this must be a common problem?
Code or (well-explained, not dry) math theory would be much appreciated. Thanks!
posted by sbutler at 2:29 PM on October 14, 2008