Cloth simulation in C++


#1

I made a cloth simulation using c++ and posted the video in youtube as linked below.

http://www.youtube.com/watch?v=YVhD2d2wWHU

It uses implicit backward euler integration and continuous collision detection for cloth-object and cloth self-collision. Strain limiting was used to simulate inextensible cloth. BVH/AABB was implemented to avoid n^2 collision checking. Rendering was done in Maya and AnimOBJ(http://code.google.com/p/animobj ) was used. I made the Maya plug-in and opened it for public.

If there is anyone who is interested in developing physically based animation such as cloth and fluid, please feel free to contact me.

Thanks.


#2

Congrats on your simulation. Looking very nice. You are using a mass-spring model? What’s the resolution of the cloth and what’s the simulation speed? Just curious. :smiley: Well done and keep it up.


#3

yarniso, thank you for your comment. The cloth mesh has around 7.2k vertices and 12k triangles. The simulation took around 25min for 2000 frames. The second half of simulation took much longer time than the first half because there were lots of self-collisions. The simulation time could be much shorter if self-collision iteration is set less number.

I will be working on multi-core supporting probably using TBB and expand it to CUDA later. Self-collision time can be reduced if global treatment is done. I am working on it too.

I will post more videos and result as I’m progressing.

Thank you.


#4

Collision-free subdivision is in progress as well. The mesh in the video was using Maya’s mesh smoothing and it can generate collisions.


#5

post more, this is interesting!


#6

Looks great!

Can you elaborate on the benefits of your integration scheme, especially as compared to something dead-simple like Verlet?


#7

Thanks kiaran.

The benefit of implicit euler integration over any explicit method is that it is much stable and allows a longer time step. Verlet or RK4 is higher order and more stable than 1st order euler method but still their stability is more sensitive to time step.

Implicit method needs to solve large linear equation. So it takes more time to compute. In non-realtime simulation, it is still beneficial than explicit method because of larger timestep. In realtime simulation i.e. games, I believe verlet, RK4 or symplectic would be better with low stiffness and some damping. There is hybrid method calling semi-implicit method but I don’t see much gain from it though.

In my simulation, I have not added any damping and spring constant is quite high. Using explicit method, the timestep should have been much smaller.

I am not sure any commercial realtime physics engine uses implicit method. I have looked Bullet and it seems like using 1st order explicit euler method.

Thanks.


#8

saggita - Sounds good. I’ve created cloth simulations using Verlet integration and found that while the stability was great, it gave the cloth a rubbery feel as the springs took several frames to return to rest length.

It would be a really interesting experiment to have a toggle which switches the integration scheme on the fly so you can see how it affects the behavior of the cloth. But I’m sure there are plenty of toy-features to add before spending time on this…

Couple more questions:

  1. For the CCD, do you create a line segment for each vertex trajectory and then test that against each face in the collision geometry? Do you use the BVH to reduce the number of triangles to test?

  2. Care to elaborate on how you handle self-collision? Is this where the BVH is used? I’ve never been able to grok this and skimming Baraff’s papers only confused me further.

I would love to collaborate. Would you consider hosting this on Google code and making this an open source project? We could all learn a TON from this.


#9

I have seen similar problems. I guess the spring constant and mass are too low. Also adding a little damping might alleviate it. Cloth simulation is quite sensitive to setting like spring constant, damping, mass and gravity. A small change makes things quite different.

Currently my implicit integrator is 2nd order accurate in space. I am planning to implement BDF so that it can be 2nd order accurate in time too. It will be interesting to compare different integration schemes and visual result. It is planned to make a maya plug-in so comparison can be visualized easily.

For the CCD, I am following the paper linked below.

http://graphics.stanford.edu/papers/cloth-sig02/

Yes for BVH.

Both self-collision and cloth-to-object collision use BVH as a broad phase collision detection. My BVH uses AABB as bounding volume. Below link will be a good reference.

http://gamma.cs.unc.edu/DEFORMCD/

Sorry. I am current doing some personal research on global collision treatment for deformable object. There are several researches out there but none of them seems to give me a good result. So I am developing my own approach now. Also I have a great idea to make the simulator faster than existing ones. So there is no plan to be open source project. However I am looking for one or two co-developers who have expertises on Maya/Houdini plug-in programming and c++. I am also quite interested in fluid simulation so the project will be quite exciting. Below is a link to my thesis just in case.

FLUID SIMULATION IN TETRAHEDRAL MESH USING HYBRID METHOD


#10

New video is posted in link below.

http://www.youtube.com/watch?v=Q3sxamRYkcA


#11

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.