Game Development Reference
In-Depth Information
only to those constraints that are stretched. Together, they can be tuned to create
the desired behavior.
A large push strength (0.6-1.0) will result in the mesh forming wrinkles when
under compression. This may or may not be desirable, but having the ability to
tune these parameters is highly recommended.
13.5.3
Laplacian Smoothing
In addition to relaxation, it may sometimes be necessary to aggressively smooth
areas of extreme deformation. Because this type of aggressive smoothing gen-
erally tends towards a noticeable loss of volume, it must be applied locally and
sparingly.
Experience shows that areas at high risk of becoming tangled include, for
example, the armpits, corners of the mouth, inside of elbows, or any region with
a relatively high amount of curvature coupled with large deformations. Applying
several iterations of Laplacian smoothing to these areas can quickly restore order
and untangle a mess of polygons.
As the number of iterations increases, the mesh tends towards its so-called
Laplacian shape, beyond which additional smoothing has no effect. This is
analogous to the limit shape of a subdivision surface.
The Laplacian smoothing operation works by moving each vertex to the aver-
age position of its neighbors (those vertices sharing an edge). The new position
of a vertex v is defined as
n i
1
n i
v i =
v j ,
j =0
with vertex v i having n i neighbors. Listing 13.5 shows this in pseudocode.
//Fetch neighbor vertices for each vertex
PreCalculateNeighbors (mesh);
//Now each vertex has pointers to its neighbors
// ie. vertex.neighbors[i] returns pointer to ith neighbor
...
//Now inside the deform function
for (eachIteration)
{ for (each vertex in mesh)
{
3dPoint averagePos = (0,0);
float numNeighbors = vertex.neighbors.length();
for (i=0; i
numNeighbors; i++)
averagePos += vertex.neighbors[i].pos;
vertex.newPos = averagePos / vertex.numNeighbors;
<
}