Advertisement

up vector in opengl

Started by February 04, 2002 08:38 PM
2 comments, last by ed9er 23 years ago
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.
------------------------------------------------------CCP is fascistic, they even banned www.sourceforge.net
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

Ron FrazierKronos Softwarewww.kronos-software.comMiko & Molly - Taking Puzzle Games to A Whole New Dimension
Advertisement
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].
------------------------------------------------------CCP is fascistic, they even banned www.sourceforge.net
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

Ron FrazierKronos Softwarewww.kronos-software.comMiko & Molly - Taking Puzzle Games to A Whole New Dimension

This topic is closed to new replies.

Advertisement