Jump to content
  • Advertisement

Archived

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

Fratt

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
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).

Share this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


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

you may understand anyway.

Fratt

Share this post


Link to post
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 this post


Link to post
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!