0
\$\begingroup\$

I'm making a game in XNA and I recall hearing that professionally made games use a technique to only render the polygons that appear within the cameras projection. I've been trying to find something on this to do something similar in my game, could anyone point me in the right direction? Right now all I have is a plane/grid of vertices that you can set the X/Y on which is drawn using DrawUserIndexedPrimitives, but I plan to make a bunch of props as scenery items and I can imagine myself running into issues later on if I don't address this now.

Thanks

\$\endgroup\$
0
\$\begingroup\$

Basic Frustum Culling

Frustum culling is what you are looking for and is very easy to do in XNA. Create a Bounding Frustum by passing in the view*projection matrices.

Frustum = new BoundingFrustum(view * projection);

Then create Bounding Boxes for your models. Finally you want to make sure you only draw the model's whose Bounding Boxes interact with the Bounding Frustum.

foreach (var gameobject in gameobjects) {
    currentContainmentType = Frustum.Contains(BoundingBoxe);
    if (currentContainmentType != ContainmentType.Disjoint)
    {
        //Draw gameobject
    }
}
\$\endgroup\$
  • \$\begingroup\$ Thanks, perfect. Up until now I didn't even know what it was called. :P \$\endgroup\$ – user1157885 Jun 25 '13 at 20:34
  • \$\begingroup\$ Select as the answer please if you found it to be one. @user1157885 \$\endgroup\$ – ClassicThunder Jun 25 '13 at 20:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.