Cloth Simulation

Cloth Simulation 1   Cloth Simulation 2


This demo displays a cloth modelled using a "ball-and-spring" model. A grid of balls is created and these are linked using springs. Each ball is connected to all 8 neighbours (up, down, left, right and diagonally) and to its next-but-one neighbour in the up, down, left and right directions.

The cloth begins suspended from its four corners above a sphere, above the floor. Pressing 1, 2, 3 or 4 will release a corner.

The physics for the model are updated every 10ms. For each ball, the overall force on it due to gravity and the springs is calculated. This is then used to calculate a new position and velocity. If the new position is within the sphere or below the floor, the ball is moved outside the object.

The cloth can be drawn in two ways. Either triangles can be drawn between the balls to create a simple triangle mesh, or each 4x4 subgrid of balls can be submitted to the OpenGL evaluators for interpolation and subdivision to create a smoother look.


No Extensions required.


Interactive Cloth Simulation, by Matthias Wloka.

Download: (360 KB)