Thanks in advance for any help -
What is the best way to get the coordinates of each corner of the view frustum? I would like to get the projection of the view frustum onto the xz plane after the projection and camera transformations have been applied.
Thanks again for any hints or tips
The best source of info I have found so far is at: http://www.markmorley.com/opengl/frustumculling.html
But still I am unclear - How can I extract the corners of the frustum from the combined Projection/View Matrix? The tutorial extracts plane definitions of the Normal vector / distance from origin format. I am looking for only the projection of the view frustum onto the xz plane.
Thanks again for any help
For what purpose do you require these coords?
Are you trying to draw a representation of the Frustum onto an ortho viewport? (ie. Drawing the “Camera Cone”)
If so you can easily work out the Frustum as a set of vertices and then use GL transformations when you draw it…
When using gluPerspective you have…
so for the near plane
p1.z = p2.z = p3.z = p4.z = near;
p1.x = p2.x = -near * tan(0.5f * fovy * aspect);
p3.x = p4.x = -p1.x;
p1.y = p3.y = near * tan(0.5f * fovy);
p2.y = p4.y = -p1.y
For the far plane you do the same with far instead of near in you equations.
And from there you can (a) multiply the verts by your modelview matrix or (b) use gl transforms etc to draw your shape in an Ortho/Persp view…
I want to do view frustum culling for some heightmap terrain tiles. Rather than store and test a bounding box, I want to just test a bounding square against the quadrilateral formed by projecting the frustum onto the xz plane. Perhaps I can just send each vertex of the frustum throught the view matrix. I was using gluPerspective rather than glFrustum. I’m going to swith and try that…
Thanks again for any help…