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 3 of 3

Thread: Rotation of object

  1. #1
    Newbie Newbie
    Join Date
    May 2017
    Posts
    1

    Rotation of object

    How to ratate the 3D object arround itself in all the axis.

    glRotatef(0.0,0.858824f,0.576471f,0.439216f);

    I use this cases to rotate my object arround the axis.
    case 'l':
    glRotatef(-1.0,1.0f,0.0f,0.0f);
    break;
    case 'r':
    glRotatef(-1.0,0.0f,0.0f,1.0f);
    break;
    case 'd':
    glRotatef(-1.0,0.0f,1.0f,0.0f);
    but i wand how to rotate object itself.

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    4,478
    Rotation transforms are typically about the origin. If you want to rotate about a different point, you have to translate that point to the origin first, then apply the rotate.

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    2,926
    Quote Originally Posted by Dark Photon View Post
    Rotation transforms are typically about the origin. If you want to rotate about a different point, you have to translate that point to the origin first, then apply the rotate.
    ... then translate back.

    The sequence
    Code :
    glTranslatef(x, y, z);
    glRotatef(...);
    glTranslatef(-x, -y, -z);
    constructs a rotation about the point (x,y,z).

Posting Permissions

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