Archived

This topic is now archived and is closed to further replies.

gluLookAt up vector

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

Recommended Posts

hello, how to store correctly the 3 last parameters of gluLookAt function ? I never succeed doing something good. But that''s may be a geometrical problem ! i explain: consider thses position as vectors (x,y,z coordinates). i have a camera which have a pos (cam_pos) i have a car which have a pos (car_pos) this car moves on a terrain and the camera follow this car but is not at the same height than the car (it''s more heigher). So my up vector is not always 0,1,0 ! how to calculate it correctly please ! Fratt

Share on other sites
I believe the up vector is a unit vector, meaning it has a magnitude of 1. It''s used to find the angle of rotation for the vector you give it, and doesn''t have anything to do with the height. You should be able to just leave it as (0, 1, 0).

Share on other sites
no, strtok !
you''re wrond, and i''m sure.
the up vector is needed for opengl to draw a correct perspective:

let''s try something like that:
gluLookAt( 40,100,-20, 0,0,0, 0,1,0);
and look at your world: see all your scene is disturbed !

cordially,

Fratt

Share on other sites
I may have lost what you were trying to do,

But basically if the car follows the terrain, ie as the terrain goes up or down, the car sits parrallel to the polygon it sits on, then you would be able to get the correct up vector from the polygon it is sitting on''s normal (which can be calculated by taking a CrossProduct of the 3 vertexes of the polygon!!

This would then generate an up vector that is perpendicular to the landscape!!

Paul P.

Share on other sites
Nate Robins has a nice set of tutorials on this which lets you play around with the values of each function parameter and you can see it in real time....

Ill try to find the link and post it...

Share on other sites
sorry, if you find this question more mathematic than opengl,
i have posted too in math & physic, but best answers here.

yes PaulPrice,

but, the camera (in fact gluLookAt) isn''t on a parallel plan to the ground (not always).
its plan is around the vector defined by the eye and the aim of the gluLookAt

y|
| * top <- the up vector defined by these points
| /
| /
| /
| *Eye
|
| *aim
|
î|______________________________<- assume the ground plane
O j x/z

so, as you can see (sorry for the schema), the vector Eye->aim
is not parallel to the plan.
more, in space, i have the ground plan and this vector: and i lack doing an orthogonal vector to Eye->aim in up vector:
Eye->top

thanks for any help ! a lot

Fratt

Share on other sites
sorry, i didn''t know that it won''t respect the space characters.

you may understand anyway.

Fratt

Share on other sites
Do you refer to the perspective demo ? i download all the demos and i ''ll test it this evening.
i don''t think this will help me. the perspective demo, let you change the param values of gluPerspective or gluLookAt but not adapte automatically the parameters if you move the view, and i want to move the view and not the scene.

thankx anyway, the demos seem good and touch some interressant parts of opengl.

Fratt

Share on other sites
The up vector for gluLookAt acts like rotating the camera left/right on the z axis... Eventually if you rotate it enough, it will make everything look like it is upside down... At least that how I understand it...

Edited by - ANSI2000 on February 20, 2002 12:08:56 PM

1. 1
2. 2
Rutin
24
3. 3
4. 4
JoeJ
19
5. 5

• 14
• 26
• 11
• 11
• 9
• Forum Statistics

• Total Topics
631771
• Total Posts
3002253
×