View Full Version : perspective projection in opengl
I'm now teaching myself opengl and encounter
some problems.I want to ask how can I recognize view plane and center projection point when calling functions like glFrustum? thanks.
01-10-2004, 04:35 PM
I think you misunderstand a few concepts.
Forward is the eyespace z axis. This is ALWAYS forward, and the plane is always at orthogonal to this, the view plane is never tilted (or needn't be).
You use the modelview matrix to position and orient the eye in the world.
The projection matrix is where you define the frustum. The plane of the frustum is always orthogonal to the eye z vector. So to offset the plane you need to manipulate the modelview. When calling frustum you define a window on a near plane, that window can be in any location, ever one where the z axis running from the eye is not visible.
The confusion generally arises when people start to try to implement off axis or asymmetric projection by orienting the projection plane on the projection matrix stack. They miss the point.
For an off axis projection, with an apparently tilted plane you must project the eyepoint onto the near plane at right angles to the plane, (typically the display plane), to find the forward vector even if it's not on the screen. Then using this as the origin you define the frustum window on the plane.
This always works and is completely unambiguous. Doing it this way means viewing software must multiply the offset vector on the modelview matrix before applying the viewing orientation to orient the eye at the screen plane.
The only issue then becomes z linear fog, but that may or may not be an issue for you.
Try to visualize this, it's much simpler than it sounds.
[This message has been edited by dorbie (edited 01-10-2004).]
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.