My rotations is not correct.

I have tried to do some scene lately where I want to rotate my object around it self and after that translate it to an arbitrary point in space. After that I want to use gluLookAt… But when I do this I get my object to rotate around itself but then after the gluLookAt it continue to rotate but now in reference to its new point in space. How do I solve this?
Here is my code:


glRotatef(obj->xv, 1.0f, 0.0f, 0.0f);
glRotatef(obj->zv, 0.0f, 1.0f, 0.0f);
glRotatef(obj->yv, 0.0f, 0.0f, 1.0f);

I have tried to put the gluLookAt after the rotations and the translations but then it disappears from the screen.
What am I doing wrong?


If i understand correctly in order to make the object rotate about itself at an arbitrary point in space you should do this

glRotatef(xAngle, 1.0, 0.0, 0.0);
glRotatef(yAngle, 0.0, 1.0, 0.0);
glRotatef(zAngle, 0.0, 0.0, 1.0);

BTW, check your second rotate as it uses the z-angle to rotate about the y-axis.

One other thing to be aware of: if you perform your rotations around the x, y and z axes in order like that, you could come across everyone’s favourite topic “gimbal lock”. I won’t go into it here - it’s been covered many times already. Do a search of the discussion boards for “gimbal lock” and “quaternions” and you’ll find heaps of links.