Public Group

# gluLookAt() - wats the point?

This topic is 3967 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello, Ive just found this function, gluLookAt, though I dont fully understand how to use it. Firsty, wats the point in having an 'up' vector? Would you not just change reference point where you were looking to be shifted up or down? Why can the up vector not be parallel with the line of sight created? Say I wanted to look straight ahead (from the origin). We would pass the following parameters to the function: gluLookAt(0, 0, 0, 0, 0, -1, 0, 0, -1); Though this causes the up vector to be parallel with the line of sight. How can we look straight ahead using this function? So yeah, any explanation on the point in this 'up' vector and how to use this function properly would help. Mash

##### Share on other sites
Quote:
 Original post by DjMaShFirsty, wats the point in having an 'up' vector? Would you not just change reference point where you were looking to be shifted up or down?
A position and target is not enough information to uniquely determine an orientation for the camera (the camera can roll freely about its forward axis while still looking at the target, so there is an infinite number of orientations that satisfy these requirements). The 'up' vector provides an extra bit of information that allows the orientation to be uniquely determined.
Quote:
 Why can the up vector not be parallel with the line of sight created?
The 'look at' algorithm computes the side vector (and, indirectly, the 'actual' up vector) by taking the cross product of the reference up vector and the line-of-sight vector. If these two vectors are parallel or nearly parallel, the cross product yeilds the zero vector (or nearly so), and the algorithm fails.
Quote:
 Say I wanted to look straight ahead (from the origin). We would pass the following parameters to the function:gluLookAt(0, 0, 0, 0, 0, -1, 0, 0, -1);Though this causes the up vector to be parallel with the line of sight. How can we look straight ahead using this function?
Just submit (e.g.) the positive y axis for the reference up vector:
gluLookAt(0, 0, 0, 0, 0, -1, 0, 1, 0);
Does that help?

##### Share on other sites
The up vector is used to tilt the camera to the side. It is the direction the top of the camera should face. If you want the image to be upside-down, you make the up vector point down. If you want the image to be sideways, you make the up vector point to the side. If you want the image to be right-side-up, you make the up vector point up.

##### Share on other sites
AHHH! Of course, I forget that cameras can roll. Im making a snowboarding game so this doesn't happen, but in a plane or something it would. Wiked, that makes sense
for the up vector being there now.

Quote:
 Just submit (e.g.) the positive y axis for the reference up vector:gluLookAt(0, 0, 0, 0, 0, -1, 0, 1, 0);Does that help?

Right, so the up vector determines the orientation. I was thinking that providing an up vector of {0, 1, 0} would lift the camera's angle up by 1 in the y axis. Excellent, this all makes sense now.

Thanx!!!

1. 1
2. 2
3. 3
4. 4
Rutin
17
5. 5

• 11
• 31
• 12
• 12
• 11
• ### Forum Statistics

• Total Topics
631409
• Total Posts
2999926
×