Game Development Reference
In-Depth Information
Soft-body physics tries to solve this problem by allowing each body's shape to be deform-
able to varying degrees. The application of soft-body physics in games is currently limited
to modeling vehicle damage (most notably BeamNG.drive ) and so-called “jelly phys-
ics,” where the shape of bodies is easily deformable but the shape itself tries to revert back
to its designed shape.
Note You may have heard of other applications for soft-body physics—for in-
stance, cloth and hair simulation and modeling facial expressions by simulating
muscles. However, these are almost exclusively used as visual effects and do
not affect the physics world as a whole. That's the kind of physics that can be
GPU-accelerated on current desktop computers. It looks impressive, but it is
purely a visual effect and likely to remain that way—unlike fluid simulation,
which has been used by games like “Where's My Water” and “Feed Me Oil” to
great effect. In games, fluid simulation is achieved by using a large number of
tiny rigid bodies with a circle shape and a custom renderer that traces the outer
bodies to draw blobs formed by a group of bodies. To prevent individual bodies
from simply becoming tiny droplets, the bodies attract each other to form
bonds—most likely programmatically, but spring joints could also be used.
Soft-body physics does not require a specialized physics engine. It can be simulated using
rigid bodies and joints. The basic underlying principle to make a body “soft” is to model
the body in question using several rigid bodies that form the outer shape and joining the
bodies together by using a combination of spring joints, often combined with a distance
joint to define the minimum and maximum distances the connected bodies can be apart.
Normally, the inside of the body consists of one or more shapes that hold the outer form
more or less in shape. They act as the bones for the soft part.
By far the easiest shape to model as a soft body is the circle, since every two opposing
bodies on the circle's circumference can be connected with joints, while more joints con-
nect the circumference bodies together to hold the shape in circle form. The joint connec-
tions naturally balance each other out.
Unless the body is meant to be heavily deformable, it helps to have a center body that
connects to the circumference bodies with distance joints to prevent the shape from fold-
ing in on itself. And many, if not all, the connected bodies need to collide with one anoth-
er to distribute the forces properly and again to reduce the risk of the body folding in on
itself. Figure 10-1 shows the finished setup of the soft-body player object you're going to
create in this chapter.
Search WWH ::




Custom Search