Game Development Reference
In-Depth Information
Chapter 7. Physics
Although not every game needs physics, the ones that do implement col-
lision detection and movement at a minimum. Collision detection en-
ables the game to determine whether or not two game objects intersect
with each other. A variety of different algorithms can be used to detect
these collisions, and the first part of this chapter covers some of the
more basic ones.
The movement part of physics takes into account force, acceleration,
mass, and the other properties inherit in classical mechanics to determ-
ine where objects go from frame to frame. The only way this can be
done is by using calculus, specifically the numeric integration methods
covered in the second part of this chapter.
Planes, Rays, and Line Segments
Before we broach the topic of how we might represent characters and other game
objects in the world for the purposes of collision detection, we need to discuss
a couple of additional mathematical topics useful for physics systems. You may
have learned about these objects in a high school algebra course, but now that you
have familiarity with linear algebra wecan approach them fromaslightly different
perspective.
Planes
A plane is a flat, two-dimensional surface that extends infinitely, much like a line
is a one-dimensional object that extends infinitely. In games, we may commonly
use planes as abstractions for the ground or walls, though there are also other uses.
A plane can be represented in a few different ways, but game programmers prefer
where P is any arbitrary point on the plane, is the normal to the plane, and the
absolute value of d is the minimum distance between the plane and the origin.
Recall that a triangle is guaranteed to lie on a single plane. One reason the pre-
ceding plane representation is popular is because given a triangle, it is possible to
quickly construct the equation of the plane that triangle is on. Once we've com-
puted both and d , we can then test if any arbitrary point, P , also satisfies the
equation, in which case this arbitrary point is also on the plane.
Search WWH ::




Custom Search