Cloth

Hi all,
I’m working now on a planar cloth sim C++ extension. The actual code is not ready to be shared, but as soon as I have something less dirty, I’ll post it here.

The code is intended to be used for liquid surfaces more that for real cloth objects : the adjacency points are not movable and a little assumption concerning the axes is made when calculating normals.

Actual features :

  • Generates a spring system from a planar mesh made of quads
  • Normals are computed in a fast way, but could be more realistic
  • Almost framerate independent
  • One sphere collider

Planned features :

  • Propagation of vertex color ( sci-fi but nice to watch :slight_smile: )
  • N sphere colliders
  • Optimized collisions with AABB tests

If we consider that the points don’t move too much during the simulation, I could use a spatial indexation for collisions.

I spent a lot of time on the computation of normals, and I’m not really satisfied with the actual code. I didn’t manage to sort the neighbors of each point to perform cross operations in the right order, so for now, I correct the upside-down normals by hand assuming that they should have their Z component > 0

nice work!
if you are just simulating watersurfaces you could fallback on heygens wave principle. perfect for point emitters since all you have to do is to paint a grayscale texture.
for example each drop paints a light grey circle followed by a little bit darker gray. if 2 circles overlap just add the colors difference to the zero-level of the water.
could be done in a shader or offscreen buffer. should be fast like hell :slight_smile:

hope you can extend your current extension. having a rough cloth simulation for things like cloaks or so would be awsome :slight_smile:

This is a possibility, but it wouldn’t be precise enough to allow huge waves, and realistic bouncing onto the surface when it’s not horizontal.
It could work for a graphical only effect, but I want collisions with the mesh :wink:

This is the source, sorry for the dirtiness of the C++ code, it was hacked as quickly as possible and is not what you’d call a good looking OO C++ code.
Includes a windows release

tom.rethaller.free.fr/vrac/Forum … mCloth.zip