To view or not to view…

In this post we’ll be introducing Frustum culling. We’ll be adding to the Actor class so we can determine which models are currently in the view frustum and only render those. To do this, we’ll add a BoundingSphere property to the Actor class:

public BoundingSphere BoundingSphere
    get { return new BoundingSphere(Position, model.Meshes[0].BoundingSphere.Radius); }

With this in place, all we need to do is make a slight amendment to the SceneManager class. In the Draw method, alter the foreach statement to the following:

foreach (Actor actor in models.Where(a => a.BoundingSphere.Intersects(

If you don’t get a Where method in the Intellisense, add the following namespace:

using System.Linq;

The new foreach statement will check all models to see if they intersect with the current view frustum and only return those models that are in view.