Wednesday, November 25, 2009

The updated movie

I made a few tweaks and corrections to the cloth simulation to make it look without too many glitches..




Have people telling me the video doesnt load so in case it didnt load feel free to watch it here
http://www.youtube.com/watch?v=OBKZQHa_K-Q&feature=player_embedded

First out

Nothing fancy yet.. But ya the first working preview of the cloth simulator after 5 days into the project. Well what happens is the cloth interacts with a sphere and the ground and moves due to forward euler integration.

In computer animation terms integration is the way to do the physics simulation. It basically defines at every point of time where the object will lie ...



Ok what changes have I done since the last commit

revno: 12
committer: sundar
branch nick: qtClothSImulation
timestamp: Wed 2009-11-25 14:48:28 +0000
message:
Got the Basic system to work...I implemented the same algorithm which was implemented earlier..but then made a bit of modificaitons to the collision detection routine... Also i have implemented the whole RK4 integrator but i need to do a bit of modifications to get it to work..The thing what got it to perforrm like a cloth was the jacobian relaxation method which iterates through every vertice and for every vertice finds the force required eep the distance between the two vertices constant. By iterating it over a fixed number of times we can get the cloth to behave .


First off I was rendering out my cloth as quads.. The problem with using quads is that it doesn't really work too well with stretching and bending ..



That gives how a triangulated mess will react to bending and stretching and with quad based meshes it is hard to get the desired visual quality.

Doing a triangulated mesh from a quad based mesh is not that hard .. it is basically rearrangement of vertices .


Once I converted my thing into triangulated meshes I went on to do the jacobian part. What really happens when you dont do the relaxation is exhibited in the video



How does jacobian relaxation work? Forces to keep the point at a proper distance are inhibited in 3 different ways on every point. Along the horizontal , vertical and the diagonal.

Algorithm:

For evrypoint identify the point closest to it on the horizontal,vertal and diagonal.
Identify if the point is on the extreme if so whether it loses a horizontal/vertical/diagonal member
Once this is done loop through all the points and for every point
Calculate Horizontal force by
-> Choose the neighbouring point
-> Calculate delta which is the difference between the position of the neighbouring point and the current point
-> a jacobian factor given by delta = [(xj - xi) * strutLength^2 / (|(xj - xi)|^2 + strutLenth^2)] - 1/2 is calculated
where xi and xj are the two neighbouring points
strutlength is the original length between the two points
xi -= delta xj+= delta
Repeat this or the vertical and the diagonal force acting

I am currently working on porting the integration to a more calculation correct RK4 integrator and might come up with a post real soon ...


Reference :

http://www.teknikus.dk/tj/gdc2001.htm