Geometry.ComputeBoundingSphere Directx

Started by
1 comment, last by spiffycrony 16 years, 11 months ago
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()
Advertisement
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.
Rim van Wersch [ MDXInfo ] [ XNAInfo ] [ YouTube ] - Do yourself a favor and bookmark this excellent free online D3D/shader book!
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)

This topic is closed to new replies.

Advertisement