Col 0599
Col 0599
I tems for the past couple of months. These techniques excellently increase the
realism in your real-time graphic simulation. One of dynamic simulation’s key
benefits is that it creates a scaleable game experience.
Users with more powerful systems get a
more realistic experience, while users
with less powerful systems are still pro-
doesn’t move along with the body. It’s
possible to morph the shape of the skirt
to match the motion of the character,
should go back and read the March
column or at least take a look at the
March source code on the Game
17
vided with a complete experience. It’s but this requires quite a bit of detailed Developer website (http://www.
an analogous situation to the use of animation work. Likewise, deforming gdmag.com).
levels of detail in your 3D models. the skirt with a bone system can be I start by creating a rectangular grid,
Particularly in the PC market, where effective, but not necessarily realistic. and then connected each point to
target systems can vary widely, these For my work, I wanted to create real- neighboring points with springs, as
techniques have become a crucial istic cloth in the environments and on you can see in Figure 1A. These springs
weapon in the developer’s arsenal. the characters. My hardware accelerat- define the rough structure of the cloth
For a current project, I decided to ed graphics rasterization freed the and so I refer to them as “Structural
maximize the use of dynamics to processor power necessary to make this
increase realism wherever possible. The possible. So, I set about creating a real-
project focuses on characters in moody time cloth simulation.
interior environments. It occurred to
me that the use of cloth animation in
my scenes would be crucial to creating The Latest “Springy” Fashions
the mood I was trying to establish.
he mass and spring dynamics sim-
the radius of the sphere. Now that the F I G U R E 3 . Collision with a sphere.
contact point is established, I need to
resolve the collision. The collision nor-
mal, N, between a point and a sphere is
the vector between the point of contact
and the center of the sphere. You can
X
see this in Figure 3. Fortunately for me,
the rest of the collision response is
handled just like the collision with a
plane. This means my existing collision
N
response code works great.
I can now add collision spheres to
F I G U R E 2 . Collision boxes allow for my simulation. The cloth slides realisti-
the draping effect on this tablecloth. cally off the spheres. You can see how
the simulation looks with two collision
spheres in Figure 4. By animating the S
it’s important to use a good numerical spheres along with the 3D model, I can
integrator. The midpoint method and get a nice animated hip sway and other
Runge-Kutta integrators developed last alluring effects. The motion of the
20 month seem to do the trick nicely. cloth continues after the animation
stops. This creates entertaining effects
that are diffiicult to achieve with tradi-
Making It Move tional animation techniques. a little more. Game players with a
white-hot system should have
already have a simulator from the smooth-looking cloth.
I March column that is capable of
handling a cloth patch. I can even
Problems to Avoid and Ignore Another problem is that each spring
acts independently. This means that
apply gravity to it and lock the posi- he simulation has a couple of each spring can be stretched to a great
tion of individual vertices. That’s pret-
ty interesting, but it needs some
T problems. The first is that the way
to simulate cloth realistically is to use
extent. In many cases, the amount of
stretch can exceed 100%. This is not
improvement to come alive. In March, a lot of points in the simulation. This very realistic. Actual fabric will not
I also discussed the use of planes for takes more computation time. High- stretch in this manner. The problem I
collision. With this same method, I can end animation programs rely on a have is that I am using linear springs
create collision boxes that enable me to great numbers of particle points for when fabric actually displays a non-
simulate a tablecloth draped over a realism. Of course, in other fields, linear spring behavior. As the amount
table, as you see in Figure 2. hour-long render times are perfectly of stretch increases, the strength of
This model is interesting and realis- acceptable. In a real-time game, how- the spring increases also. The fabric
tic looking but not terribly animated. ever, this won’t get you on the cover will also stretch to some limit and
In fact, in this case it’s probably better of any game magazines. You have to then if the force continues, it will rip.
to freeze the simulation and avoid the sacrifice realism for speed. This is This is not what I want (at least for
constant recalculation. Unless, of another good area for scaling game now). This issue, which Xavier Provot
course, the wind kicks up or someone performance. If the system is running (see For Further Info) calls “the Super-
pulls on the corner. quite fast, subdivide the cloth patches Elastic Effect,” is difficult to handle.
For characters, a moving box is not Increasing the spring strength dynam-
the most realistic way to displace the ically can lead to instability problems
cloth. Moving bounding spheres allow just like any other stiff spring prob-
much more pleasing character anima- lem. Provot suggests checking the
tion. Fortunately, this is easy to add to amount of stretch in each spring and
the simulation. Determining if a point if it is exceeds a set deformation limit,
is inside a sphere is very easy. If the dis- the springs are adjusted to achieve
tance from the point to the center of this limit. While I agree this solves a
the sphere is less than the radius of the definite problem, a second pass
sphere, the point is on the inside. If a through the springs is costly. For the
point in the cloth is found inside a effects I have attempted to achieve, I
sphere, I have a penetrating collision. can live with super-elastic cloth.
Just like handling collisions in the My collision system is pretty primi-
March simulator, I need to back up the tive. To make things easy, I only col-
simulation time to find the point of lide the vertices of the mesh with the
actual contact. In a sphere, contact F I G U R E 4 . Cloth hanging from a pair objects. As it stands, if a sphere is
takes place when the distance of the of invisible hips. small or the fabric stretches too much,
point to the sphere center is equal to the sphere will pass right through it. I
22