Public Group

This topic is 5155 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

When you glTranslatef( x, y, z ), is it specifying the middle of the object, or the top left? Thank you...

##### Share on other sites
Neither. It's specifying how much you want to move it.

##### Share on other sites
Oh!! I see~

But does it count how much you want to move it from the center or from the sides?

##### Share on other sites
It works out the same either way.

##### Share on other sites
You're actually changing the center of your coordinate system (or performing a translation on your World Transform, if you prefere).

As such it just means that all coordinates will be offset by (x, y, z).

So

glTranslatef(100, 0, 00);
glBegin(GL_LINES)
glVertex3f(10, 10, 10)
glVertex3f(-10, -10, -10)
glEnd();

would give an equivalent image to

glBegin(GL_LINES)
glVertex3f(110, 10, 10)
glVertex3f(90, -10, -10)
glEnd();

Makes sense?

[edited for errata]

[Edited by - __ODIN__ on September 5, 2005 11:57:55 PM]

##### Share on other sites
You do not move objects but, like __ODIN__ says, the coordinate system tied to the object. There is no top left or middle of objects, you just send vertices and whereever they end up on screen will depend on the viewport, projection and modelview you have specified.

So, if you translate you move the origin of the local coordinate system, and then you draw the object into that moved/translated coordinate system by sending the vertices. Whereever the corner or middle of the object you paint end up depends on the vertices you specify: (0, 0, 0) would obviously be the middle of a rectangle if you draw a rectangle from (-10, -10, 0) to (10, 10, 0); but you may also draw it from (0, 0, 0) to (20, 20, 0) and then the origin of the local coordinate system would be one of the corners.

[Edited by - brulle on September 6, 2005 7:20:50 AM]

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 16
• 11
• 24
• 42
• 75