Saturday, January 2, 2010

My Cloth Simulation


As a quick and fun programming exercise, I wrote this simple cloth simulator based on the mass-spring model. The cloth is a simple grid of 13x13 nodes, each node connected to its neighbors by three different types of springs (structural, shear, and flexion). The cloth is initially suspended in air, and each end gets detached by a programmed keystroke. The node position is determined by the influence of the internal spring forces, the gravity and the wind. And lastly, the simulation is based on the leap-frog numerical integration method, slightly a higher order of accuracy than the Euler.
There're many features that could be added to improve the system, like adding a few more user-interaction GUI controls for the spring constants and the integration timestep size, as well as improving the lighting and rendering aspects.
Over all, it was a fun and rewarding exercise which kept me occupied for a few days.

January 2010

2 comments:

Renault said...

Way to go Joanna. It's really impressive. Is it a lot of effort/code to produce this kind of demos?

Joanna said...

Thanks Renault! It took me about five days to code; of course, I did about three days of reading before that, reading some of the published papers on the clothing simulation; it's quite an active research area. It was a fun exercise.