PDA

View Full Version : question about gluLookAt command



chen
03-26-2006, 08:11 AM
Let say i want to watch my scene from above, what should be the parameters of gluLookAt?

and if i want to watch my scene from below, what should be the parameters of gluLookAt?

Thanks in advance,

Chen

03-26-2006, 12:02 PM
Depends on what you define as "up" and "down" ;) ... that is up to you ... if, for example, the Y axis shall be "up", then you feed (0,1,0) as the up vector to gluLookAt ...
from there, positions with a positive Y will be "above", and position with a negative Y will be "below" your Y=0 plane :-)

Ehsan Kamrani
03-26-2006, 12:07 PM
To see the scene from above, you should move the camera to the positive Y position and set the Up vector parallel to the x-y plane. As an example:
gluLookAt( 0, 10, 0, 0, 0, 0, 0, 0, -1 );

To watch the scene from below, move the camera to the negative Y position:
gluLookAt( 0, -10, 0, 0, 0, 0, 0, 1 );

Note that I have set the *At* position to (0, 0, 0).
-Ehsan-

chen
03-27-2006, 01:31 AM
i tried your suggestion , but i get a blank screen.
i'm using also gluPerspective command. doses it have any influence? what sholud be it's parameters, if i use the parameters for the gluLookAt command,like you suggest

Tin Whisker
03-27-2006, 02:00 AM
Chen, LookAt controls the position and orientation of the camera, whereas Perspective controls the projection of the scene from camera space into clip space.

Might I suggest giving the chapter on viewing in the programming guide (http://www.rush3d.com/reference/opengl-redbook-1.1/chapter03.html) a good read? All this and much more is covered in great detail.