View Full Version : Arbitrarily positioned view planes
05-12-2001, 02:15 PM
For my program, I wish to have the viewer positioned at a point, and the view plane completely arbitrarily positioned in front of the viewer - i.e. the vector from the viewer to the point on the plane that would be mapped to the centre of a window is not necessarily perpendicular to the plane, and the effective shape of the window in world space is not necessarily rectangular.
The information I have is the location of the viewer and four vertices making up the corners of what should be mapped to the frame buffer. Can anyone help with how I should instruct OpenGL of this information? Presumably I'll want to adjust both perspective and modelview matrices?
05-13-2001, 04:05 AM
Have you got the red book? I always use glFrustum(left, right, bottom, top, zNear, zFar); to set up my viewing volume. I normally have symmetrical viewing volumes, but you don't have to. If that doesn't do what you want, from Appendix F or the red book, the matrix that glFrustum(l, r, b, t, n, f) generates looks like this:
m = 2n/(r-l);
m = 2n/(t-b);
m = (r+l)/(r-l);
m = (t+b)/(t-b);
m = -(f+n)/(f-n);
m = -1;
m = -2fn/(f-n);
All the rest are 0's. Note that the matrix is in OpenGL column-major format. If you can be bothered deciphering the matrix, you can probably change it to suit your purposes. That's then set up as the GL_PROJECTION_MATRIX.
05-15-2001, 10:39 AM
Okay, but that still assumes that the rectangular view window is being mapped onto a rectangular shape in the 3d world, whereas I have an arbitrary planar quadrilatteral.
E.g. imagine if you drew a quad non straight on, then used the shape projected by that onto a normal view shape as the new view shape - i.e. you could achieve the same effect by drawing the scene, using the framebuffer to texture copy command, then mapping the texture to a single perpendicular polygon which doesn't have the (clockwise) texture co-ordinates set to (0, 0), (1, 0), (1, 1), (0,1). Which is a solution to my problem, but a really awful one.
yep, yep. I know what you want to do, and I think I know why. <nods wisely> =)
er, I don't know how to do it off the top of my head, *BUT* the Multiple-Pipe-Utility library uses this trick, too. Find it; download the source.
Ack, i lie; it's changed it's name. http://www.sgi.com/software/multipipe/sdk/ should be it.
(for the uninitiated: I think the poster wants to project onto a plane not orthogonal to the optical axis for use in head-tracked VR stuff. If you think about someone'e head wavering in front of a monitor or wall, then the optical centre is the user's eyes, but the near plane maps to the screen....)
hope this helps,
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.