Bounding Sphere Too Big

Started by
12 comments, last by SDyer 20 years, 5 months ago
I did try making my own spheres, based on the bounding box. They were a bit small, though, as I was using half the distance between the min/max points as the radius.

Aikon - I will try your method of getting the center, then determining the radius by scanning all vertices in the mesh. That ought to do it.

I''d still like to know, if anyone knows, why the DirectX function is not working as expected.
Advertisement
I''ve had a similar problem to the one you describe where vastly larger bounding spheres were being created. I was also getting a problem with bounding boxes. After checking the .x file in txt format I found the values for the bb min to actually be a tex coordinate (I know this because it was the only -25.0 val in the file).

This made me suspicious of the FVF descriptor generated so I changed the FVF size to what I thought it should be in the CreateBoundingSphere call, and this seems to have fixed the problem altogether.

I don''t know if it''s the same as your problem, but it could be worth investigating.
For very tight encompassing spheres, I''d have a look at this code of the day on Flipcode:

http://www.flipcode.com/cgi-bin/msg.cgi?showThread=COTD-SmallestEnclosingSpheres&forum=cotd&id=-1

This is generally a very robust (and quick) way to find the smallest encompassing bounding sphere of any arbitrary mesh.
D3DXComputeBoundingSphere computes the center of the sphere as some sort of average of all vertices in the mesh. Therefore, if one side of the mesh has a high density of vertices, the center will be weighed towards that side.

D3DXComputeBoundingSphere works better for meshes whose vertices are more evenly distributed. If the vertex distribution is not even, you might consider using D3DXComputeBoundingBox to find the center, then compute the radius yourself using that center.

This topic is closed to new replies.

Advertisement