XNA Collision Detection for 3D models
Update 17 Apr 2009:
Get the latest sample here (v126.96.36.199).
IMPORTANT: The tutorials have not been updated to reflect this XNA v3.0 version and refactoring.
The main changes are these:
- updated for XNA v3.0
- refactored to make it easier to include your own models and textures
- refactored so that the subdividing info is now contained in XML files
Includes the following 24 Feb 2007 updates…
- When constructing a BoundingPart you now additionally pass the original ModelMesh’s original BoundingSphere. This is used as a general proximity test, so the rest of the BoundingSphere’s don’t need to be transformed and tested on every frame.
- This behavior is optional. When calling Transform() there is a bool “optimize” parameter. Pass false and the behavior is as it was before.
- Re factored a little. The List stuff is now encapsulated into a class.
- When you run the sample, you will notice the BoundingSpheres often don’t move with the model. This is deliberate, and demonstrates the optimizations working. It means they didn’t need to get transformed on each frame because nothing (i.e. the 3D Mouse Cursor) is in the general proximity of their BoundingPart.
- the XBOX 360 controller now rumbles when the 3D Mouse cursor collides.
there is a Mouse moveable black Cursor that goes White when colliding. The controls are…
- Pitch model: XBOX 360 Left Thumbstick Forward/Backwards or Keyboard W/S
- Roll model: XBOX 360 Left Thumbstick Left/Right or Keyboard A/D
- Yaw model: XBOX 360 Right Thumbstick Left/Right or Keyboard Q/E
- Scale model: XBOX 360 Left/Right Trigger or Keyboard LeftShift/LeftCtrl
- Move 3D cursor: Mouse
- Move 3D cursor forward/backwards: Mouse Scrollwheel Forwards/Backwards
- Screenshot and XML Dump (put in \Screenshots sub directory): Keyboard PrintScrn
if you’re after the original (XNA v1) working sample that matches the Tutorial text, get it here