PDA

View Full Version : Rotating an Object



purplepalace
01-17-2011, 08:33 AM
I have went through various objects on rotations and the tutorials seem to rotate correctly on the simple object like a cube. I am trying to get my object to rotate around the y-axis of the object , however it seems like it's rotating around an offset of my object's y-axis. It's hard for me to describe. I expect the center of my object to be rotating on point , rather the center of my object is making a circle around another point.

Here's a snippet of my code.
glLoadIdentity
glTranslatef(0.0f,0.0f,-4.0f);
glRotatef(rquad, 0.0f,-4.0f,0.0f);

Thanks in advance

mobeen
01-17-2011, 09:06 AM
This tells me that the object's modelling coordinates are not centered to the object's geometric center. Are you sure that the object coordinates are given correctly during modelling in ur modelling program? You can verify this by looking at the bounding box of your model.

mhagain
01-17-2011, 09:32 AM
Switch the order of your glTranslatef and your glRotatef - what happens?

mobeen
01-17-2011, 09:52 AM
Switch the order of your glTranslatef and your glRotatef - what happens?
I think switching the order of gltranslatef and glRotate will add another offset of (0,0,4) units to rotation. The current order is correct since opengl will apply rotation first (at object's origin which I think is shifted) and then translation.