Game Development Reference
In-Depth Information
commercial titles for attention, and top-quality physics is a must for a top-quality
title of any kind.
1.3
A PPROACHES TO P HYSICS E NGINES
There are several different approaches to building a physics engine, ranging from the
very simple (and wrong) to the cutting-edge physics engines of top middleware com-
panies. Creating a usable engine means balancing the complexity of the programming
task with the sophistication of the effects you need to simulate.
There are a few broad distinctions we can make to categorize different approaches,
as described in the following sections.
1.3.1
T YPES OF O BJECT
The first distinction is between engines that simulate full rigid bodies and so-called
mass-aggregate engines. Rigid-body engines treat objects as a whole and work out the
way they move and rotate. A crate is a single object and can be simulated as a whole.
Mass-aggregateenginestreatobjectsasiftheyweremadeupoflotsoflittlemasses.
A box might be simulated as if it were made up of eight masses, one at each corner,
connected by rods.
Mass-aggregate engines are easier to program because they don't need to under-
stand rotations. Each mass is located at a single point, and the equations of the motion
can be expressed purely in terms of linear motion. The whole object rotates naturally
as a result of the constrained linear motion of each component.
Because it is very difficult to make things truly rigid in a physics engine, it is
difficult to make really firm objects in a mass-aggregate system. Our eight-mass crate
will have a certain degree of flex in it. To make this invisible to the player, extra code
is needed to reconstruct the rigid box from the slightly springy set of masses. While
the basic mass-aggregate system is very simple to program, these extra checks and
corrections are more hit and miss, and I don't feel that they are worth the effort.
Fortunately we can extend a mass-aggregate engine into a full rigid-body system
simply by adding rotations. In this topic we will develop a mass-aggregate physics
engine on the way to a full rigid-body physics engine. Because we are heading for a
more robust engine, I won't spend the time creating the correction code for springy
aggregates.
1.3.2
C ONTACT R ESOLUTION
The second distinction involves the way in which touching objects are processed. As
we'll see in this topic, a lot of the difficulty in writing a rigid-body physics engine
is simulating contacts: locations where two objects touch or are connected. This in-
cludes objects resting on the floor, objects connected together, and to some extent
collisions.
Search Nedrilad ::




Custom Search