View Full Version : Problems understanding glFrustum()
11-07-2008, 06:02 AM
I have a set my matrix -10.0, 10.0, -10.0, 10.0 and I am trying to provide clipping around this matrix so anything that goes outside the matrix is taken out.
I am trying to achieve this through the Frustrum method.However, I am struggling to understand how it works by reading the red book manual. I know it takes the (left, right, bottom, top, near and far)
Can someone please explain in a simple terms how it works please with an example if possible.
11-07-2008, 07:56 AM
Please help :(
11-07-2008, 09:10 AM
Your question is interesting because I want to compute the "viewing volume" given by glFrustum (http://www.opengl.org/sdk/docs/man/xhtml/glFrustum.xml), that is the equations of the 6 clipping planes and I am learning on that right now. There exist a web page (http://www.lighthouse3d.com/opengl/viewfrustum/) that explain it for gluPerspective (http://www.opengl.org/sdk/docs/man/xhtml/gluPerspective.xml). Notice that the matrix generated by gluPerspective is similar to the matrix generated by glFrustum. Maybe there exist a post on this forum on that subject already. But for now I will try first to derive the clipping plane myself with the help of OpenGL SDK reference (http://www.opengl.org/sdk/docs/man/) pages.
11-07-2008, 09:20 AM
I take it you're talking of frustum culling? Google it up, there's plenty of tutorials out there. Basically you compute the plane equations for at least the 4 "side" planes (also for the far plane, if it makes sense; the near plane is usually close enough not to make any difference, and one less plane to check is less computational load).
Plane equations are essentially vectors comprised of a 3-element unit-length normal vector and a scalar that equals the distance of the plane from the origin of the coordinate system (the [0, 0, 0] point). Mind you that distances can be negative for some orientations of planes. The idea is that if you multiply the normal by the distance, you get a point that lies on the plane.
Once you have the plane equations, you can perform sphere- or bounding-box checks against them. Basically, you test for a point being in front or behind a plane (positive or negative dot product with the plane normal minus plane distance). If all points of a bounding box lie behind a plane, they're out of the viewing frustum.
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.