Game Development Reference
In-Depth Information
in reaction to this small deformation. This type of interconnected elasticity is
what a relaxation deformer attempts to replicate.
To do this, we will borrow (or steal) concepts from cloth simulation. The
mesh relaxation algorithm described here is almost identical to Thomas Jakob-
sen's constraint solver as described in his seminal paper, Advanced Character
Physics 2003 [Jakobsen 03]. See Section 11.3 for details on solving constraints
with relaxation.
As in Jakobsen's cloth simulation, distance constraints are created between
neighboring (in his case) particles (in our case, vertices). These distance con-
straints are solved by projection for a number of iterations, yielding a solution that
approximately satisfies them all. By building distance constraints (we can think
of them as springs), we are effectively constructing a linkage between neighbor-
ing vertices such that a deformation on one vertex is imparted to its neighbors
through the constraints. For a very readable introduction to position-based con-
straint solvers, please see [Muller et al. 06].
13.5.1 Building Edge Constraints
I have experimentedwith various methods of creating constraints (Euclidian prox-
imity, edge distance, across faces, etc). In my experience, the best behavior is
obtained by simply using the edges of the mesh itself. So there will be the same
number of constraints as there are edges. A constraint, therefore, contains the in-
dex to both vertices, as well as the initial distance between them (see Listing 13.3).
struct edgeConstraint
{
Ve r t ex vertexA; //Pointer to vertex
Ve r t ex
vertexB; //Pointer to vertex
float restLength;
}
Listing 13.3. A distance constraint ensures that the distance between two vetices, A and B,
remains as close as possible to the original distance (rest length).
13.5.2 Solving Constraints
Once we have a list of constraints, solving them is done by iterating over all of
them a set number of times (I've found five to ten iterations is usually plenty),
adjusting the position of each vertex accordingly. When the constraints have been
sufficiently solved, local deformation on the mesh will be distributed across the
surface, giving it a very convincing sense of elasticity.
Search Nedrilad ::




Custom Search