Jump to content
  • Advertisement
Sign in to follow this  
Anddos

calculate bounding sphere of an .obj 3d model?

This topic is 1428 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

i am just wondering how would i calculate the bounding sphere for an obj model, i have parsed vertices,index data to a vector etc, i need to use spheres around the models for view frusrum culling in increase rendering performance, thanks

Share this post


Link to post
Share on other sites
Advertisement

You might want to start with this Gamedev article.

 

There are several approaches. Perhaps the best is an optimal sphere as discussed in that link. It's an involved algorithm that I'll let the article describe. But the idea is to calculate the smallest sphere that contains all the points.

 

A very simple approach is to calculate the average of all vertices, use that average position as the sphere center, calculate the distance from that center to each vertex and use the maximum distance found as the radius. EDIT: this approach can be relatively fast if you calculate distance-squared from the center to each vertex, and apply sqrt just once to calc the radius. The downside of this algorithm is: if there are many vertices grouped in one area, the center will be influenced by that, and the radius just has to grow to include the outlying points. If the mesh is fairly "regular," the result approaches optimal.

 

Another approach is to determine an axis aligned bounding box for the mesh vertices and calculate the sphere that contains that box. EDIT: this is fast, but is almost guaranteed to produce a larger sphere than other approaches.

 

There's no "best" answer as it depends on the shape of the mesh, whether the algorithm needs to be fast, etc.

Edited by Buckeye

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!