Game Development Reference
In-Depth Information
body 1 minus the position of body 2. Similarly, v 1 and v 2 are the velocities of the con‐
nected points on bodies 1 and 2. The quantity ( v 1 - v 2 ) represents the relative velocity
between the connected bodies.
It's fairly straightforward to connect particles with springs (and dampers); you need
only specify the particles to which the spring is connected and compute the stretched
or compressed length of the spring as the particles move relative to each other. The force
generated by the spring is then applied equally (but in opposite directions) to the con‐
nected particles. This is a linear force.
For rigid bodies, things are a bit more complicated. First, not only do you have to specify
to which body the spring is attached, but you must also specify the precise points on
each object where the spring attaches. Then, in addition to the linear force applied by
the spring to each body, you must also compute the resulting moment on each body
causing each to rotate.
Connecting Particles
From swinging vines in Activision's Pitfall to barnacle tongues in Valve Corporation's
Half-Life , dangling rope-like objects have appeared in video games in various incarna‐
tions since the very early days of video gaming. Some implementations, such as those
in the 1982 versions of Pitfall , are implemented rather simply and unrealistically, while
others, such as barnacle tongues, are implemented more realistically in how they dangle
and swing. Whether it's a vine, rope, chain, or tongue, you can use particles and springs
to simulate realistic rope-like behavior. We'll show you how in the following simple
example.
Rope
You know from your real-life experience that ropes are flexible, although some are more
flexible than others. Ropes are elastic and stretch to varying extents. They drape when
suspended by their two ends. They bend when swinging or when collapsing on the
ground. We can capture all these behaviors using simple particles connected with
springs. Figure 13-2 illustrates the rope example we'll cover here.
Search Nedrilad ::




Custom Search