Jump to content
  • Advertisement
Sign in to follow this  
Gluc0se

OpenGL Problems Extracting Frustum Planes in OpenGL [Solved]

This topic is 4354 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So I'm having some problems extracting the frustum planes in OpenGL. I've found many references as to how to do this, such as these two links Extraction of Frustum Planes - RavenSoft Extraction of Frustum Planes - LightHouse3D So for the life of me, and please point out what I'm doing wrong, I can't get these equations to actually come up with the correct answer. Heres an example of a projection matrix in question. First, lets work in viewspace, so the modelview is the identity. And now lets use the gluPerspective(..) function to set up a frustum. A simple frustum is constructed with the call gluPerspective(90.0f, 1.0f, 1.0f, 10.0f) -- which means a square-shaped near plane at 1.0f, a far plane at 10.0f, and the right,left,bottom,top are all 1 unit away from the -z axis. The resulting OpenGL projection matrix from this call is 1.000 0.000 0.000 0.000 0.000 1.000 0.000 0.000 0.000 0.000 -1.222 -0.222 0.000 0.000 -1.000 0.000 Now lets just determine the 'left' plane equation of the frustum, using the equation given from the two links provided. They use the Ax + By + Cz + D plane equation, and the values are thus. A = m[0] + m[3]; // 1 + 0 = 1 B = m[4] + m[7]; // 0 + 0 = 0 C = m[8] + m[11]; // 0 + -0.222 = -0.222 D = m[12]+ m[15]; // 0 + 0 = 0 So heres my immediate problem with this. The vector (1.0, 0.0, -0.222) will not represent the correct normal for the left plane. Given that I've constructed a 90 degree frustum, the normal of the plane should be (1.0, 0.0, -1.0)(unnormalized) - but it is not. So my question is, am I using the correct projection matrix to begin with? Should it not be straight from OpenGL? [Edited by - Gluc0se on August 18, 2006 5:27:18 PM]

Share this post


Link to post
Share on other sites
Advertisement
Double-check element 11; the matrix itself is right but you're using the wrong value in your manual computations.

Share this post


Link to post
Share on other sites
It appears to me that I have a tranposing problem, since it seems to work out ok if I transpose the matrix. Though that printed matrix is already the tranpose of what is returned from OpenGL, meh I'm sure I just wasn't paying attention to the matrix ordering. Thanks for the help

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!