PDA

View Full Version : Frustrum Points Coordinates

Antorian
09-01-2002, 07:58 AM
I would like to get (with a fast method) the points that limits the frustum (4 for the front near plan & 4 for the front far plan)
I just would like coordinates of these point with a few instructions.
I uses for the moment, the intersection plane from the planes got by multiplying projection & modelview matrix.
But I'm not enough good in maths to get a fast solution http://www.opengl.org/discussion_boards/ubb/frown.gif
Yes I need to learn http://www.opengl.org/discussion_boards/ubb/smile.gif
But If anyone got a simple solution....
Thanks

Alessandro_dup1
09-02-2002, 12:33 AM
take a look at www.markmorley.com (http://www.markmorley.com)

Antorian
09-02-2002, 02:15 AM
Yes it's exactly what I used, but it give only the planes for the frustrum.
I would like to know if there is a fast method (like this one) to get points (instead of planes) of the frustrum.

I think also this method gives the points in its core, but my maths aren't enough good to abstract this theory.

Thanks

davepermen
09-02-2002, 02:24 AM
wich points? you mean the 8 edgepoints?

well, search some code that intersects 3 planes and returns a point of this intersection.. do this for all 8 points with the right planes, and you're done..

or you could backproject the unitcube..

Antorian
09-02-2002, 04:53 AM
Yes thank you, but it's I used (intersection by three plane).
But I've found an easier way to do with glUnProject (using ViewPort Limits).
It works fine and it's faster than my algo using 3 plane intersection.

Thanks anyway http://www.opengl.org/discussion_boards/ubb/biggrin.gif

rlskinner
09-02-2002, 10:01 AM
The projection matrix transforms the camera space fustrum to a 2x2x2 cube centered at the origin (the clip cube). So to get the corners of the fustrum in camera space, transform the corners of the clip cube by the inverse of the projection matrix:

[ inverse Projection ] x [ -1, -1, -1 ]
[ -1, -1, +1 ]
[ -1, +1, -1 ]
[ -1, +1, +1 ]
[ +1, -1, -1 ]
[ +1, -1, +1 ]
[ +1, +1, -1 ]
[ +1, +1, +1 ]

If you want the points in world space, then transform these points by the inverse of the view matrix.

As for computing the inverses:

- Appendix G of the Red Book gives the inverse of the projection matrix, if you have the l, r, b, t, n & f values.

- You can probably find a robust matrix inversion routine with google, or search this forum. I'm sure its been mentioned before....

- All the zero's in the projection matrix make it possible to solve for the closed form of the inverse. It takes a bit of algebra, but the result is probably more accurate than a general matrix inversion.

- the view matrix is usually separable into a rotation and a translation, e.g. from gluLookat: TR, so the inverse is T'R'. finding T' is trivial. R is an orthogonal rotation matrix, so R' is just the transpose of R.