Possible Duplicate:
What exactly is the UP vector in OpenGL's LookAt function?

This is related to: What exactly is the UP vector in OpenGL's LookAt function?

If the call is:

      gluLookAt(512, 384, 2000,
                512, 384, 0,
                0.0f, 1.0f, 0.0f);

If I am sitting on a chair looking straight ahead, holding an iPad right in front of my eyes, then my top of my head is pointing up the sky. Therefore the (0, 1, 0) for the UP vector, as on the 3rd row. How about if I change it to (0, 0.00001, 1)? That means I am almost lying down, with now my face and eyes facing the sky. So how come the result is exactly the same as when I use (0, 1, 0)?

2

There are 2 answers

2
Jeremy L On

After more trial and error, as I just started learning OpenGL for one day, is that, the Up vector must have some components in the plane that is "normal" (or perpendicular) to the camera to target vector.

In other words, in the example, it is from (512, 384, 2000) to (512, 384, 0), so the vector is only in the Z-direction. The Up vector must have some components on the XY plane (XY plane is the one that is perpendicular to the vector that has only the Z direction).

If there is no x and no y component, that is, if they are both 0, then on my iPad 2, the image is not displayed at all. So the Up vector deals with rotation in the XY plane in this case, and not case about the Z direction at all.

1
Nicol Bolas On

What could you possibly expect to happen?

You pass 3 sets of values: a camera position, a position for the camera to look at, and the direction of up. In your analogy, if you're looking up at the sky, you're not looking at your iPad. Therefore, your look-at position must have changed along with your up direction. And if you didn't change your look-at position, then what do you expect to happen when you change the up direction?

The up direction only affects where up is relative to where you're looking. If you want to change what you're looking at, you must actually change the look-at point. That's why it's there.