PDA

View Full Version : rotate around a custom object



bbazatu
04-16-2006, 03:10 PM
Hi,
I have the following code. I am trying to rotate around the point that I am looking at (1.5, 2.5, 0) but it seems the rotation is around the 0, 0, 0 axis. What should I do to rotate around the center point that I am looking at?
glLoadIdentity();
gluLookAt(0, 0, -10, 1.5, 2.5, 0, 0, 1, 0);
glRotatef(rotTri, 1.0f, 0.0f, 0.0f);

glBegin(GL_TRIANGLES);
glVertex3f(1.0f, 3.0f, 0.0f);
glVertex3f(1.0f, 1.0f, 0.0f);
glVertex3f(2.0f, 1.0f, 0.0f);
glEnd();

Somebody told me that I should first translate the point to the origin, rotate and then translate it back.
glLoadIdentity();
gluLookAt(0, 0, -10, 1.5, 2.5, 0, 0, 1, 0);
glGetFloatv(GL_MODELVIEW_MATRIX, (GLfloat*) tmatrix);

after this two calls the translation values in the MODELVIEW matrix are 1.4834 -2.37352 -9.60031. So the translation to the origin what does it mean?

Can somebody point me to some good example, or cand somebody explain here what should I do to achieve the desired effect? I need to rotate around the X axis that passed trough the point 1.5, 2.5, 0.

Thank you so much for any good answer. I have posted this on the beginner forum but I got no complete answer.

bbazatu
04-18-2006, 10:47 PM
pop