Hi,
I’m having a few problems trying to get my object to rotate around the global (world) axis, rather than it’s own local axis.
Here’s the order in which I’m doing my transformations:
gl.glTranslatef(transObjx,transObjy,transObjz);
gl.glRotatef(rotObjx,1.0f,0.0f,0.0f);
gl.glRotatef(rotObjy,0.0f,1.0f,0.0f);
gl.glRotatef(rotObjz,0.0f,0.0f,1.0f);
gl.glScalef(scaleObjx,scaleObjy,scaleObjz);
But this is giving me undesirable results! Here’s what happens. Say my object starts off like this first image:
Now after the first rotate of 45 degrees around the X axis it looks like this:
But now when the object rotates around the Z axis, it looks like the following image:
It it rotates around the purple axis not the blue one, because it’s already been rotated around the X axis first!
How can I get it to rotate around the blue Z axis, regardless of how much it’s been rotated around the X axis? In other words, I need to force OpenGL to retain the same global axis when I’m doing rotations, not the local axis.
I know I could do this easily if I wrote the rotation code myself, but I’m using Java so this will slow it down a lot.
Many thanks for your help!
Bob