Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: rotate around a custom object

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2006
    Posts
    2

    rotate around a 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);
    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.

  2. #2
    Junior Member Newbie
    Join Date
    Apr 2006
    Posts
    2

    Re: rotate around a custom object

    pop

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •