• Advertisement
Sign in to follow this  

Finding the radius of an imported sphere?

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

Aside from watching the calls as you import the object is there a way to find the farthest point from the center of said object? Find the radius of an already imported object?

Share this post


Link to post
Share on other sites
Advertisement
when loading models vertices and storing them into VBO I flag the extents of the mesh to build a bounding box. You could use this to get you radius but you only need to get the max value one one axis in the case of a sphere. just loop though all vertices checking if the current ones x value is the largest (you could use y or z also)providing your sphere is centered at 0,0,0 this will give you your radius.

if its not at 0,0,0 then just get the max "x" value as above, also get the minimum value on the x-axis. subtract min from max and this will be the diameter then you can just divide by 2 to get the radius

unless the model format you export to stores such data as "radius of a sphere" I'm not aware of any other way.

Share this post


Link to post
Share on other sites
Shame. I had been hoping for a magic button to determine these things. A my_sphere.show_me_the_radius() kind of thing.

Thank you for the quick response though.

Share this post


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

  • Advertisement