Remember OpenGL first works backwards in how glRotate/translate effect an object.
Every thing is draw in respect the the world origin.
example 1:
glTranslate
glRotate
draw_object
// Object is rotated on its axis 0,0,0 Which could be located at any part of the object. I like to draw objects with there center being 0,0,0.
example 2:
glRotate
glTranslate
Draw_object
// Object is translated out, then rotated around the world axis 0,0,0.
So if you were to translate it 5 units on the x and then rotate it on the x, the object will be moved in a arc fashion based on radius of the translate x value.
I hope that makes sense
Also do you know how to use glPush/PopMatrix()?
// Global stuff, could be use for camera movement
glTranslatef( glob_x, glob_y, glob_x); // Translate world
glRotatef(ax, 1, 0, 0); //Rotate world x axis
glRotatef(ay, 0, 1, 0); //Rotate world y axis
glRotatef(az, 0, 0, 1); //Rotate world z axis
// Object movemt
glPushMatrix()
glTranslatef( objecy_x, object_y, object_x); // Translate Object
glRotatef(ox, 1, 0, 0); //Rotate object x
glRotatef(oy, 0, 1, 0); //Rotate object y
glRotatef(oz, 0, 0, 1); //Rotate object z
Draw_object();
glPopMatrix();
repeat above for each object push/pop for each object.
Originally posted by DennisMV:
[b]I have an object, and I do these rotations in sequence inside the code: X, Y, and Z. Also, these are absolute rotations. I several sliders which give absolute values for the variables.
There is an inherent problem here. When I want to rotate around only one axis, it’s fine.
However, suppose I rotate around Y first,
and then rotate around X. The object rotates now around it’s OWN X axis, when I want it to rotate around the GLOBAL X Axis.
Is there a way to do something here ?
I’ve thought and thought about this, I looked up rotations around parallel axis, even around arbitrary axis, but they do not help … the rotations are still the same, with the same inherent problem. Is there maybe another way to do this and still get rotations around all the axis ?
Can someone shed some light on this ?
thank you !
Dennis
[/b]