Cloth simulation circa 2009

Another salvaged artefact: an old animation of a rectangular cloth draped over an invisible donut-shaped table.

Click to show animation.


It’s nicely rendered in POV-Ray, but there are serious flaws in its computation:

  1. The cloth itself is infinitely stretchable and 100% elastic.
  2. The surface of the table resists cloth points; but the edges of each are intangible.  That’s why the the cloth will contract into the centre.  (The cloth will not obstruct itself, either.)
  3. There’s no air — a cloth simulation looks more “billowy” with a gentle breeze.

It’s simulated as a simple 100×100 array of points, with orthogonal connections to nearest four neighbours.  The connections are springs.

Flaw #1 arises because the spring model is as simple as can be: a force towards the natural length, in proportion to the distance from that length.  At the time I was experimenting with damping, but this was fraught with complications, around determining the velocity of expansion/contraction and calculating a braking effect as a proportion of that.  It’s a matter of keeping track of the coordinate transformations — I think the damping effect was correct, but I was fatigued from getting that far and muddled about how to apply that in the direction of the spring  If I can reconstruct this animation’s algorithm I’ll have a another go at figuring it out.

I’m not sure about Flaw #2.  It may come down to giving the table a thickness (and corresponding vertical surfaces) that is greater than the maximum spring length in the cloth.  This is fine for the table, but will not stop the cloth from flowing through itself (and almost becoming inverted, as shown in the animation).  Preventing this requires proper collision detection, which is only faked in the case of an abstract table surface.

Flaw #3 I’ll tackle if and when I’ve learned a bit about fluid dynamics. ;-)

Advertisements
This entry was posted in Simulation and tagged , . Bookmark the permalink.

3 Responses to Cloth simulation circa 2009

  1. Halitus says:

    Talk to me about point 3 some time. We may be able to approximate the action of the air without having to model any real air movement. depending on the application this may or may not be appropriate, for visuals it should be.

    Also with point one what happens when you make it completely inelastic or increase the stiffness a lot? most material is only very slightly elastic.

  2. ejrh says:

    Thanks for your offer Halitus; but I need to write the program from scratch first! (Fire.) I’m certainly planning to experiment with it again. I think I know a bit more about physics simulations now.

    I’m wondering about your air simulation comment. Are you suggesting it can be done without needing to model particles? Gravity can be applied as a constant force in the “down” direction. I imagine a steady breeze of speed s in the x direction could be applied to each point p as k(sp.vx)^r for 1 < r < 2 — i.e. the wind drags the object along with it. (Seem to remember that air friction is approximately proportional to the square of the difference in velocity.)

    On the other hand, I could just be making this up off the top of my head!

  3. Pingback: Project summary | EJRH

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s