Game Development Reference
In-Depth Information
Marking Regions
It will be rare that an effect—especially with the reverb effect—will be uniformly
applied to an entire level. Instead, it likely is necessary to apply the reverb only
in certain regions of the level. For example, if a level has both outdoor areas and
a small cave, the reverb might only be enabled inside the cave. A region can be
marked in a number of ways, but one of the simplest is to use a convex polygon
that lies on the ground plane.
Recall that a convex polygon is one where all the vertices of the polygon point
outward. More specifically, all of the interior angles of a convex polygon are less
than 180°. Figure 6.5 demonstrates both a convex and a concave polygon.
Figure 6.5 Convex (a) and concave (b) polygons.
The reason why a convex polygon is preferred is that given a point, it is relatively
straightforward to determine whether or not that point is inside or outside the con-
vex polygon. So, in our case, the convex polygon represents the region where
the reverb effect should be applied. Given the position of the player, it will then
be possible to determine whether the player is inside or outside that region; if
the player is inside the region, the reverb should be enabled, and vice versa. The
algorithm for determining whether or not a point is inside a convex polygon is
covered in detail in Chapter 7 , Physics ,” as it has many applications beyond just
DSP effects.
However, we don't want to just suddenly switch on the reverb as soon as the
player enters the cave. Otherwise, the effect will be pretty jarring. This means that
Search WWH ::




Custom Search