gluLookAt up vector

Started by
25 comments, last by Fratt 22 years, 1 month ago
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
Advertisement
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).
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
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.
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...
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
sorry, i didn''t know that it won''t respect the space characters.

you may understand anyway.

Fratt
Nate''s opengl tutorial page

http://www.xmission.com/~nate/tutors.html
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
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

This topic is closed to new replies.

Advertisement