Page 3 of 4

Re: My explicit euler cloth code

Posted: Mon Jul 25, 2011 1:44 pm
by mobeen
DevO wrote: This should be 3 point constrain only.
The only tricky part is actually properly creating this constrains.
The should be just like distance constrains that are used to replace bending constrains but are using middle point too.

Code: Select all

0-----1-----2
|     |     |
3-----4-----5
|     |     |
6-----7-----8
In this simple case you should have 6 bend constrains.
C(0,1,2), C(3,4,5), C(6,7,8), C(0,3,6), C(1,4,7), C(2,5,8).
Oh I just saw fig.4 and its explanation. Doing that way, I think I could just add in the constraint like this

Code: Select all

for(int j=0;j<numY;j++) {
   for(int i=0;i<numX;i++) {
      AddBendingConstraint(i+(j*numX), i+((j+1)*numX), i+((j+2)*numX), kBend);
      AddBendingConstraint(j+(i*numY), j+((i+1)*numY), j+((i+2)*numY), kBend);
   }
}
and i think this should do it. I will do this tomorrow hopefully. I have already commited teh current version though.

Re: My explicit euler cloth code

Posted: Mon Jul 25, 2011 1:53 pm
by DevO
I dont get this, are u talking about this http://image.diku.dk/kenny/download/kel ... e.ea10.pdf.
Yes I am talking about this paper.
Please lock at page 5 to Figure 6: algorithm create-bending-constraints and read
4.1. Working with Triangle Meshes.

The constrain should not for an triangle that you have in the mesh.

Code: Select all

//add vertical constraints
for(int j=0;j<numY-2;j++) {
   for(int i=0;i<numX;i++) {
      AddBendingConstraint(i+(j*numX), i+((j+1)*numX), i+((j+2)*numX), kBend);
   }
}
//add horizontal constraints
for(int j=0;j<numY;j++) {
   for(int i=0;i<numX-2;i++) {
      AddBendingConstraint(i+(j*numX), (i+1)+(j*numX), (i+2)+(j*numX), kBend);
   }
}
Something like this should work.

Re: My explicit euler cloth code

Posted: Mon Jul 25, 2011 1:57 pm
by mobeen
Oh ok thanks for that.
One more thing, you didnt tell me how i should refer you in the code.
I have just written special thanks to DevO for his help. Do u want to add in your real name and affiliation?

Re: My explicit euler cloth code

Posted: Tue Jul 26, 2011 2:37 am
by mobeen
Ok done. I have committed the final pbd version. You can checkout from svn.

One more thing, if I were to extend it to 3d meshes, how do i create the constraints? I think i would have to create a tetrahedral mesh first and then assign distance constraints to the three shared edge (p2p3, p0p3 and p1p3) and one bend constraint(p2p1) assuming the base of the tetrahedron is p0p1p2 and p3 is the apex vertex as given in the following figure,

Code: Select all

       + (p3)
      /|\
(p2) +-|-+(p1)
      \|/
       +(p0)
Is this how pdb is setup for softbodies?

Another thing I want to ask is how to do simple linear FEM for softbodies? Do u have any idea or reference which might help?

Re: My explicit euler cloth code

Posted: Tue Jul 26, 2011 3:03 am
by Dirk Gregorius
On FEM you might want to start here: http://www.matthiasmueller.info/publications/GI2004.pdf

I found this course awesome since it approaches FEM from the Direct Stiffness Method and Variational perspective. This is very advanced though:
http://www.colorado.edu/engineering/CAS ... .d/IFEM.d/

Re: My explicit euler cloth code

Posted: Tue Jul 26, 2011 3:08 am
by mobeen
Thanks Dirk for the links. I will surely have a look through these.

On the side note, have u checked out our pbd implementation? Any comments on it?

Re: My explicit euler cloth code

Posted: Tue Jul 26, 2011 1:09 pm
by DevO
Hi,
please lock at this version.
I just wanted to test one idea regarding float precision and summation.

Re: My explicit euler cloth code

Posted: Tue Jul 26, 2011 3:03 pm
by mobeen
Hi DevO.
THanks for the KahanSum stuff. I will run it on my system first thing tomorrow morning. By the way, could u elaborate a bit more on this as this is quite new for me. I assume it is something to do with the floating point inaccuracies during summations however I m not sure. An expert advice would be interesting.

Apart from this, is the pbd implementation (the latest svn one) correct.

Another thing, what about using pbd for soft bodies any ideas how to go about it?

Re: My explicit euler cloth code

Posted: Tue Jul 26, 2011 3:08 pm
by Dirk Gregorius
Here is a possible way how to use PBD to do softbodies:
http://www.matthiasmueller.info/publica ... ticles.pdf

Re: My explicit euler cloth code

Posted: Tue Jul 26, 2011 3:10 pm
by mobeen
Thanks Dirk for this.

Re: My explicit euler cloth code

Posted: Wed Jul 27, 2011 4:15 am
by mobeen
WOW, using KahanSum the behaviour is more accurate as compared to not using the KahanSum.
DevO I am grateful to you for pointing this out. I didnt know about this and the errors numerical inprecision generates. Thanks man.

Re: My explicit euler cloth code

Posted: Wed Jul 27, 2011 3:12 pm
by Dirk Gregorius
Can you elaborate a bit more about the KahanSum and where you added it to the PDB algorithm - maybe a simple example? I will look at the code after this, but it might be nice to discuss this in isolation. I looked at Wikipedia and it seems to deal with Cancelation problems. Good stuff DevO :)

Re: My explicit euler cloth code

Posted: Wed Jul 27, 2011 9:21 pm
by Erwin Coumans
Thanks for sharing these cloth implementations, it will be helpful.

For FEM, you can also buy the 'Game Physics Pearls' book, and check out chapter 10.

I recently extracted the corotational linear fem implementation from OpenTissue (removed BOOST and only use the necessary code) here:
https://github.com/erwincoumans/experiments (there is a Download button) and check out the dynamics/corotational_fem folder.
You can build it under Windows using Visual Studio 2008/2010 by clicking on the build/msvc2008.bat batchfile and open the new folder.
fem_gwen.png
I plan to add some collision detection to it. You could use it to simulate cloth as well (thick cloth of a single layer of tetrahedra)
Cheers,
Erwin

Re: My explicit euler cloth code

Posted: Thu Jul 28, 2011 1:51 am
by mobeen
WOW. Thanks Erwin for this. I would surely have a look through those resources.

Thanks,
Mobeen

Re: My explicit euler cloth code

Posted: Tue Aug 16, 2011 7:04 pm
by saggita
Just my 2 cents about Explicit method..

1. The force between two points are not constant even during the discrete time step. We already know that the force is changing as a result of moving points. The good thing is that we can compute how much the force will change during the time step. Unfortunately it is a function of point velocity and we don't know this until we integrate! So those two information (force change rate and point velocities) are strongly coupled together. That is why we need to solve a linear equation in implicit method.

2. If one point is moving towards the other point, we know that the force change rate is a vector with the same direction of the two points. However, if the point is moving perpendicular to the line of two points, there is still change of force. In this case, the force change rate is dependent on the point velocity direction but not the same direction. So the force change rate is always vector and the relationship with point introduces some 3x3 matrix which is Jacobian matrix. For real-time simulation, we can ignore the perpendicular case, then the Jocobian matrix is no longer needed because the force change rate will be always the same direction as the line of two points. This makes it possible to implement implicit integration without solving linear equation. Below paper explains this concept.

http://www.multires.caltech.edu/pubs/GI99.pdf