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

Thread: How do you rotate an individual object and not the whole scene?

  1. #1
    Intern Contributor
    Join Date
    Mar 2000
    Posts
    94

    How do you rotate an individual object and not the whole scene?

    How do you rotate two objects independently? I have a 3d cube suspended above a floor. i want to rotate the cube and not the floor. I can't get all the pushMatrix popmatrix, Modelview stuff to work right.. Can someone tell me the the syntax for acheiving this effect? Thanks again!

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Feb 2000
    Posts
    569

    Re: How do you rotate an individual object and not the whole scene?

    //preparation before rendering

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    //Set the view frustum(glfrustum or gluProjections
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity()

    //Set the camera position

    glPushMatrix();

    //transformations
    //Draw the floor

    glPopMatrix();

    glPushMatrix();

    //transformations
    // draw cube

    glPopMatrix();

    don't forget, if you want to rotate and oject around it's center you need to put the glRotate before the glTranslate


    [This message has been edited by Gorg (edited 04-04-2000).]

  3. #3
    Intern Contributor
    Join Date
    Mar 2000
    Posts
    94

    Re: How do you rotate an individual object and not the whole scene?

    Originally posted by Gorg:
    //preparation before rendering

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    //Set the view frustum(glfrustum or gluProjections
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity()


    I'm not sure I understand. What does translation have to do with my rotation?

    //Set the camera position

    glPushMatrix();

    //transformations
    //Draw the floor

    glPopMatrix();

    glPushMatrix();

    //transformations
    // draw cube

    glPopMatrix();

    don't forget, if you want to rotate and oject around it's center you need to put the glRotate before the glTranslate


    [This message has been edited by Gorg (edited 04-04-2000).]

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    Feb 2000
    Posts
    569

    Re: How do you rotate an individual object and not the whole scene?

    If you don't need to use translations, then don't use them.

Posting Permissions

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