Sign in to follow this  

DirectX bounding sphere weird results

This topic is 2174 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 made a simple box in 3Dstudio max and exported it with KW X-port plugin in .X format. Now I'm loading this mesh in my Direct3D project and calculating the bounding sphere of it like this:

[CODE]
m = Mesh.FromFile(My.Application.Info.DirectoryPath & "\Data\Models\Box.X", MeshFlags.Managed, DEV)
Using vb As VertexBuffer = m.VertexBuffer
Dim vertexData As GraphicsStream = vb.Lock(0, 0, LockFlags.None)
objectRadius = Geometry.ComputeBoundingSphere(vertexData, m.NumberVertices, m.VertexFormat, objectCenter)
vb.Unlock()
End Using
[/CODE]

Now the problem is that I'm getting some weird results as center and radius:

[CODE]
objectCenter.X : -944.5798
objectCenter.Y : 0
objectCenter.Z : 944.5798
objectRadius : 0.007336923
[/CODE]

although box's width, height and length are about 50, and box's position is 0. What could be going wrong here?

Share this post


Link to post
Share on other sites
The 3rd parameter should probably be the vertex stride, not the vertex format. I'm not sure how to get that in VB, but in C++ you'd call ID3DXBaseMesh::GetNumBytesPerVertex().

Share this post


Link to post
Share on other sites
In Managed Direct3D there are 4 options to use this function. One of them is the one that I wrote above. When I changed it to what you said, like this:
[CODE]
objectRadius = Geometry.ComputeBoundingSphere(vertexData, m.NumberVertices, m.NumberBytesPerVertex, objectCenter)
[/CODE]
everything worked great.
BUT, I found that only the meshes that are exported with KW X-port plugin from 3Ds max have this problem. PandaExporter plugin seems to work well with this but unfortunately it doesn't export tangets, so I can't use it.
Thanks for the help.

Share this post


Link to post
Share on other sites

This topic is 2174 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.

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