Collision Sample
Description
This sample implements collision detection for triangles and oriented-bounding boxes.
Sample Overview
This sample implements collision detection for triangles and oriented-bounding boxes. It renders a scene that demonstrates collision detection for both of these shapes and the XNA Framework's built-in geometric primitives.
Sample Controls
This sample uses the following controls:
| Action | Keyboard control | Gamepad control | Touch control |
|---|---|---|---|
| Pause | Space | ||
| Single-step while paused | Left square brackets and right square brackets | ||
| Rotate the camera | Arrow keys | Right thumb stick | Drag |
| Move camera nearer/farther from target | Plus/minus keys | Triggers | Pinch |
| Move to next group of objects | G | Tap | |
| Switch between perspective and orthographic cameras | P and O | ||
| Exit | ESC or ALT+F4 | BACK | BACK |
How the Sample Works
The sample creates and animates instances of each XNA geometric primitive (Plane, Sphere, Ray, BoundingBox, BoundingFrustum), as well as two additional primitives defined in this sample: OrientedBoundingBox and Triangle. It tests pairs of objects with Contains or Intersects, so each combination of shapes is represented at least once. Contained, intersecting, and disjoint objects are drawn in different colors to illustrate the results of the tests.