-3

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)?

Community
  • 1
  • 1
Jeremy L
  • 3,770
  • 6
  • 41
  • 62
  • this is a fairly special case of the UP vector... for 5 people who said you should ask this question in the original question, there are 5 people who will say, don't add a lot of discussions -- start a new question instead – Jeremy L May 17 '12 at 14:25
  • 2
    It's not a special case; it's the *same case*. It's the exact same issue, just slightly restated, all coming back to the same point: what does the up vector mean. It has been explained to you in 6 different ways over these 3 questions, from a detailed listing of the code implementation to prose descriptions of what the up vector means. – Nicol Bolas May 17 '12 at 14:28
  • so if somebody understands 1/2 or 3/4, and not understand 1/0, you are going to shout and say: NO IT IS THE SAME CASE!! – Jeremy L May 17 '12 at 16:11
  • 2
    I'm going to *speak* (I didn't shout anything; you're the one who used CAPS LOCK) the truth: it is the same case because it is the same case. It doesn't stop being the same case just because you didn't understand it fully. That's part of why we have comments: so that you can ask for clarification on answers you don't fully understand. – Nicol Bolas May 17 '12 at 16:15

2 Answers2

1

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.

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
  • we are seeing that (1, 0.001, 0) will be tilted 90 degree, and (0, 0.0001, 1) being exactly the same as `(0, 1, 0)` so I guess it is, if the eyes are facing the sky but can roll to see the image, then it is the same as `(0, 1, 0)`, that's why for `(0, 0, 1)`, you can't see anything, maybe because the rolling is limited to less than 90 degree. – Jeremy L May 17 '12 at 14:23
-2

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.

Jeremy L
  • 3,770
  • 6
  • 41
  • 62
  • And this is a prime example of why I hate it when people "learn" OpenGL with the fixed-function pipeline. Your understanding of the problem means that you'll be completely clueless if you ever change the viewing axis, because you think that the up vector rotates around the Z axis. See, the issue has nothing to do with the XY or Z planes. The up vector does not deal with XY rotation. It deals with rotation around the *view axis*, which *in your case* just so happens to be the Z axis. – Nicol Bolas May 17 '12 at 16:12
  • so is the concept that the Up vector must have component on XY plane the same as your "rotation" around the view axis (Z axis)? – Jeremy L May 17 '12 at 16:18