PDA

View Full Version : Object movement



Me6
06-24-2004, 10:27 AM
How do move an object's xyz axis' in opengl? Or how can I move the object forward and backward? Am I being too vague in my questions? Thanks...

ZbuffeR
06-24-2004, 10:54 AM
glTranslated(x,y,z) if your values are doubles or glTranslatef(x,y,z) if your values are floats.

Is my answer precise enought ? Thanks... :p

Aeluned
06-24-2004, 10:54 AM
here's one way:

glMatrixMode(GL_MODELVIEW);
glPushMatrix();
//now you perform your transforms

glTranslatef(deltaX,deltaY,deltaZ);
glRotatef(theta,x,y,z);
glScalef(xScale,yScale,zScale);

//Render your object

glPopMatrix(); //restore modelview matrix

Me6
06-24-2004, 07:32 PM
Thanks... How could I get a camera to follow it? Thanks again...

ChinaShrimp
06-24-2004, 10:06 PM
I think When you move the object, the camera's position doesn't change. It's decided by the parameters of gluLookAt.

Me6
06-25-2004, 06:06 AM
Could I make it change according to the objects position?