Question about OpenGL positioning
When you glTranslatef( x, y, z ), is it specifying the middle of the object, or the top left?
Thank you...
Oh!! I see~
But does it count how much you want to move it from the center or from the sides?
But does it count how much you want to move it from the center or from the sides?
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]
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]
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]
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]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement