Erin
Contact

Department of Computer Science
Tufts University
Halligan Hall
161 College Ave
Medford, MA 02155
etreac01 AT cs.tufts.edu
Follow me on Twitter


Deformable Object using Mass Spring Model

Click here to download program.

This application uses a Mass Spring System to model 3-dimensional deformable bodies. The system allows users to interactively change the spring constants and mass of the particles and observe how the body behaves under gravity and collision with surfaces. The system was written using C++ and the OpenGL libraries. The user interface was designed using FLTK and fluid.

The deformable body is made up of several particles (or masses) connected by springs. These springs are used to allow the object to deform, and then depending on the strength of the spring, return to the resting position. The user can create cubes by clicking on a button on the user interface. A cube will be displayed in mid-air, and will fall to the floor due to gravity. Collision with the floor causes the cubes to deform, and come to rest. Viscous drag is also implemented in the system, and the result can be observed by changing the mass of the springs in the system.

There are several data structures used for this system.

First, there is a Particle. The particle is made up of a position, velocity, and force. Each particle also has a mass. However, in many cases, the particle's mass is the same throughout the system. It was desirable to allow the user to manipulate the mass of the particles interactively. Therefore, the mass can be changed in the user interface, and this will affect all particles in the system. There is no way to change the mass of individual particles, although it would not be a difficult addition to the system.

Another data structure is the Spring. The spring is made up of two particles, a rest length, a damping coefficient, and a spring type. The two particles are the masses at each end of the spring. The rest length is calculated when the spring is first created. It is the distance between the two particles. The particles may move closer and farther away from each other, but will tend to move back to positions such that the rest length is the distance between them. The spring type may be one of these values: SPRING_REGULAR, SPRING_FACE, or SPRING_DIAGONAL. SPRING_REGULAR refers to the springs that form the edges of the cube. SPRING_FACE refers to the diagonal springs on the face of a cube. SPRING_DIAGONAL refers to the diagonal springs that are inside the cube. Each type of spring may have a different spring constant which is manipulated by the user using the user interface. A strong spring constant will bring the particles back to the rest length with more force and a smaller spring constant will not. It seems sufficient to allow the users to change these three values, instead of directly changing the spring constant for each spring in the system.

Finally, there is a volume data structure. This has a linked list of particles and a linked list of springs. The volume is also where the default mass of all the particles is stored, as well as the values for the three spring constants. As explained above, the user may change these values which will affect the entire system.

At each time step, all of the particles in the system are updated, by applying forces, taking the derivative of the particles' states and using the Euler solver. Gravity and viscous drag are applied to all particles. Spring forces between the particles are also applied, using the spring constant and the damping coefficient. In addition, there is a plane at y=0. When particles hit this plane, a collision force is applied which prevents particles from going through the floor. The state of the system is stored in an array of doubles as discussed in class and in Witkin (1997). The particle system state contains the positions and velocity of all the live particles. This allows forces to be applied using Euler's method. John Hugg's vector class was used to store and manipulate vectors.

The application also includes the ability to clear the entire scene and start over, using the “Clear” button. The user may also increase and decrease the size of the masses and the thickness of the springs. There are instructions that appear in a separate window and are accessed using the “Instructions” button. There are buttons to increase and decrease the time step. Increasing the time step will speed up the system, but will result in less accuracy. Finally, there is a quit button to exit the application.

My goal was to create an easy to use, interactive application for experimenting with deformable bodies. If I had more time, there are several enhancements I would make to the application. First, I would allow the cubes to be rendered with textures or colored sides, and use lighting. Currently, the objects are represented as the masses and springs. I would like to keep this viewing option as well, as it helps to understand how the objects are deforming. I would also allow more options in what type of object to create. It would not be difficult to add the capability for the user to specify how many attached cubes to create. Currently the system can create one cube or four attached cubes. I'd also like to include more complex shapes. It would be nice to include 2-dimensional and 1-dimensional deformable objects in the system (e.g. cloth and hair). These would require additional forces to limit stretching, bending, shearing and twisting. Another potential enhancement would be to include collision detection between the objects.

REFERENCES
Chan, Eric. FLTK Tutorial - Comp 275. Tufts University Spring 2006.
Frisken, Sarah. Class Notes - Comp 275. Tufts University Spring 2006.
Hugg, John. Vec3 - a C++ Vector class. Tufts University Spring 2006.
Witken, Andrew. An Introduction to Physically Based Modeling: Particle System Dynamics. 1997.