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

0

Share this post

Link to post

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

Link to post

Share on other sites

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!!

so, as you can see (sorry for the schema), the vector Eye->aimis 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

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

0

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...