Cloth simulation was always an interesting simulation for me. I have finally found time to experiment on this beautiful simulation. I have used famous “Mass-Spring Model” to obtain cloth behavior as discussed in literature [1].

As its name suggests “Mass-Spring” models cloth using particles with mass information where each particle is connected with series of springs to their neighbors. In my implementation, I basically generated a 2D grid mesh where mesh vertices act as particles in mass spring model and non-visible springs attached to them to provide cloth behavior.

In mass-spring model, there are three kind of springs as illustrated in Figure-1:

  • Structural Springs
  • Shear Springs
  • Flexion Springs

Figure-1: Mass-spring model illustration for a 3x3 cloth grid. Note that spheres on the image represents particles. Springs are only given from yellow particle for simplicity. These springs are generated per particle in cloth grid

Since we are talking about springs that we have seen in high school, their motion is modeled by Hooke’s Law [2] and other laws of motion. As described in Provot’s paper [1] there are three types of forces acting on each particle, I have also added wind force to my implementation to generate a real cloth simulation:

  • $F_{int}$: Internal spring force, modeled using Hooke’s law
  • $F_{damp}$: Damping force
  • $F_{grav}$: Gravitation force
  • $F_{wind}$: Wind force

that are computed as following equations that are described in Figure-2 below:

Figure-2: Forces acting on each particle. Note that wind force calculation is more or less same with gravitational force, only direction of wind changes compared to gravity force, therefore not included

Moreover, since we have $F_{total} = F_{int} + F_{damp} + F_{grav} + F_{wind}$ acting on each particle, by using highschool physics we know that $F=ma$ where $m$ is particle mass, we can easily find particle acceleration $a$. Since acceleration of particle $a=\begin{equation}\frac{\partial V}{\partial t}\end{equation}$ we can obtain velocity by integration $V=\int{adt}$ and find new position of particle accordingly using $\delta{t}$. To do that in an easy way and not to deal with exact integration, I have used well known numerical integration technique called as Verlet Integration [3].

Verlet integration finds new position of a particle as follows at each iteration:

$x’=2x - x^* + a\delta{t}$

$x^* = x$

where $x$ is current position of particle, $x^*$ is previous position of particle and $x’$ is next position of particle

Initialization
- Generate a grid of particles
- Connect each particle with the all three kinds of springs.
- Generate trianglulated vertices from the particles on the grid.
- Calculate texture coordinates and normals.
- Render cloth.

Main simulation loop
- Apply gravity force to each particle of the cloth.
- Apply wind force to each face(triangle) of the cloth.
- Apply a total spring force to each particle due to all springs that
  this particle is involved.
- Determine new positions of the particles due to sum of three
  forces above, using Verlet Integration.
- Generate trianglulated vertices from the particles on the grid.
  Calculate normals.
- Render cloth.

My results for cloth simulation using a 20x30 cloth grid are as follows:


References

1 - Xavier Provot, “Deformation Constraints in a MassSpring Model”

2 - Hooke’s Law

3 - Verlet Integration