"If con is the opposite of pro, is congress the opposite of progress?"

Framework 4 (Last updated: October 25, 2019)
Framework 3 (Last updated: February 6, 2017)
Framework 2 (Last updated: October 8, 2006)
Framework (Last updated: October 8, 2006)
Libraries (Last updated: September 16, 2004)
Really old framework (Last updated: September 16, 2004)
Cloth
Friday, December 19, 2003 | Permalink

Executable
Source code
Cloth.zip (474 KB)

Recommended:
GL_ARB_shader_objects
GL_ARB_vertex_shader
GL_ARB_fragment_shader
GL_ARB_shading_language_100
GL_ARB_vertex_buffer_object
This is one of my coolest demos so far in my own humble opinion.
The demo simulates the physics of cloth. It properly interacts with the spheres it falls over and slides off them due to weight. The code to do this is surprisingly simple. The cloth is a rectangular field of points. Each point connects to its neighbors in all directions through imagined springs. For each frame the force, speed and direction is computed through Newton's simple laws of physics, and the position of each point is updated accordingly. In a second pass the normals are evaluated from the position of each point. The result is a very realistic cloth simulation.

The physics is done on the CPU, but is simple enough to be evaluated on the GPU with the upcoming superbuffers extension.

The lighting is done with GLSL, but there's also a vertex lighting fallback for cards that don't support GLSL. This gives lower quality however, but all cards should be able to run this demo.

2004-01-11:
Updated with more springs, which makes the cloth less stretchable and behave better. A standard GL vertex lighting path was also added.