CSE 576 Computer Graphics - Final Project

Cloth Simulation and animation

Stefan Ekerfelt & Armin Hornung

Modelling the cloth

Building on the framework and GUI from the Animator project, we implemented a cloth simulation based on a particle system with springs. Each particle of the cloth is connected horizontally and vertically to each direct neighbors (springs controlling the stretch of the fabric), as well as diagonally (springs controlling the shear of the fabric). To control the bending of the fabric (creating ripples), there also need to be springs connecting the second neighbor horizontally and vertically. We found out that these connections are enough to create a quite stable and realistic looking cloth that can be simulated with an Euler ODE solver. The springs connecting particle i,j to its neighbors in the mesh is shown at the left. At the borders of the cloth, there are obviously less springs because of missing neighbors. Since we implemented the springs to work both in pushing as well as pulling direction, this is not a problem.

In the Animator, various properties of the cloth can be controlled directly by sliders, such as the dimensions, the density of particles, their masses, or the number of fixed (attached) points along each edge. To animate the cloth, the wind strength and direction can be set, as well as controlled with interpolating curves over the duration of the animation.

The cloth is rendered by storing the particles as coordinates in a OpenGL Quadmesh. For correct shading, we compute the surface normals with a cross-product.


Figure 1: Springs connecting one particle

ODE solving

To calculate the position and velocity of the particles at each time step, we need to solve the differential equations which are given by the forces applied to each particle. We decided to use the Euler method for this purpose (derived in equations 1 through 3). Given the length of each time step and the previous velocity and position of a particle, the Euler method estimates the new position. Since this method only makes use of the previously computed position, this estimation can be relatively poor, resulting in inaccurate simulation. When simulating the behaviour of springs, poor accuracy may cause the spring effect to explode by slightly overestimating the position of the endpoints of the spring at each step. By decreasing the step length, the accuracy of the Euler method is improved. We found that updating the particle positions in phase space 12 times per rendered frame produced stable enough results for our simulation.

Improving stability and rigidity

In our initial implementation, the cloth was over-elastic resulting from the springs - especially near the attachment points - stretching too much. However, increasing the springs' linearity constants leads to unstable behavior, resulting from the error accumulating during the ODE solving with the Euler method. We used the method described in [1] limiting the maximum extension of the stretch and shear springs. After updating the positions of the points of the mesh, the particles that are more than 10% of the resting length of the springs apart, are moved closer along the spring connection, to fulfil this constraint.


Figure 2: Adjustment of spring elongation

Collision detection

Another extension is the detection of collisions between the cloth and simple world ojects, such as spheres and boxes.

Static Collision detection

The collision detection for static objects is done by checking each particle after each frame update to see whether or not they have been moved into an object. If a collision occurs, the particle is moved to the closest surface point of the object and the velocity of the particle is reduced to 0 in the collision direction. Since the particles speed in the plane orthogonal to the collision plane is kept, the particles can smoothly slide over a surface.

A problem with a simple particle to edge collision detection as such is that the edges between the particles are not checked for collision. To compensate for this, we check for collision within a constant distance e from the surface. Furthermore, by increasing the particle density of the cloth, the length of the edges between the particles are decreased, thus reducing the probability of edge to edge collision. A more advanced solution to this problem would be to also do edge to edge collision detection, but this would also decrease the performance of the collision detection.


Figure 3: Results of different distance constants

Moving object collision detection

The collision detection for moving objects is done in a similar way as for the static objects. After each frame update, each particle is checked for collision. If has collision occured, the particle is not only moved to a position on the surface of the object. Since the object is not static anymore it will have a mass and a velocity. Using these properties, the collision can be treated as an elastic collision. To calculate the direction and velocity of a particle after a collision, we use the properties of the elastic collision.

1. The total kinetic energy before the collision is equal to the total kinetic energy after the collision:

2. The momentum remains constant throughout the collision:

Using the two equations above, the velocities v1 for the particle and v2 for the colliding object can be solved as:


Figure 4: Moving object shot at cloth



Influence of cloth parameters

The properties of the cloth in our simulation can be modified by several different parameters. These include:

ks: The constant of the stretch springs

ku: The constant of the shear springs

kb: The constant of the bend springs

The stretch constant control the elasticity of the cloth. As seen in figure 5, the retraction force of cloths with different stretch constants causes the colliding ball to bounce to different heights.

By adjusting the shear constant, the cloth's shearing property is adjusted. A high constant creates a cloth which is more resistant to shear stress, as seen in the figure 6.

The last constant controls the bending properties of the cloth. A cloth with a large bend constant will seems stiffer and creates larger ripples when affected by external forces (e.g. wind).

Furthermore, each spring constant is also affected by a corresponding damping constant, which controls the oscillation of the spring force.


Figure 5: Top figure: Cloth with ks=160
Bottom figure: Cloth with ks=110

Figure 6: Cloths with different shearing constants

Figure 7: Cloths with different bending constants

Results

The following artifacts were created by our cloth simulation:

References