Simple collision detection

Image source -

Thought this might come in handy for anyway wanting to test their code with some very basic collision detecion, it's by no means particulary accurate but is very simple to implement.

Click on image to view - you will be redirected to the image on imageshack - as blogger does not let you format code nicely ;-)

XNA simple collision detection code

After having a little look with Reflector it seems that when a .fbx model is compiled into a .xnb file that it automatically works out a BoundingSphere for that mesh, storing the information in the .xnb file. Then when creating a model and its subsequent meshes the ContentManager sets the BoundingSphere of that mesh to the value found in the .xnb file.

In my case I was using the spaceship model from the starter kit which only has one mesh. The BoundingSphere is rather large and so the spaceship only had to be in close proximity to the other and it detected it as a collision.