Archived

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

up vector in opengl

This topic is 5825 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

some computer gfx book once said, the upview-vector(V) need not to be perpendicular with the lookat-vector (N: the view-plane normal):
quote:
it can be difficult (or at least time consuming) to determine the direction for V that is precisely perpendicular to N. Therefore, viewing procedures typically adjust the user-defined orientation of vector V, so that V is projected into a plane that is perpendicular to the normal vector. We can choose the view-up vector V to be in any convenient direction, as long as it is not parallel to N.
i''m not sure whether opengl conform to this convention. that is, if i just do yaw/pitch rotation between reasonable angle like most FPS game did, without roll, can i always assign [0, 1, 0] to upvector? thx in advanced.

Share this post


Link to post
Share on other sites
If you are talking about using gluLookAt and if you can always guarantee that [0,1,0] is going to be pointing even slightly up, then yes, you can just use that.

The 3 things you need to make sure of are that:
1) camera can never point straight up [0,1,0]
2) camera can never point straight down [0,-1,0]
3) camera can never roll 90 or more to either side

Since you said you will only do yaw & pitch, 3 isnt an issue. To deal with 1 & 2, just make sure
-90 degrees < yaw < 90 degrees
If yaw gets very close to +/- 90 degrees (ex: 89.999 degrees), then you might start seeing problems from rounding error. It would probably be safests to just limit yaw to +/- 89.0 degrees

Share this post


Link to post
Share on other sites
thanks for your reply! very clear

but maybe you''ve made a little mistake: if the camera roll around Z-axis, in spite of if it is bigger than 90 degree, the up-vector must be changed according to the roll angle. that is, no more [0, 1, 0].

Share this post


Link to post
Share on other sites
quote:
Original post by ed9er
but maybe you''ve made a little mistake: if the camera roll around Z-axis, in spite of if it is bigger than 90 degree, the up-vector must be changed according to the roll angle. that is, no more [0, 1, 0].


I''m sorry, yes you are right. For some reason I was thinking of something else when I said this. I should have said

3) camera can never roll

Share this post


Link to post
Share on other sites