Game Development Reference
In-Depth Information
Figure 10-2. Types of collision
In addition to the tasks discussed in the last section, this new version of CheckForCol
lision must also determine the exact point of contact between the hovercraft. This is
a very important distinction between this new version and the last. You need to know
the point of contact because in order to affect the angular velocity, you must apply the
impulse at the point of contact. In the last section, the normal to the contact point always
passed through the center of gravity of the hovercraft because we assumed they were
spheres; that's not the case here.
This now brings up the challenge of finding the collision normal. There are two cases
to consider here. In edge-vertex collisions, the normal is always perpendicular to the
edge that's involved in the collision. In vertex-vertex collisions, however, the normal is
ambiguous, so we've resorted to taking the normal parallel to the line connecting the
hovercraft's centers of gravity.
All of these considerations make CheckForCollisions a little more involved than in
the previous section. The following code listing shows what we mean:
Search Nedrilad ::

Custom Search