I’ve wanted, for a long time, to implement a ‘verlet‘ integrated cloth sim.  I’ve always thought the description sounded sophisticated and cool :-)  However, while I am on the ‘tech art’ side of professional video-game development and occasionally poke at code with a stick, I don’t have a strong traditional education in math or physics, other than what I learn on a ‘need to know’ basis.  So it’s safe to say, I’m riding on the shoulders of giants here.

  • You can download the zip of the Windows executable (32 bit) here.
    • Unzip, and run verletCloth01.exe
  • You can download the source Python module here.
    • It was built with Python 2.6.5 and Pygame1.9.1.
    • This program also uses a fixed-up version of the 2d vector library that’s on the  Pygame site, you can access  it (the fixed-up version) from my blog here, or the original from the Pygame site here.

When the sim starts, there is a cloth ‘grid’ suspended by its top left and right corners.  On my 6 year old 32-bit P4 laptop, I’m getting around 16fps depending on the number of constraint loops (set to 2 by default – setting to 1 gets me over 20fps, but the sim gets really soupy).


  • Expects a 3-button mouse.
  • You can LMB-click on any particle to make the particle stick to the mouse.  LMB-click again, and the particle will stick in space.
  • If you RMB on a stuck particle, it will unstick.


When I first started web-searching for Python-related verlet integrators, I first found this blog post and source code by a poster called ‘domlebo’:

His blog referenced a 2001 Siggraph paper by Thomas Jakobsen, but it was a dead link.  After some additional searching, I found a version here.  I’ve also uploaded it to my site for prosperity here.

My code is a Python\Pygame interpretation of that 2001 Siggraph paper.  Great learning experience.  I did borrow some code inspiration from ‘domlebo’s source, it was a great starting point to understand the paper.  But I’d like to think I put my own flavor on it and made it my own.  At the time of authoring though, I honestly can’t say I get ‘everything’ that’s going on, but it was a fun two day project.

  1. No comments yet.

  1. October 17th, 2015