# rotate around custom object

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);
glColor3f(1.0f, 0.0f, 0.0f);
glVertex3f(1.0f, 3.0f, 0.0f);
glColor3f(0.0f, 1.0f, 0.0f);
glVertex3f(1.0f, 1.0f, 0.0f);
glColor3f(0.0f, 0.0f, 1.0f);
glVertex3f(2.0f, 1.0f, 0.0f);
glEnd();``````

Dear bBazatu,

1. Translate the point X(1.5,2.5,0) so that it becomes origin i.e glTranslatef(-1.5,-2.5,0.0f)
2. Now Perform the Rotation using glRotatef
3. Translate back to point X

Rajesh
IRIS,CAIR,
Bangalore

Hi,
Thanks for the answer.
I donâ€™t get the desired efect. After the translation back to the centered point it seems the hole scene is rotating around a cylinder and not around the object.
I want the entire scene to rotate around the X axis that goes trough the point (1.5, 2.5, 0.0).

``````gluLookAt(0, 0, -10, 1.5, 2.5, 0, 0, 1, 0);
glTranslatef(-1.5f, -2.5f, 0.0f);
glRotatef(rotTri, 1.0f, 0.0f, 0.0f);
``````

??? glTranslatef(1.5f, 2.5f, 0.0f);

any help would be appreciated

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?

1. glTranslatef(-1.5, -2.5, 0)
OR
2. glTranslatef(-1.4834, -2.37252, 9.60031)?

It drives me crazy. I can not find a good example work. I really need the gluLookAt call first.

thx.
b bazatu