Jump to content
  • Advertisement
Sign in to follow this  
REspawn

[.net] Looping through objects checking against view frustum

This topic is 4218 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, Im working on speeding up my render time and I was wondering if anyone can tell me a better way of looping through all the objects in my scene. I have to loop through them and check there position and bounding sphere size to see if they are inside the view frustum, they are stored in an ordinary array. So should i use another type of list to store them? thanks for any help, -Dave

Share this post


Link to post
Share on other sites
Advertisement
The way that I like to do it is to have a grid of some sort. So make your map into a 100x100 grid or so. Depending on what the frustum is set to depends on how many grid cells you check out from the players location. So say we have a small frustum then you would including the object that are in the grid the player is in and the grids directly around the player's grid. You can include the next grid out as the frustum increases.

The grid is really just a reference or pointer to the array holding the objects in that grid. You then go through each of the grid arrays to see if the object is visible or not.

You really reduce the number of ojbects you have to check and will greatly speed things up.

theTroll

Share this post


Link to post
Share on other sites
A bounding volume hierarchy is probably you best bet. You can bound your entire scene in a large sphere (or aabb), then select a dividing plane (1/2 way along longest axis maybe) and split the objects into two groups along that plane. Bound each of these groups in another sphere.
Recursively do this to each branch until you reach less than a threshold number of objects in each group.
You can quickly check a sphere against the six planes of a viewing frustum and if a sphere falls completely outside it, then you don't need to check any of the objects contained within it.
This is a standard way of doing culling, but gets difficult with dynamic scenes.
If you want more help you should post in the Graphics algorithms forum.

Share this post


Link to post
Share on other sites
Depending on the amount of objects and how dynamic they are(much they move around) you could consider them storing them in an Octtree (look it up)

Then simply match the Octtree to the frustum.

Share this post


Link to post
Share on other sites
Quote:
Original post by ernow
Depending on the amount of objects and how dynamic they are(much they move around) you could consider them storing them in an Octtree (look it up)

Then simply match the Octtree to the frustum.


well, it's "Octree", but yeah. That will be a good start for you. It's a pretty simple concept.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!