Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 0 down vote accepted

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
    }
}
share|improve this answer
    
Thanks, perfect. Up until now I didn't even know what it was called. :P –  user1157885 Jun 25 '13 at 20:34
    
Select as the answer please if you found it to be one. @user1157885 –  ClassicThunder Jun 25 '13 at 20:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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