So I'm trying to implement some collision detection in XNA. I'm aware of the Bounding Spheres, but I worry with the accuracy, most items in my game are cubic in nature, so it seems very square-peg in a round hole, so it seems to me bounding boxes would be the best solution.

I looked at having libraries(JigLibX, Henge3D) to do it for me, but most have heavy physics systems attached and that's really not what I'm wanting I've also tried to implement solutions utilizing the Vertex buffers for Bounding Boxes after XNA's importers and processors pack the .fbx model into the Content Pipeline to no avail.

So the two things I feel I'm left with are:

  • Using Primitives as collisions "skins" for my objects.

    • Same problem here as using XNA's default bounding box, after Importation, I have no clue how to get it's size or even the vertices.
  • Creating a Custom Content Processor to determine the vertices at Load, and then apply transformations to the Bounding Box along with the Model itself at run-time.

    • problem Here is that this is a very daunting task. I'm finding it hard to locate thorough documentation on XNA's default importer, so it's highly difficult to just create a custom Processor. I wouldn't even know how to begin to write my own importer.

TL;DR- I've hit a brick wall with 3D Collision using Bounding Boxes, Halp?

  • \$\begingroup\$ If you were to use boxes, would you need them to rotate as the object they are bounding rotates or can you get by with axis aligned boxes? \$\endgroup\$
    – Steve H
    Feb 16, 2013 at 14:07
  • \$\begingroup\$ AABB are perfectly fine, while rotation will occur, the models won't clip the box by a huge amount. \$\endgroup\$
    – Sevvy325
    Feb 16, 2013 at 20:24

2 Answers 2


"Creating a Custom Content Processor to determine the vertices at Load, and then apply transformations to the Bounding Box along with the Model itself at run-time" is not a daunting task if you use the right algorithm.

You can use a custom ContentProcessor on your models that iterates through each vertex, look at their local positions and tracks the furthest ones on each axis. By doing so you can easily find the dimensions of the model and use it to make a BoundingBox object with the right dimensions. The thing is that you will need to update the size of the BoundingBox if you scale the model, which is not as difficult as it might seem since you just need to multiply the half of the box's dimensions by the scaling value.


You should be able to obtain the VertexBuffer after loading the model with the Content loader and through that obtain the actual vertices with a GetData() call. The only tricky part happens if there are bones in this particular model then you would have to apply the bone transformations to the child vertices in order that they would be scaled/translated appropriately. However, that said once you get the vertices and transformed them if needed, you simply do a little statistical analysis on them to determine the min/max for your x, y, and z. Use those values to create the 8 corners of your bounding cube and then make sure whenever you check for collisions that you apply the same transformation to the bounding cube that you did to your model.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .