7

GLM provides a way to declare a projection matrix:

projectionMatrix = glm::perspective(45.0f, 4.0f / 3.0f, 0.1f, 1000.f);

From this, I want to be able to check to see if bounding boxes are in my frustum. How do I obtain the frustum planes or whatever it is I would need to calculate this from the projection matrix? Is this even the correct way to do it?

Pladnius Brooks
  • 1,068
  • 2
  • 16
  • 31

1 Answers1

8

This will help: http://crazyjoke.free.fr/doc/3D/plane%20extraction.pdf

Also notice that in order to extract the frustum you will need to extract it using model and view matrix as well otherwise you need to apply model and view transformation on the bounding boxes in order to perform the test.

genpfault
  • 47,669
  • 9
  • 68
  • 119
brano
  • 2,666
  • 15
  • 14
  • 2
    Can you elaborate on using the model and view matrix when extracting the frustum? My view matrix is my camera's frame (position, rotation) and the projection matrix. When I render my world, I just offset the vertices in the world from my camera. If I am not transforming any models from model to world space, how do I apply the model matrix or how can I apply it to the bounding boxes? – Pladnius Brooks Aug 03 '12 at 04:50
  • You could do it like this: 1. extract frustum from projection matrix. 2. Apply view transformation on bounding box. 3. Perform test (because they are in the same space). – brano Aug 03 '12 at 06:41
  • Thank you. Am I correct in thinking with the old fixed pipeline, I didn't need to do this? I never did. Just grabed the matrices with glGet and it magically worked. – Pladnius Brooks Aug 03 '12 at 06:48