Rotation problem

Hello
I’m trying to make the global origin visible on the screen and also add the x, y and z symbols to the axis. I want the symbols to rotate with axis but also rotate the same angles in the opposite direction so they always remain readable on the screen. I can do this if I only rotate in one direction but when mixing x, y, z rotations after each other the symbols show up wrong. Here is part of the code,

glRotatef (x_rotation, 1.0, 0.0, 0.0);
glRotatef (y_rotation, 0.0, 1.0, 0.0);
glRotatef (z_rotation, 0.0, 0.0,1.0);
.
here follows drawing of some objects
.
drawing line segments showing the x, y, z axis
.
glTranslatef (x_translation, 0, 0);
glRotatef (-x_rotation, 1.0, 0.0, 0.0);
glRotatef (-y_rotation, 0.0, 1.0, 0.0);
glRotatef (-z_rotation, 0.0, 0.0, 1.0);
.
draws X
After here I do the same for y and z.

Suggestions about what’s wrong or a working code would be appreciated.

Thanks

Hello,

do you mean something like this? :smiley: :
http://horustempel.de/OpenGL/Bilder/descartes.png

that’s not a problem.
You could use glPushMatrix() and glPopMatrix() and you have to reverse the order of the reverse rotation commands.
It would look something like this :

glRotatef (x_rotation, 1.0, 0.0, 0.0);
glRotatef (y_rotation, 0.0, 1.0, 0.0);
glRotatef (z_rotation, 0.0, 0.0,1.0);
.
here follows drawing of some objects
.
drawing line segments showing the x, y, z axis
.
glPushMatrix();
glTranslatef (x_translation, 0, 0);
glRotatef (-z_rotation, 0.0, 0.0, 1.0);
glRotatef (-y_rotation, 0.0, 1.0, 0.0);
glRotatef (-x_rotation, 1.0, 0.0, 0.0);
draws X
glPopMatrix();
.
the same for Y and Z

Sumpfratte

Order of rotation, I overlooked that!
Thanks a lot, this helped me out.