Obtaining the frustum clipping planes

For the purposes of lopping chunks out of my BSP tree:

how do I obtain the 6 plane equations of the current viewing volume (ie. the frustum)?

Having set the frustum up using gluPerspective and subsequently translated and rotated it somewhere to look at a bit of world it would be nice to be able to clip it efficiently

TVM in advance - I’m sure this one’s blindingly obvious…

If you have 90 degrees fov, you have the planes rotated about 45 degrees plus or minus. Since they go through the zero-point (?), you only have to know the normal. That is to rotate the vector of the plane about 45 degrees in the direction depending on the plane you mean.

Take a look at this: http://www.markmorley.com/opengl/frustumculling.html

A very nice frustum culling tutorial. It tells you, among other usefull stuff, how to obtain the six clipping planes.

But as Michael said, I also thought the four “side-planes” went through the origin, and therefore had a D-component of zero. However, in these equations, I always get non-zero values for D. I’m a little but suspicious about the correctness. But what boggels me is that whatever culling I try to do, it always gives me the correct results. So after all, it seems like they indeed are correct.

also take a look at Paul Martz’s FAQ, there is a sample app doing this

-Lev

Originally posted by Bob:
I also thought the four “side-planes” went through the origin, and therefore had a D-component of zero. However, in these equations, I always get non-zero values for D. I’m a little but suspicious about the correctness. But what boggels me is that whatever culling I try to do, it always gives me the correct results. So after all, it seems like they indeed are correct.

No, the clipping planes dont necessarily run through the origin. They run through the viewpoint. If you translate all world geometry by (-viewpoint.X, -viewpoint.Y, -viewpoint.Z), THEN the clipping planes will all (except near and far planes) go through the origin (but this is wasteful and slow).

[This message has been edited by LordKronos (edited 01-14-2001).]

Thanks for everything! As usual a brilliant response.

That MarkMorley site is excellent.

Cas

>>No, the clipping planes dont necessarily run through the origin. They run through the viewpoint.

DOH! Stupid me

Yes, in eyespace, D is always zero (for the four side-planes I mean), but we need to transform them to be able to clip in worldspace. Thanks for pointing that out. Probably whould have done it myself sometime, but only god know when… hehe.