View Full Version : How do you rotate an individual object and not the whole scene?
Ace_Man
04-04-2000, 10:28 AM
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!
//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).]
Ace_Man
04-04-2000, 09:18 PM
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).]
If you don't need to use translations, then don't use them.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.