# How do you guys determine world co-ordinates?

I’m a complete beginner so today I was looking at gluLookat and thinking about using the camera position as an absolute world position. I place the camera at 0,0,5 observing a triangle at 0,0,0 However this is a bit confusing because the camera is initially looking down the negative z axis and a forward move means a decreasing z value so I cheated a bit by using
-(z)

gluLookAt (0.0, 0.0, -(-5.0), 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

That is correct the openGL default is looking down the - z axis in ortho mode.
You world co-ordinates will depend a lot on the ortho view setup or perspective view.

Just take the values of you view to determin where your object need to be located.

gluLookAt (0.0, 0.0, -(-5.0), 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

But if you use gluPerspective then it is rotated to look down the + z axis.

example for movement:

if (direction == 1) z–; // forward
if (direction == -1) z++; // backward

gluLookAt (0.0, 0.0, z, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

Originally posted by eXor:
[b]I’m a complete beginner so today I was looking at gluLookat and thinking about using the camera position as an absolute world position. I place the camera at 0,0,5 observing a triangle at 0,0,0 However this is a bit confusing because the camera is initially looking down the negative z axis and a forward move means a decreasing z value so I cheated a bit by using
-(z)

gluLookAt (0.0, 0.0, -(-5.0), 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);[/b]

[This message has been edited by nexusone (edited 01-02-2003).]

Think of the z axis as going in and out of the monitor (perpendicular on its surface). The negative side is into the monitor, the positive side is out of the monitor.

But I don’t understand your question. If you want your camera at 0,0,5 looking at 0,0,0, use: gluLookAt( 0, 0, 5, 0, 0, 0, 0, 1, 0 ) (assuming you want your up vector parallel to the positive y axis).

Oops, I misinterepreted “looking down the negative z axis” It means the opposite of what I thought it meant.

-(-5) was intentional i.e. +z=-5 make’s it easier to understand. I prefer to look at it like

z++; // forward
z–; // backward

because that is how it would look on a 2D graph of the XZ plane