Game Development Reference
In-Depth Information
CHAPTER 7
Real-Time Simulations
This chapter is the first in a series of chapters designed to give you a thorough intro‐
duction to the subject of real-time simulation. We say introduction because the subject
is too vast and complex to adequately treat in a few chapters; however, we say thor‐
ough because we'll do more than touch on real-time simulations. In fact, we'll walk you
through the development of two simple simulations, one in two dimensions and the
other in three dimensions.
What we hope to do is give you enough of an understanding of this subject so that you
can pursue it further with confidence. In other words, we want you to have a solid
understanding of the fundamentals before jumping in to use someone else's physics
engine, or venturing out to write your own.
In the context of this topic, a real-time simulation is a process whereby you calculate
the state of the object (or objects) you're trying to represent on the fly. You don't rely on
prescripted motion sequences to animate your object, but instead you rely on your
physics model, the equations of motion, and your differential equation solver to take
care of the motion of your object as the simulation progresses. This sort of simulation
can be used to model rigid bodies like the airplane in our FlightSim example, or flexible
bodies such as cloth and human figures. Perhaps one of the most fundamental aspects
of implementing a real-time rigid-body simulator is solving the equations of motion
using numerical integration techniques. For this reason, we'll spend this entire chapter
explaining the numerical integration techniques that you'll use later in the 2D and 3D
simulators that we'll develop.
If you refer back for a moment to Chapter 4 , where we outlined a generic procedure for
solving kinetics problems, you'll see that we've covered a lot of ground so far. The pre‐
ceding chapters have shown you how to estimate mass properties and develop the gov‐
erning equations of motion. This chapter will show you how to solve the equations of
motion in order to determine acceleration, velocity, and displacement. We'll follow this