Sign in to follow this  
spiffycrony

Geometry.ComputeBoundingSphere Directx

Recommended Posts

spiffycrony    122
I am trying to compute the object radius & centre using Geometry.ComputeBoundingSphere for a mesh object. This works fine for a small mesh say few hundreds of triangles. But for a larger say few thousands of triangles the objectRadius returned is 0 & objectcenter is NAN(not a number). Any clue of why this is happening? Dim vb As VertexBuffer = mesh_.VertexBuffer Dim vertexData As GraphicsStream = vb.Lock(0, 0, LockFlags.NoSystemLock) objectRadius = Geometry.ComputeBoundingSphere(vertexData, mesh_.NumberVertices, mesh_.VertexFormat, objectCenter) vb.Unlock() vb.Dispose()

Share this post


Link to post
Share on other sites
remigius    1172
Going from this, your thread on cloning and your thread on loading meshes, I'd say there's something horribly wrong with the STL file you converted to .X [smile] If you have the file around in a modelling app, you might want to check the scale in the modelling app to see if the coordinates aren't plain huge. If so, scale it down a good amount, so the largest vertex coordinate fits comfortably into a float datatype.

Share this post


Link to post
Share on other sites
spiffycrony    122
Thanks remigius.

When I scaled the model by say 10 then the Geometry.ComputeBoundingSphere and also the mesh.clone works fine.

The minxyz - -260.49, -83.99997, -70.0 and
maxxyz - 222.11, 84.00003, 70.0
which are all small enough to fit into a float data type. So I dont think it can cause an overflow. But still I couldnt find the reason as to why without scaling it causes problem in Geometry.ComputeBoundingSphere and mesh.clone(where some vertex coordinates are QNAN)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this