Game Development Reference
In-Depth Information
which of the two faces the vertices E and E occur in counterclockwise order.
(For each edge structure created by the BuildEdges() function shown in List-
ing 10.1, the triangle for which the vertices occur counterclockwise is always
listed first.) Let N be the normal to the face for which the vertices E and E oc-
cur in counterclockwise order, and let N be the normal to the face for which the
vertices E and E occur in clockwise order. The two faces meet at an exterior
angle less than or equal to 180 degrees if
(
)
]
NEEN .
×− ⋅
0
(12.26)
[
1
2
1
2
12.3 Sliding
When a moving object collides with a stationary part of the environment and is
not destroyed as a consequence of the collision, most games allow the object to
slide along the surface of the geometry that it hit. This is especially useful when
the moving object is a character under user control, since sliding avoids the frus-
tration of getting stuck whenever a player runs into something.
The distance by which an object slides over a surface during the single frame
that it collides with part of the environment is determined by the angle with
which the object struck the surface. As shown in Figure 12.6, a typical sliding
implementation may choose to move an object to the point on the surface that is
closest to the point at which it would have reached had the surface not been there
P
1
N
P
3
Q
P
2
Figure 12.6. The part of the path from P to P that lies beyond the point of collision Q is
projected onto the direction perpendicular to the normal vector N to determine how far an
object should slide.