View Full Version : Moving 3D objects

07-11-2001, 01:04 AM
How can I move 3D objects?
Which is the GLUT function?

07-11-2001, 01:27 AM
use glTranslatef(....) and glRotate(...) to move your

07-11-2001, 01:56 AM
But how can I move this quad for example one unit right.

glVertex3f(-1.0f, 1.0f, 0.0f);
glVertex3f( 1.0f, 1.0f, 0.0f);
glVertex3f( 1.0f,-1.0f, 0.0f);
glVertex3f(-1.0f,-1.0f, 0.0f);

07-11-2001, 02:45 AM
Ok do you know what a cartesian plain is?
Consider youre 3D space a cartesian plane.
Ok now it depends whether you want to move the object or the entire scene. I'm gonna take it you want to move the object as you stated. After you pushed the matrix state, have glTranslatef(varX,y,z);
Ok every time the loop executes you can increment varX with a value, to get the object to move either left or right, considering that you did not change youre plain. I suggest, increment it with about 0.1f. Do you understand? To rotate it, you just change the angle at which it rotates, in other words you will have youre variable like so. glRotatef(varAngle, 0.0f,1.0f,0.0f);
Hope it helps http://www.opengl.org/discussion_boards/ubb/smile.gif

07-11-2001, 02:53 AM
Oh crap yeah, almost forgot. Glut doesn't have a specific function to translate or rotate, seeing that it's so simple already.