Date post: | 02-Dec-2014 |
Category: |
Technology |
Upload: | stella0107 |
View: | 2,972 times |
Download: | 4 times |
1
Abstract—Cloth simulation has been extensively applied in film
making and in-game animation. In this project, I implemented a
virtual simulation interface for users to manipulate the cloth in
real-time. The key objectives in my project are to provide users with
an interactive interface to manipulate the virtual cloth dynamically,
while at the same time preserving the physical morphological details
of the cloth, such as wrinkles and folds. In addition, collision
avoidance of the virtual cloth (e.g., self-collision and cloth-object
collision) was implemented to realistically represent how a virtual
cloth conforms to different static objects.
I. INTRODUCTION
LOTH INTERACTION, depending on the degree of realistic
representation required during the simulation, can consume
a significant amount of computational resources. Modeling of
the virtual cloth using continuum models is therefore not
suitable for the purpose. To enhance the computational
efficiency, a mass-spring model is commonly used. In this
project, I implemented a simple interactive cloth simulation
interface based on the mass-spring model to animate a piece of
cloth in real-time. The virtual simulation environment allows
users to interact with the cloth in a three-dimensional (3D) space
through the mouse or keyboard controls.
In the simulation, the motion of the cloth is influenced by the
forces within the particles inside the cloth (i.e., internal force),
as well as the forces between the cloth and the other objects,
such as gravity (i.e., external force). Internal forces were
handled by constraining the motion of the particles, except for
the bending force acting on the cloth. External forces, such as
gravity, momentum transfer by winds, or the controls from the
users, were applied to the cloth, where the force magnitudes
were integrated over time. For collision detection, bounding
volume hierarchies (BVH) were used to improve the
computational efficiency. Self-collision of the object (i.e., cloth)
was handled to a certain extent. All functions of the interface
were programmed into a modular structure to facilitate the
testing of individual functions. The work flow chart of the
interface is illustrated in Fig. 1.
II. THE CLOTH MODEL
To construct a simulated cloth, a simple mass-spring
constitutive model was used. The model consisted of a mesh of
m× n virtual masses, with each mass being connected to its
neighbors by a number of massless springs at their natural
lengths. While more sophisticated model could be used for
constructing the simulated cloth (e.g., the finite-element
constitutive model), the simple mass-spring constitutive model
was sufficient for the modeling presented in this report. Based
on the model, three different types of springs were used (i.e.,
structural, shear, and bending springs), which are showed in Fig.
2.
The movement of each particle is governed by the
well-known Newton’s equation of motion:
2
2
dt
xdmamF i
iiii ⋅=⋅= (1)
where 3ℜ∈i
x denotes the 3D position of a particle,
3ℜ∈iF denotes the force acting on the particle, 3ℜ∈i
a and
im represent the acceleration and the mass of the particle,
respectively.
To solve for the equation (1), we have to determine the
resultant force, i
F , acting on each of the individual particles.
The resultant force consists of two components, one is the
internal force, intF , and the other is the external force, extF .
Mathematically, the resultant force can be expressed as,
exti FFF += int (2)
By calculating the internal and the external forces acting on
individual particles, one can determine the resultant force based
Interactive Cloth Simulation
Hsin-Huei Cheng
Computer Science Department, University of California, Los Angeles, USA
C
Fig.1. The flowchart of the cloth interactive simulation.
2
on equation (2). In the following, I will first introduce the
possible external forces that act on the cloth in the simulation.
These external forces will be modified by a bending force model
to further enhance the wrinkles and folds of the simulated cloth.
The modified external forces will be utilized to determine the
intermediate position of the particle at a specific time step using
an integration method. The intermediate position will be further
refined by considering the internal forces acting within the
cloth.
A. External Force
In real world, many different types of forces exist, such as
gravity and reaction forces induced by collision. When these
external forces impart on an object, the object will be set into
motion. To simulate the motion of the object realistically in a
digital computer, we need to account for the forces that act on
individual particles within the object.
The external forces can be mathematically represented by
vectors, which quantify the magnitude and the direction of the
forces. The resultant force acting on a particle can be obtained
by the addition of the force vectors. Through the use of
Newton’s law of motion, the acceleration of the particle can be
determined. This information is then used to calculate the
displacement of the particle at a particular time step through the
method of integration.
B. Bending Force
One of the goals of cloth simulation is to obtain folds and
wrinkles realistically. To achieve the effects, we have to
consider the bending forces acting on the cloth. Here, I chose to
implement the bending force model proposed by Bridson et al.
[1]. Specifically, Bridson et al. [1] suggested that it is critical to
avoid the introduction of arbitrary and artificial in-plane and
bending deformations into the model. This is due to the fact that
the exact nature of these physical coupling varies between
materials, and is not understood even for the simplest fabrics.
Bending force contains two components. The first component
is the elastic bending force, which is governed by the dihedral
angle, θ , and the rest angle, 0θ (Fig. 3). Sculpting folds could
be simulated on a cloth by setting a non-zero rest angle. The
second component is the damping bending force, which is a
function of the rate of change of the dihedral angle. Details of
the equations and implementation of the model can be referred
in Bridson et al. [1]. With the use of the bending force model,
one can simulate the interaction between the cloth and the object
more naturally (i.e., wrinkles on the cloth, see Fig. 4).
C. Integration Method
The standard explicit Euler integration method is a way to
compute the time history of the particle trajectory efficiently.
Despite the simplicity of the integration method, there are a
number of drawbacks for its use in the cloth simulation. First,
the method is not suitable for larger simulation time step,
especially in the situations when forces with large magnitudes
are involved [2]. Also, instabilities of the particle trajectory
result when the positions of the particles change rapidly due to
sudden collisions. To alleviate these problems, Meyer et al. [3]
proposed to correct the particle velocities within the objects
m =1 m =2 m =3
n =1
n =2
n =3
Fig. 2. Mass spring model for cloth representation. Particles
are represented in yellow circle. Three kinds of spring are
employed, structural (green), shear (blue) and bending (red)
spring.
(a)
(b)
Fig. 4. Comparison of the morphological features on a virtual cloth. (a)
Cloth simulation without bending force. (b) Cloth simulation with
bending force (rest angle = 15o), where more wrinkles were appeared.
1n
2n
e
1n θ 2n
Fig. 3. The bending elements contain two triangles with a shared edge.
er
. 1n and 2n are the normals of the two triangles. θ is the angle
between 1n and 2n , and the dihedral angle is defined as θπ - .
3
after each time step. The modified particle velocity based on the
proposed method can be expressed as,
dt
xxv
n
i
n
in
i
1−−= (3)
where in
v denotes the velocity of the particle, 1−ni
x and
ni
x represent the positions at the previous and the current time
step, respectively, and dt denotes the infinitesimal time step.
The velocity term in the equation (3) can be obtained by the
subtraction of the particle positions at different time steps.
Although positional errors may be accumulated as the number
of integration increases, this simplified method greatly enhances
the numerical integration stability as compared to other
conventional methods. To obtain the particle position in the
subsequent time steps, Verlet integration method was employed
as the method is known to be numerically stable [4]. This
method updated the particle position without computing any
velocities term, and can be expressed as,
i
n
in
i
n
i
n
i
n
im
fdtxxxx ⋅+−+= −+ 211
(4)
where fi denotes the accumulated external forces and mi denotes
the mass of the particle. In the project, I assumed all the
particles were identical (i.e., having the same mass). In addition,
equation (4) can be further modified by introducing a damping
coefficient, kd , (see equation (5)). With the new damping
coefficient, small amount of dragging effect can be
implemented into the cloth simulation.
i
n
in
id
n
id
n
i
n
im
fdtxkxkxx ⋅+−−−+= −+ 211 )1()1( (5)
D. Internal Force by Constraints
For a particle-spring system, the interactions between
interconnected particles are handled by linear springs. The
resulting force on individual particle can be calculated by
ij
ij
ijijijijxx
xxlxxkf
−
−⋅−−= )( (6)
where kij denotes the spring constant and lij is the rest length of
the spring. Despite the simplicity of the linear spring model, it
cannot fully simulate the cloth stretching process since the
process is highly nonlinear. When the elongation of the cloth
exceeds a certain threshold, the simulated cloth will become
very stiff. Instead of considering the internal forces between the
particles, Provot [5] proposed a simple alternative method
which uses particle position as the only parameter to solve the
stiffness problem.
In this project, I utilized the concept from Provot to constraint
the particle displacement within the cloth. In my approach, the
particle distances at each time step were compared with the rest
lengths of the spring. If the distance was larger than the rest
length, the particle distance would be reduced accordingly.
Likewise, if the particle distance was shorter than the rest length,
the particle distance would be lengthened (Fig. 5). The
pseudo-code of this constraint operation is illustrated in Fig 6.
The code was applied to every spring present in the cloth model.
This process was iterated several times within one time step in
order to converge to the desired solution. The necessary
number of iterations varies depending on the physical system
simulated.
III. COLLISION HANDLING
Collision handling refers to the detection of two objects when
they are in close proximity (i.e., collision detection), as well as
the respective methods to resolve the collision events (i.e.,
collision resolution). For interactive applications, collision
handling has been a bottleneck to the simulation performance.
Therefore, improvement in the computational efficiency plays
an important role in collision handling, especially for
self-collision (i.e., object collides with itself). To enhance the
collision handling performance, the first step is to optimize the
collision detection.
A. Bounding Volume Hierarchy
Collision detection between a cloth model with N particles
and an object with M nodes has a )(MNO complexity.
Similarly, the self-collision detection has a )( 2NO complexity.
To enhance the speed for collision detection process,
hierarchies of bounding volumes technique is introduced since
they provide a fast way to perform collision detection between
complex models.
There are several types of volumes, such as oriented bounding
boxes (OBBs), discrete-orientation polytopes (DOPs), and
axis-aligned bounding boxes (AABBs) [6]. In this project, I
used AABBs due to its easy implementation and fast collision
detection performance.
The AABBs hierarchy is a binary tree, where AABBs are
aligned to the axes of the model's local coordinate. An AABB
too large rest length too short
Fig. 5. Schematic showing the concept of the constraint
operation. If the distance between 2 particles (yellow dot) is
too large, then the particle will be pushed closer. Otherwise,
PseudoPseudoPseudoPseudo----code code code code ofofofof satisfyConstraint()satisfyConstraint()satisfyConstraint()satisfyConstraint()
Delta = x2-x1;
deltalength = sqrt(delta*delta);
diff = deltalength *(1- restlength/ deltalength);
diff_half= diff/2;
x1 += diff_half;
x2 -= diff_half; Fig. 6. Pseudo-code of the constraint operation.
4
hierarchy is constructed bottom-up, where two neighbor
primitives (particles, triangles or edges) are grouped under a
parent. This process is performed recursively until only one
AABB left, termed as the root of the AABBs hierarchy.
Building the AABBs hierarchy for a static object is a one time
operation. For a moving object (e.g., the cloth), the hierarchy is
required to be updated at each time step. The AABBs hierarchy
of different levels is illustrated in Fig. 7.
An intersection test between two nodes of two hierarchies is
done by recursively testing pairs of nodes. For each pair of the
nodes, the AABBs are tested for overlapping. Only the
overlapped nodes are further traversed to their children nodes.
The procedures of traversing hierarchies are borrowed from the
concept of Van Den Bergen [6]. These procedures are outlined
as follow:
i) If both of the nodes are leaf nodes, then the primitives are
tested for the occurrence of intersection to determine whether
collision occurs. If collision happens, then further collision
resolution will be performed.
ii) If one of the nodes is a leaf node and the other is an internal
node, then the leaf node is tested repeatedly for the occurrence
of intersection with the children of the internal node, until a leaf
node is reached.
iii) If both of the nodes are internal nodes, then the node with
smaller volume is tested for the occurrence of intersection with
the children of the node with the larger volume.
B. Cloth-Object Collisions
Cloth-object collisions are detected by testing the occurrence
of the intersection between the particle BVH of the cloth and the
triangle BVH of the static model. If both nodes are leaf nodes,
the proximity test is performed to check if the particle is close to
the triangle. For example, to check if point 4xr
is closer than the
cloth thickness h to a triangle 321 xxxrrr
with normal n , I first
checked if the point was close to the plane containing the
triangle, i.e., hnx <• ˆ43
r. If this was the case, I projected the
point onto the triangular plane and computed the barycentric
coordinates 3,21, www with respect to the triangle:
•
•=
••
••
4323
4313
2
1
23232313
23131313
xx
xx
w
w
xxxx
xxxxrr
rr
rrrr
rrrr
(7)
1321 =++ www (8)
The purposes for Equations (7) and (8) are to find the
barycentric coordinates. If the barycentric coordinates were all
within the interval [−δ , 1+δ ], where δ is h divided by a
characteristic length of the triangle, the point was close to the
triangular plane [7]. Then the projected position could be
obtained by using equation (9). Then the new position of the
particle 4xr
would be assigned to prjxr
to resolve the collision.
332211 xwxwxwxprj
rrrr++= (9)
In addition to modifying the particle position, it is also
necessary to adjust the particle velocity for the purpose of
collision resolution. Since the collision event is happened in
between a cloth and an object, the friction between them has to
be taken into consideration.
General macroscopic laws of friction describe the forces that
are applied to each of the objects when they are in contact. The
friction forces could be derived from the Coulombian law.
During an “inelastic” collision, there is some dissipation of
energy during the collision. For a “perfectly inelastic” collision,
the energy is completely dissipated. Both forces are coupled to
generate an integrated response as showed in equation (10) [8].
−=<
−−=≥
NdTNfT
Nd
T
TNfTTNfT
vkvvkvif
vkv
vvkvvvkvif
rrrr
rr
rrrrrr
'
'
,
, (10)
where NT vvvrrr
+= is the resultant velocity of the particle before
collision, and T
vr
and N
vr
are the tangential and the normal
velocity component of the particle, respectively. 'vr
is the
resultant velocity that will be assigned to the particle. kf is the
friction coefficient and kd is the dissipation coefficient
( 10 <≤ dk ). kf =0 means sliding without friction, and
kf = ∞ means sliding is prohibited.
C. Self-Collisions
Accurate geometric collision test is required to resolve any
undetected collisions. In addition, more advanced techniques,
such as impact zones, are applied iteratively to resolve each
collision [5, 7, 9]. These methods can generate
close-to-perfect/perfect collision resolved results. However,
the drawback of these methods is the consumption of significant
amount of computational time. For interactive applications,
self-collision occupies a significant portion of the rendering
time, thus self-collision handling is ignored in most of these
applications.
In this project, I considered the particle-particle and the
particle-triangle interactions independently. Since the AABBs
hierarchies of particle and triangle of the cloth were built at each
time step, colliding pairs were obtained by the bounding box
hierarchy intersection tests.
For a particle-particle pair, I directly added repulsion forces
between the two particles. The inelastic impulse was calculated
based on the relative velocity of the two particles using equation
(11).
Level = 0 Level = 3 Level = 5
Fig. 7. The AABBs of triangle hierarchy at different level.
5
2/NmvI = (11)
where I is the magnitude of impulse, m is the mass of particles,
and Nv is the relative velocity on the normal direction. For one
particle, the repulsion force was given by nI ˆ• , whereas that of
the other particle was given by nI ˆ- • .
For the particle-triangle pairs, I performed the proximity test
which is the same as the test described in that of the cloth-object
collision. The inelastic impulse was calculated using equation
(11) based on the relative velocity of particle and the
interpolated velocity of the triangle (i.e. 332211 ++ vwvwvwrrr
).
The repulsion forces acted on the particle and the triangle could
then be obtained using equation (12).
nmIvv
inmIwvv
www
II
new
i
new
ii
ˆ)/~
(
3,2,1ˆ)/~
(
1
2~
44
2
3
2
2
2
1
−=
=+=
+++=
rr
rr (12)
where I~
is the weighted impulse, new
ivr
(where i=1,2,3) indicates
the new velocities of three particles of the triangle, and newv4
ris
the new velocity of the particle.
D. Preserving Folds and Wrinkles
The collision between cloth and object is often resolved by
projecting the particles of the cloth to the outer surface of the
object. However, projecting the cloth particles to the outer
surface of the object will smooth out the wrinkles and folds of
the cloth, as illustrated in Fig. 8 (a). To resolve this information
loss (e.g., wrinkles), Bridson et al. [1] proposed a simple yet
powerful post-processing method. The method is to bring all
the cloth particles inside the collision volume above the object
surface. Mathematically, this can be achieved by applying a
monotonic increasing function to rescale the cloth particle
displacement, so as to preserve the cloth morphology. The
method can be illustrated in Fig. 8 (b).
IV. INTERACTION
Interaction is the most intuitive and fun part of human feelings.
In this project, I implemented two different interactive functions
for user to manipulate the cloth in the virtual world.
A. Dragging
User could drag any part of the cloth to see how the cloth
interacted with the objects or the environment in real-time. The
openGL GL_SELECT mode was used to determine which
particle was selected. In some situations, there might be several
particles lining up together at the location where the user chose.
The pick function would automatically choose the particle
which was closest to the user determined position.
User could also click on the left button of the mouse to drag
the particle to a specific location, and then free the particle by
releasing the button. This interaction would generate an
external force. The force vector is defined as the difference
between the local particle position and the position where the
user released the button.
B. Fixing and Releasing
In the 2nd
type of interaction, users can fix and release the
virtual cloth through the mouse and keyboard control. The
function “Fixing” fixed the particles to specific positions. User
could click on any part of the cloth during the simulation and the
pick function would determine which particle is being selected.
The motion of a moving particle can be made frozen by using a
keyboard control, “M” or “m”. Likewise, the same keyboard
control can be used to make a frozen particle move. The
combination of mouse and keyboard control could simulate
some interesting cloth mechanics, such as cloth hanging, or
wrapping an object etc.
Other user interactions, such as controlling the camera view
by zoom in/out or rotating the scene around the y-axis, can be
achieved by using the controls from a mouse. The keyboard
control can also be used to start or to pause the simulation.
V. IMPLEMENTATION AND RESULTS
A. Default Scene
In the project, the scene contained a static model, a horizontal
ground where the model located, and a moving cloth. A
representative scene is shown in Fig. 9. The number of faces in
the model is 1418 and the total number of the particles in the
cloth is 600. Wind and gravity forces have been added to the
cloth by default.
B. Experimental Illustrations
1) Cloth – object collision
The cloth was hanged in the air with gravity and wind forces.
When the cloth collides with the model, the collision would be
resolved to a certain extent. In the simulation, collision between
the cloth and the sharper edges of the model could not be
resolved because the edge-edge collision handling was not
performed.
(a)
(b)
Fig. 8. Cloth penetrating into an object can be (a) pushed to the cloth
boundary, where the wrinkles will be flattened; or (b) pushed to a region
(the green dotted line) outside the object using monotone mapping, where
wrinkles can be preserved.
6
2) Cloth self- collision (particle-particle pairs)
The following result showed when only particle-particle pairs
were considered for self-collision, the cloth would penetrate
itself.
3) Cloth self- collision (particle- triangle pairs)
The following figure (Fig. 12) showed the result of
self-collision resolution based on particle-triangle pairs. The
collision resolution had been resolved and the wrinkles and
folds were preserved.
Fig. 12. The result of cloth self-collision using particle-triangle BVHs.
Fig. 10. The collision handling between the cloth and the model.
Fig. 11. The defect of cloth self-collision using particle-particle BVHs
only.
Fig. 9. A representative default scene.
7
4) Fix the cloth
Parts of the cloth were fixed in arbitrary positions during the
simulation. The cloth simulations at different viewpoints were
illustrated in Fig. 13 and Fig. 14, respectively.
5) Releasing hanged cloth
The default cloth was hanged by fixing 6 particles on the
cloth (i.e., 3 particles each on the upper corners of the cloth).
User could use a mouse to release the cloth and also could drag
the cloth to any positions. The results of the cloth releasing and
cloth dragging were shown in Fig. 15.
6) Dragging response
The results for cloth dragging and the subsequent response of
the cloth were shown in Fig. 16.
VI. DISCUSSIONS
Robust collision handling is the most challenging part in cloth
simulation. For the cloth-cloth and cloth-object collisions, I
tried to handle both point-triangle and edge-edge collisions.
However, the animation took a few seconds to render each
frame. To enhance the computational efficiency, I only used
point-triangle BVHs to handle the cloth-object collision. Under
this condition, some collisions occurred on parts of the model
with sharper edges. This type of collision could be resolved if
the edge-edge collision resolution was applied. As for the
self-collision, I used two methods to detect and to resolve the
collisions. One was to detect particle-particle pairs and the
other was to detect the particle-triangle pairs. The latter
performed better than the former one. However, the
particle-triangle based collision handling consumed a
significant amount of computer run time. The efficiency of
collision detection could be improved by using more efficient
hierarchy traversing and updating methods, while the collision
resolution could be improved by using hybrid integration [ 7, 9]
or adaptive time step integration. For the interaction part, so far
only basic operations were implemented. Future work includes
adding more interactive functions, such as dressing a character.
VII. CONCLUSIONS
This project demonstrated a platform for interactive cloth
simulation, where a user could animate a virtual cloth in
real-time. The platform developed in this project is applicable
to simulations with large time steps. Also two important
properties of cloth, folds and wrinkles, were retained in the
virtual cloth simulation. Collision handling was also
implemented in the project, allowing the virtual cloth to
conform to different static objects. In addition, basic physical
manipulations of the virtual cloth, such as dragging and
releasing, were provided for user interactive applications. The
interactive platform provided in this project will allow users to
interact directly with a realistic cloth in a virtual environment.
The platform should be useful for a broad variety of in-game
purposes.
ACKNOWLEDGMENT
I would like to thank my advisor Prof. Petros Faloutsos and my
mentor Gabriele Nataneli for their patience and useful advice
throughout the project. I am very grateful to have the chance to
learn from them. Also, I would like to thank Prof. Demetri
Terzopoulos and Prof. Glenn Reinman for serving on my
Examination Committee.
REFERENCES [1] R. Bridson, S. Marino and R. Fedkiw. Simulation of clothing with folds
and wrinkles. In Proc. ACM/Eurographics Symposium on Computer
Animation, pp. 28–36, 2003.
[2] D. Baraff and A. Witkin. Large steps in cloth simulation. Comput. Graph.
(SIGGRAPH Proc.), pp. 1–12,1998
[3] M. Meyer, G. Debunne, M. Desbrun, and Alan H. Barr. Interactive
animation of cloth-like objects for virtual reality. The Journal of
Visualization and Computer Animation, vol. 12, pp. 1–12, 2001.
[4] L. Verlet. Computer ”experiments” on classical fluids.
i..thermodynamical properties of lennard-jones molecules. Physical
Review, vol. 159, pp. 98–103, 1967.
[5] X. Provot. Deformation constraints in a mass-spring model to describe
rigid cloth behavior, In Graphics Interface 95, pp.147-154, 1995.
[6] G. Van Den Bergen. Efficient collision detection of complex deformable
models using AABB trees. Journal of Graphics Tools 2, 4, pp. 1-14, 1997
[7] R. Bridson, R. Fedkiw, and J. Anderson. Robust treatment of collisions,
contact and friction for cloth animation. ACM Trans. Graph.
(SIGGRAPH Proc.), vol. 21, pp. 594–603, 2002.
[8] X. Provot. Collision and self-collision handling in cloth model dedicated
to design garments. In Graphics Interface 97, pp. 177–189, 1997.
[9] A. Selle, J. Su, G. Irving, and R. Fedkiw. Robust high-resolution cloth
using parallelism, history-based collisions, and accurate friction. IEEE
Transactions on Visualization and Computer Graphics, 99(2), 2008.
Fig. 14. The result of particles fixing (at a different view point).
Fig. 13. The result of particles fixing.
8
(a) (b) (c)
(d) (e) (f)
Fig. 15. Representative images showing the releasing and dragging of a cloth (e.g., releasing the cloth from a corner in (a) and dragging the cloth in (e)).
(a) (b) (c)
(d) (e)
Fig. 16. Representative images showing the dragging of the cloth at a specific location (e.g., see (a)) and the subsequent response of the cloth.