Frustum from matrix

In the last section, we created a Frustum primitive. We know that a frustum is made up of six planes: near, far, top, bottom, left, and right. In this section, we will explore how to extract those six planes from a view-projection matrix.

Getting ready

We are going to add a new method to the Camera class. This new method will create a frustum from the camera. In order for the Camera class to know what a Frustum is, we need to include Geometry3D.h in Camera.h.

How to do it…

Follow these steps to build a frustum out of the camera's view and projection matrices:

  1. Add the public GetFrustum function to the Camera class in Camera.h:
    class Camera { // Existing class implementation not listed // The GetFrusutm function is new Frustum GetFrustum(); ...

Get Game Physics Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.