# 3d bounding boxes of a model not displaying properly

This topic is 3320 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I am trying to display the bounding box spheres for all the meshes in the model. I have them displaying, but for some reason(which obviously I don't know), they seem to be just out of place. Well, I'll put in my code first and then ramble. Loading the <int, BoundingSphere> dictionary: Code:
Model.CopyAbsoluteBoneTransformsTo(transforms);

foreach (ModelMesh mesh in Model.Meshes)
{
}


Updating BoundingSphere dictionary: Code:
Dictionary<int, BoundingSphere> tempBSDictionary = new Dictionary<int, BoundingSphere>();

foreach (int index in BoundingSphereDictionary.Keys)
{
BoundingSphere bs = BoundingSphereDictionary[index];

Matrix transformation = transforms[index] * Matrix.CreateTranslation(Posn);
bs.Center = Vector3.Transform(Vector3.Zero,transformation);

}
BoundingSphereDictionary = tempBSDictionary;


What I am doing here is, transforming each sphere by the position in the world and further transforming by the internal transforms[parentbone.Index] And, the Draw Call: Code:
foreach (int index in BoundingSphereDictionary.Keys)
{
foreach (ModelMesh mesh in boundingSphereModel.Meshes)
{
foreach (BasicEffect effect in mesh.Effects)
{
effect.View = view;
effect.Projection = projection;

effect.World =
//Matrix.CreateTranslation(BoundingSphereDictionary[index].Center);
transforms[index] * Matrix.CreateTranslation(Position);

}
mesh.Draw();
}
}


Now, this works fine! Instead if I un-comment the Matrix.CreateTranslation(..) and comment the manual translation done via Code:
transforms[index] * Matrix.CreateTranslation(Position);


The spheres are not the same. They are bigger in radius when I use the boundingSphere.center to translate the spheres than when I use the transforms[index] * ... I am essentially doing the same thing in update as well, but still I dont understand why is there, this discrepancy in the output ? Can somebody please help me out with this. Also, if you want me to upload the code, I can do that. Thanks

• 10
• 18
• 14
• 18
• 15