pygame is
Python
Simple DirectMedia Layer
 
 
pygame.org is
Site Swing
verletCloth01

verletCloth01 - 1.0

Eric Pavey (akeric)

Tags:

Description

Simple verlet based 'cloth' simulation.

  • Grab and move and pin particles to modify the sim.
  • See details on the code's home page.
  • 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.

If you grab just the source, you'll also need a fixed-up version of the Pygame vec2d lib, which you can download from my site here:

Based on the 2001 Siggraph paper:

Links

Home Page: http://www.akeric.com/blog/?page_id=1123
Source: http://www.akeric.com/python/verletCloth01/verletCloth01.py
Windows: http://www.akeric.com/python/verletCloth01/verletCloth01.zip

Screenshot


click to view original size

Releases

verletCloth01 - 1.0 - Jul 4, 2010

Pygame.org account Comments

If you wish to leave a comment with your pygame.org account, please sign in first.

July 12, 2010 1:41pm - Eric Pavey - nickname: (akeric)
reading my mind ;) My currently local tests have modified it to auto-generate a random spread of particles, and then connect them via constraints based on a distance check \ max # of constraints per particle. Not quite there yet but gives some creepy spider-web like results. If I can get that working I'll move into the 3d realm...
July 10, 2010 12:34pm - DR0ID - nickname: (dr0id)
Idea: how would an image look that is mapped on the grid? Would be a cool thing to play around.

Using opengl it should be fairly easy to map an image onto the grid.
July 7, 2010 3:26pm - DR0ID - nickname: (dr0id)
There is not approval process, I have renamed it myself by now.
July 7, 2010 11:49am - Eric Pavey - nickname: (akeric)
lol, I didn't realize I could fix it. Just updated both it and the vec3d lib. However, I don't see my changes reflected... maybe there's an approval process first? Thanks for the headsup on the "<", I don't know anything about html tags ;)
July 6, 2010 2:26pm - DR0ID - nickname: (dr0id)
You are right, I must have been confused. Maybe you should update the Vec2d class in the cookbook?

The "<" is a html tag (probably because its on a web page) and should be replaced with a "lower than".
July 6, 2010 11:51am - Eric Pavey - nickname: (akeric)
The class name in the source is Vec2d, the *module* name is vec2d.py ;)

Irony is in the source code on Pygame site, the class name *is* lowercase, so I actually made it conform to pep8 in my source.
The 'problem' is down around line 400, in the func testAngles() :

self.assert_((v - v2).length < .00001)

That line gets angry, looks like there is corruption in the source: "<". I just comment it out to get things working again. Although I suppose you could just replace the bad text with a comma ",".

Glad you like the program ;)
July 5, 2010 2:39pm - DR0ID - nickname: (dr0id)
What did you fix in Vec2d? You should know that a class name should start with a capital letter according to pep8.

Nice implementation. I have been playing around with it.
spotlight

 
our projects
pygame.org welcomes all python game, art, music, sound, video and multimedia projects. If they use pygame or not.
 
recent releases
Oct 28, 2014

Oct 21, 2014

Oct 20, 2014

Oct 16, 2014

Oct 9, 2014

Oct 8, 2014

Oct 7, 2014

Oct 4, 2014

Oct 1, 2014

Sep 19, 2014

Sep 17, 2014

Sep 9, 2014

... more!
 
for pygame related questions, comments, and suggestions, please see help (lists, irc)