1

I understand that in OpenGL, we use the gluLookAt to place the camera relative to the world and thus define the image that would be drawn.

The "eye" specifies the position of the camera and the "center" specifies the point the camera is pointing towards. Once we know these two, we can draw a straight line from the eye to the center. The camera plane would be normal to this line.

Since we know this plane, the up vector specifies the top of the camera - basically which direction in this plane is upwards. Thus the up vector is always orthogonal to the vector joining the center and the eye.

My question is why do we need the full vector, when we just want to know the angle of rotation about the line joining "center" and "eye". Is the reason behind this a computational advantage that I am not aware of? And what if someone specifies a wrong up vector, which is not orthogonal to the direction of sight?

nutsiepully
  • 1,066
  • 3
  • 14
  • 21
  • 1
    I suggest you read this http://gamedev.stackexchange.com/questions/65783/what-is-world-space-and-eye-space-in-game-development/65785#65785 – concept3d Feb 24 '14 at 15:00
  • 1
    Angle with respect to what? Without the `eye` vector, you only actually have one axis of your 3D vector space in your call to `gluLookAt (...)` (the Z-axis), and even that is not ***directly*** passed to the function, but rather computed from the origin and center position. So I say again, what exactly is this angle supposed to be relative to? If it is relative to the Z-axis, then there are an infinite number of possible `up` vectors that would satisfy your angle and that simply is not useful. – Andon M. Coleman Feb 24 '14 at 20:27

1 Answers1

1

The up vector you pass in is used to indicate the up direction, but this is used with a cross product. I think the purpose of gluLookAt is to simplify the calculations needed by the user, so for example you would just pass (0,1,0) to indicate that the up direction you desire is along the positive Y-axis.

If you want better efficiency you could avoid gluLookAt entirely

thisisdog
  • 908
  • 1
  • 5
  • 13
  • I agree that it is used to simplify the calculations, but then it could just that 1 angle instead of requiring the entire vector. This question shows the cross product (http://stackoverflow.com/questions/10635947/what-exactly-is-the-up-vector-in-opengls-lookat-function) which crosses the normal with the up vector, and then crosses it again with the normal. That seems redundant. I don't understand why? – nutsiepully Feb 24 '14 at 06:11
  • The original up vector is not meant to be orthogonal to the view direction - it simply determines the general direction that is up, for example the y axis. If you cross the orthogonal up vector with the view, or the approximate up vector with the view, you'll get the same side vector. Since gluLookAt doesn't expect the orthogonal up vector it crosses the side vector with the view to get the orthogonal up vector. If you used an angle which axis would you be rotating against? The view direction? This would require you to adjust the angle based on the view direction – thisisdog Feb 24 '14 at 06:17