Anybody know what this does?

Started by
2 comments, last by executor_2k2 22 years, 2 months ago
gluLookAt( 0.0, 1.0, 1.0, // camera''s position 0.0, 1.0, 0.0, // camera''s line of sight 0.0, 1.0, 0.0); // camera''s up direction This code segment is from a program that has a stationary camera and snow just falls down in front of it. I just dont understand it. Shouldnt the center(line of sight) parameters be pointing down the negative z axis? What''s the point of hae the center and up parameters the same? And because the camera is stationary wouldnt you want the camera at the origin. I think it should be gluLookAt(0.0, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0, 1.0, 0.0). What am I missing?
Well, that was a waste of 2 minutes of my life. Now I have to code faster to get 'em back...
Advertisement
You usually move the camera away from the origin because that's were the 'objects' are created if you don't translate them.

Thus, without adding any extra translations, you are looking at the interesting location.

The second line parameters aren't the camera's line of sight, but the camera's centerpoint. That is what point are you looking at.

Here, you are in (0, 1, 1) looking at (0, 1, 0), that is a view vector of (0, 0, -1 ), or -Z.

And your up vector is ( 0, 1, 0 ), or +Y.

-Z != +Y, Q.E.D.

Edited by - Fruny on January 29, 2002 2:57:40 AM
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
How do you go from the point your looking at(0,1,0) to the view vector(0,0,-1)?

Wait...nevermind. I got it. You have to take the resultant of where your standing to the vector your looking at.

Edited by - executor_2k2 on January 29, 2002 3:02:57 AM
Well, that was a waste of 2 minutes of my life. Now I have to code faster to get 'em back...
gluLookAt(
0.0, 1.0, 1.0, // camera''s position
0.0, 1.0, 0.0, // camera''s line of sight
0.0, 1.0, 0.0); // camera''s up direction

your understanding is wrong instaed of // camera''s line of sight this is position where the camera is looking to (thus u can be standing somwhere + also looking there as well, picture it)

>>I think it should be gluLookAt(0.0, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0, 1.0, 0.0).

this is correct but ''What''s the point of hae the center and up parameters the same?'' can easy happen eg lookat(0,1,2,0,1,0,0,1,0)
which is practically the same as gluLookAt(0.0, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0, 1.0, 0.0)

This topic is closed to new replies.

Advertisement