Game Development Reference
In-Depth Information
Bounding Shapes in 3D
In terms of bounding shapes, as with 2D programming, we again have a ton of options.
Figure 11-12 shows some of the more popular bounding shapes in 3D programming.
Figure 11-12. Various bounding shapes. From left to right: triangle mesh, axis-aligned bounding box, and bounding sphere
ï?® Triangle mesh : This bounds the object as tightly as possible. However,
colliding two objects based on their triangle meshes is computationally
heavy.
ï?® Axis-aligned bounding box : This bounds the object loosely. It is a lot less
computationally intensive than a triangle mesh.
ï?® Bounding sphere : This bounds the object even less well. It is the fastest way
to check for collisions.
Another problem with triangle meshes and bounding boxes is that we have to reorient them
whenever we rotate or scale the object, just as in 2D. Bounding spheres, on the other hand,
don't need any modification if we rotate an object. If we scale an object, we just need to scale
the radius of the sphere, which is a simple multiplication.
Bounding Sphere Overlap Testing
The mathematics of triangle mesh and bounding box collision detection can be pretty involved.
For our next game, bounding spheres will do just fine. There's also a little trick we can apply,
which we already used in Super Jumper: to make the bounding sphere fit a little better, we make
it smaller than the graphical representation. Figure 11-13 shows how that could look in the case
of a spaceship.
 
Search WWH ::




Custom Search