Sign in to follow this  

Question about OpenGL positioning

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


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

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
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]

Share this post


Link to post
Share on other sites
Sign in to follow this