Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


DirectX bounding sphere weird results


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Zosimas   Members   -  Reputation: 122

Like
0Likes
Like

Posted 03 February 2012 - 06:52 AM

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:

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

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

objectCenter.X : -944.5798
objectCenter.Y : 0
objectCenter.Z : 944.5798
objectRadius : 0.007336923

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

Sponsor:

#2 Evil Steve   Members   -  Reputation: 1983

Like
1Likes
Like

Posted 03 February 2012 - 07:44 AM

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().

Steve Macpherson
Systems Programmer

Rockstar North


#3 Zosimas   Members   -  Reputation: 122

Like
0Likes
Like

Posted 03 February 2012 - 07:58 AM

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:
objectRadius = Geometry.ComputeBoundingSphere(vertexData, m.NumberVertices, m.NumberBytesPerVertex, objectCenter)
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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS