Game Development Reference
In-Depth Information
Figure 13.3. Pre-deformation (left). Mesh after a sharp deformation resulting in unnatural
stretching (center). The deformed mesh after several iterations of solving the position
constraints (right).
inertia . The jiggle deformer is the temporal memory that records the previous
positions/velocities of the vertices and ensures that subsequent positions follow a
trajectory that mitigates any visible popping artifacts (which are common amongst
the outputs from relaxation and collision deformers).
Just like all the other deformers described in this chapter, the input to this
function is a mesh from a previous deformer. The input mesh acts as an attractor
that the jiggle deformer tries to mimic. The strength of the attraction is defined in
the springk parameter. Lower values create more floppy skin.
Each time the jiggle deformer is evaluated, it records the last position and
velocity of each vertex. To create the smooth attraction behavior, we assume
that each vertex is connected to its corresponding input vertex by a spring. The
rest length of this spring is always zero so that it acts by pulling the vertex to be
coincident with the input position. The force of the attraction is proportional to
the length of the spring according to Hooke's Law.
To integrate the position ahead in time, we use the force from the spring as
an acceleration that is applied directly to the velocity from the previous time step.
Then we do a Euler-integration step to find the final output position. This is shown
in the pseudocode in Listing 13.6.
//Typical values
float damping = 0.6;
float springk = 25.0;
float timeStep = 1.0 / 24.0;
for (eachVertex)
{ //Calculate the acceleration
Vector3d a = (vertex.inputPos vertex.lastPos) springk;
//Calculate new velocity
Search Nedrilad ::

Custom Search