Search code examples
iphoneopengl-esglrotate

How to change the Center-of-Rotation in OpenGL


I have a 3D Model (OpenGL ES 1.1 iPhone SDK v3.0) that is somewhat complex (i.e. Thousands of Vertexes and Faces) and I'd like to rotate this model around the Y-axis at or near the center of the Model. The problem is that glRotate rotates my model around a point at/near the center of one of its bottom edges, NOT near the center of the Model. Imagine a car driving very tight circles around a light-post, and that is basically what I've got. I want the car to be impaled on the light-post and be rotated around it. (Some source below)

   // BLUE BLOCK----------------------------------------------
    glPushMatrix();
    {
        glTranslatef(blueLocation[0], blueLocation[1], blueLocation[2]);
        glRotatef(blueRotAngle, 0.0, 0.0, 1.0);
        ...

THE QUESTION:
Is there an EASY way to change the Center of Rotation in OpenGL?


Solution

  • Sure. Translate the object down. THEN rotate it.