9

708 Chapter 13: reactor
Unlike traditional keyframe-based animation,
where the animator needs to specify a set of
key f ramed configurations, physical simulation
determines how objects move based their
properties. This t a kes the burden from the
animator, who now do esn’t need to manually
animateeverypieceinanexplosion,everybonein
a character stunt animation, or every vertex in a
piece of cloth.
In a physical simulation, physical properties such
as mass and elasticity are assigned to all objects
inascene. Thisisthencomplementedwitha
set of external forces lik e gravity or wind and/or
constraints, like a spring force or a ball-sock et
configuration. From all this information, the
physics engine calculates a continuous set of states
that can then b e displayed in real-time, if the
calculations are fast enough, or converted into
keyframes to be played back later .
What Does A Physics Engine Do?
A ph ysics engine like Havok has three basic tasks
to perform:
1. Collision Detect ion
Track the movement of all t he objects in
the scene and detect when any of them have
collided.
2. Update System
Determineanappropriateresponseforobjects
that have collided by resolving the collision
according to the object properties and for all
other (non-colliding) objects update them
according to the forces acting on them.
3. Interface with Application
Once reactor determines the new positions and
state of all objects, it can display the objects in
a3Dwindoworstoretheirstatesintheform
of keyframes.
Note: Aphysicsengineknowsnothingabout
howtheobjectsitissimulatingaredisplayed. It
simulates the motion and interaction of these
objects based on a physical (not graphical)
description of the objects, and this information
can b e used to generate a display that “tracks the
simulation.
Given that we are t alking about simulating a
continuously evolving state (in other words,
objects are moving and colliding and reacting all
the time i n general), we need to map this to a series
of snapshots in order to generate an animation. In
acomputergame,forexample,wetypicallywant
to display the world 60 times per second, b ecause
this is how frequently many graphics systems can
redraw the screen. When creating an animation,
we may want to store the state (that is, create a
key frame) for every fr ame. At 60 FPS, for example,
this would also create 60 keyframes ever y second,
Whatthisreallymeansisthatthephysicsengine
must b e capable of evolving the world by 1/60th of
a second knowing the state of all the objects at the
start of this time interval and knowing the external
forces acting on these objects. As an example we’ll
look at the simple case of a cannon ball and we’ll
assume we’re interested in animation at 60Hz (Hz
= c ycles or frames per second).
Simulating a Cannon Ball
Let’s forget about collisions for now, and consider
onlythesimulationofacannonballimmediately
after it has been fired from the cannon. We know
the ball’s position (and orientation, but well
ignore this for now), speed, acceleration, and
weight, and we assume we know the state of the
environment (air resistance, wind force, gravity).
Armed with this knowledge we can start to make
predictions using a physics engine.