Brandon Bloom

I exported a model from 3ds max, but I can't get the bounding volumes to line up with the model.

XNA 3D Tutorial 1 shows using the mesh.ParentBone.Transform property as the world matrix. When I do this, the model is accurately oriented, but it's scale is more than double it's original scale. The model is larger than the radius of mesh.BoundingVolume indiciates.

I tried to render with an identity world matrix and the model is the correct scale! Unfortunately, it's coordinate system is like Max's with the XY plane lying flat and the Z axis running up and down.

I may be missing something totally obvious (it is 4am) but why is the bone's Transform scaling

Thanks!



Re: XNA Framework mesh.BoundingSphere and mesh.ParentBone.Transform -- Scale?

Shawn Hargreaves - MSFT

The transform will include whatever data was provided by the tool that created the mesh: this could easily include scaling, translation, and rotations, depending on how the object was created.

I'm not an expert Max user, but there is probably a function you can use to bake the transforms into the actual vertex positions. Alternatively this would be easy to do in a custom content pipeline processor: I'll add that to my list of things to blog about!

The bounding spheres are stored in the local coordinate space of the object, so they also need to be transformed by the bone matrix. That's easy if the matrix just does translation and rotation (simply translate the bounding sphere center point by the matrix, as rotation has no effect on a sphere), but gets trickier if there is scaling involved as well.





Re: XNA Framework mesh.BoundingSphere and mesh.ParentBone.Transform -- Scale?

Brandon Bloom

I sort of suspected this, but the 3ds max exporter was set to have a scale factor of 1.0 and 1 in = 1in.

Since it's not 4am, my brain is working far better: I checked mesh.ParentBone.Transform.M11 and it is 2.54... that number seemed very familiar... That's the number of centemeters in an inch! I can probably reconfigure the exporter correctly.

Since the scaling is kind of tricky, could there be a helper method Maybe mesh.GetTransformedBoundingSphere()

By the way: I sent documentation feedback, the BoundingSphere property should mention the coordinate system.





Re: XNA Framework mesh.BoundingSphere and mesh.ParentBone.Transform -- Scale?

Inaki Ayucar

If you see a 2.54 overscaling in your objects, after importing them into XNA through the Fbx importer, its due to the units setup of 3dsMax, not to the Fbx exporter configuration.

Just go to: Customize -> Units Setup -> System Units and set to Centimeters.






Re: XNA Framework mesh.BoundingSphere and mesh.ParentBone.Transform -- Scale?

Brandon Bloom

Yep, thanks -- I figured this out shortly after my post.



Re: XNA Framework mesh.BoundingSphere and mesh.ParentBone.Transform -- Scale?

atomic Sharky

Hey Brandon.

This sounds very similar to something I was struggling with until Shawn came to the rescue.

Take a look at my "XNA Collision Detection for 3D models" tutorial and there's a small solution/work around that solved it for me.

In Part 3 specifically, you'll see a code snippet for a Transform() method I use when scaling BoundingSphere's into World Space.

Look for this comment...

"//BoneTransforms can include some scaling"

You can download the working sample code for the tutorial here.

Hope this helps.

 

Sharky.

http://sharky.bluecog.co.nz