Game Development Reference
In-Depth Information
But this topic isn't about collision detection. There are other books in this series,
including van den Bergen [2003], Ericson [2005], and Eberly [2004], that contain
more material than I can cover here.
13.1
C OLLISION G EOMETRY
The complex visual geometry in many games is too rich for speedy contact gener-
ation. Instead it is simplified into a chunky geometry created just for the physics.
If this chunky geometry consists of certain geometric primitives—namely, spheres,
boxes, planes, and capsules (a cylinder with hemispherical ends)—then the collision
detection algorithms can be simpler than for general-purpose meshes.
This collision geometry isn't the same as the bounding volumes used in coarse
collision detection. In fact, depending on the complexity of the scenes you need to
deal with, you may have many different levels of simplified geometry.
The simplest shape on which to perform collision detection and contact gener-
ation on is the sphere; hence its use in coarse collision geometry. Despite being fast,
however, spheres aren't always terribly useful. Boxes are also relatively quick to process
and can be used in more situations. Capsules are more difficult than spheres, but can
be useful in some situations. Other primitives, such as disks, cylinders, and trimmed
primitives, can also be useful.
A special case we need to consider is the collision of objects with the background-
level geometry. Most commonly this means collisions with the ground or some other
plane (walls can typically be represented as planes too). To support these, we'll also
consider collisions between primitives and planes.
It is important to remember that the primitives your game needs will depend to
some extent on the game. We'll only look in detail at spheres and boxes in this chapter;
otherwise the whole book would be about contact generation. The principles are the
same for any object, so with the help of the collision detection books in this series,
youshouldbeabletogeneratecontactsforawiderangeofprimitivepairs.
But primitives only get you so far. All primitives can only fit their objects roughly;
there are some objects that don't lend themselves well to fitting with primitives. In
these cases it can be more efficient to use a general convex mesh (or set of such
meshes).
Each of the collision algorithms is described in detail in the text, but most of the
code is reserved for the CD. Some of the algorithms are very repetitive, and the code
would run to more than a hundred pages if printed.
13.1.1
P RIMITIVE A SSEMBLIES
The vast majority of objects can't easily be approximated by a single primitive shape.
Some developers don't even try: they use convex meshes to approximate all objects.
Another approach is to use assemblies of primitive objects as collision geometry.
Figure 13.1 shows an object approximated by an assembly of boxes and spheres.
To collide two assemblies we need to find all collisions between all pairs of primitives
Search Nedrilad ::




Custom Search