Modeling Cloth Using Mass Spring Systems Corey O Connor Keith Stevens May 2, 2003 Abstract We set out to model cloth using a connected mesh of springs and point masses. After successfully implementing our simulation in C++ and OpenGL, we analyzed it to determine how realistically the model responded to various situations, including collisions with objects and external forces like wind. We conclude that our system does model realistic cloth in most situations. For extreme values of the spring constant k our simulation fails. For small k, objects can pass through the cloth. For large k, our fixed step size fourth order Runge-Kutta approximation is no longer stable. 1 Introduction As the horsepower of the average personal computer increases, the gaming world has turned to more and more realistic simulations of the real world. Games are now expected to realistically model all aspects of the world and provide users with an interactive environment which reacts realistically to other elements in that environment. One big challenge is to realistically model clothing and other cloth-like materials such as curtains. This is a problem which has been solved many different ways to varying degrees of realism. Some implementations simply ignore the problem and just texture map the characters with images of clothing. While this is a quick and easy solution, the results are not terribly realistic, as the clothing will not respond realistically to the movement of the character. In fact, the clothing will be completely static and gives the impression of being painted on the character. 1
Many models use a system of springs to model cloth. They set up a mesh of individual vertices connected with many springs, and then use the equations for spring dynamics to model a piece of cloth. This solution provides a more realistic model, but requires a lot more computation than the texture mapping model. Not only must the system compute the forces acting on each vertex, but the system must also provide collision detection for each vertex, to make the cloth interact with other objects and itself in a realistic manner. Thus, modeling cloth becomes a trade-off between speed and realism. 2 Questions In real life, cloth is made out of thousands of fibers of varying materials woven together in various patterns. We want to create a simulation using only point masses and springs. Thus, our first question is: Can we make a real time simulation of cloth using a mass spring system? Once we have implemented a simulation, we want to determine whether or not that simulation behaves in a manner consistent with real cloth. Which leads us to the second question: Does our model behave realistically? Does it respond properly to collisions with objects, and with any external forces that are applied? We will then explore our model quantitatively to get an idea how well our approach can simulate the wide variety of materials allowed for in the mass spring system. Thus our last question is: For what values of the spring constant k is our model no longer valid? 3 Our Model The cloth is defined by a mesh of point masses. These point masses are connected together using three different sets of springs (see figure). Structural Springs These springs connect the mesh in a rectangular grid. They provide the structural basis for our cloth. Shear Springs To provide a resistance force to shearing, these springs connect the points diagonally. 2
Bend Springs To provide resistance to the cloth simply folding in on itself these springs are connected between every other point (see figure). Bend Springs Structural Springs Sheer Springs The equations that govern our model are fairly simple. The acceleration of each mass is determined by the standard equation for force: Ftotal = m a. For each mass the total force is the sum of the force due to each spring given by Hook s law (F = k l) and of any damping and external forces. Where k is the spring constant and l is the displacement of the spring from it s original length. Using the standard equations for position and velocity, we set up our model with the following system of equations: d x = v(t) dt d 2 x F = total ( x) dt 2 m F total = (k l) v(t) d + F external 3
F total is the total force acting on a point of mass m at position x with velocity v. k is the spring constant and l is the displacement of the spring from it s original length. d is a damping coefficient. 4 Numerical Methods Using a simple first order Euler approximation, our system becomes: x i+1 = x i + v i t v i+1 = v i + F i m t where x i is the position at time i and v i is the velocity at time i. We discovered that Euler s method became very unstable quickly in our simulation. Thus, we decided to use an implicit method of approximation. For each step in the simulation we apply fourth-order Runge-Kutta to calculate the state of the cloth after a given time-step h. Fourth-order Runge- Kutta applied to the cloth model takes this form: (v 1, a 1 ) = h f(t, p t, v t ) (v 2, a 2 ) = h f(t + 1 2 h, p t + 1 2 v 1, v t + 1 2 a 1) (v 3, a 3 ) = h f(t + 1 2 h, p t + 1 2 v 2, v t + 1 2 a 2) (v 4, a 4 ) = h f(t + h, p t + v 3, v t + a 3 ) (p t+h, v t+h ) = (p t, v t ) + 1 6 (v 1, a 1 ) + 1 3 (v 2, a 2 ) + 1 3 (v 3, a 3 ) + 1 6 (v 4, a 4 ) 5 Conclusions Our model provides a simple yet effective method for realistic modeling of cloth in real time. The simulation looks realistic and collides with objects consistent with the way real cloth would. When an external force like wind is added, the system continues to react in a very realistic manner. The model even simulates the waves that are created by holding one point of a cloth and shaking it back and forth. 4
We did find that for values of k less than or equal to 1, collision with a sphere failed. This is because our model only checks collisions with the points, and not with the region bounded by the point. Thus, when the cloth falls onto a sphere, the springs can stretch far enough that the sphere will simply pass right through the cloth. This is not realistic behavior. For reasonable values of k the model collides correctly as long as the objects are larger than the spacing between nodes. For values of k greater than 22, the system becomes unstable even using fourth-order Runge-Kutta indicating a different integration method is required in those situations. 6 Extensions and Future Work Our simulation is fairly simple and straight forward. It provides an effective means of simulating cloth. However there is still room for improvement. For instance, we would like to add collision with the cloth itself, not just the points. This would prevent the problem of objects passing through very elastic cloth. Also, we could add collision between the cloth and itself. Currently, the simulation does not check to make sure the cloth hasn t penetrated through itself. This can lead to some problems when the cloth wraps around an object and passes through itself. Unfortunately, this is a rather difficult problem to solve. Finally, to prevent the model from exploding on large values of k, we could implement a different integration method. Perhaps a variable step size Runge-Kutta would be more stable. Alternatively, a method which is specifically designed for stiff equations would also be a helpful extension of the simulation. 5
7 References http://www.cs.lth.se/~calle/report.pdf http://mathworld.wolfram.com/runge-kuttamethod.html http://www.gamasutra.com/features/20000327/lander_pfv.htm 6