Thursday, November 26, 2009

yay the video with the wind applied

Well just recorded a video to show how wind affects the cloth..


Alternate you tube link :: http://www.youtube.com/watch?v=MLmcVXymPKQ

Wind implemented

So well what happened... well nothing much but i implemented wind .. sortta... well wind is basically a force acting on each of the triangle on the cloth.

Our cloth is nothing but a array of point interconnected by quads or triangles.. to calcuate the force acting due to the wind what we need to do is to really pick each and every quad or triangle and find the resultant force on it.

For finding out forces due to wind we usually consider a triangle. Since I already have a triangulated mesh it was easy. each quad is split into two triangles. So basically it was a check of whether the point lies in the edge and if it did then move on or continue to split..


once we get the triangle we find the normal to each triangle. Normal to each triangle is formed by the cross product of the two vectors connecting the three vertices together.

Then we implement this formula :

resultant force = Normal * (Dot (Normal,wind))

Dot is the dot product of the vector..

once this is done the resultant force is added to all the vertices constituting the triangle and the the final resultant is added to the force vector which affects the motion.

revno: 14
committer: sundar
branch nick: qtClothSImulation
timestamp: Thu 2009-11-26 10:49:29 +0000
message:
"Implemented the wind in the simulation.. wind forces are achieved by acquiring the resultant vector of the normal and the wind force for each of the triangle.. the model implemented is nt the best considerig the wind doesnt interact rather it inhibits a force on the cloth. the movement of the cloth in no way affects the wind force. so it is a one way force acting upon it... also changed a bit of ui. .added a few options in the additional parm tab.. .so well looks cool


So ya that is my 14th revision yayys

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

Tuesday, November 24, 2009

1 day of system fixing

Ok whole day what happened...

i woke up and well started off with a little bit of cloth simulation and well I had to go the university. I decide to take a trip to uni and hibernate my linux and go and come back i get a frozen screen.

I restart the system and boom Linux is gone.. down ... dead...

It gave me this


GRUB4DOS 0.4.4 2008-10-27, MEMORY: 639K / 478M, CodeEnd: 0x42910
[Minimal BASH-like line editing is supported. For the first word, TAB
lists possible command completions. Anywhere else TAB lists the possible
completions of a device/filename. ESC at any time exits.]

grub>


It allows only very little access to the whole of linux and absolutely no access to the filesystem what so ever . So the whole day was spent in solving this.

What had happened:
Linux can be installed in different ways. One of the type of linux is called the WUBI linux which is nothing but installing linux inside of windows vista instead of partioning a space for linux on its own .My system apparantly ran a wubi mode of linux. So for some reason during the hibernation process the NTFS file system which is the file system governing the Windows partitioning of the system got corrupted and I never managed to figure it out. Online research stated that it might be due to different reasons even power failures. But any ways the NTFS file system on partition sda2 of my system got corrupted and which basically means linux was gone .. poooof....

So what then:
I came back and well i got the grub prompt and started off with my research into the topic. So apparantly wubi version of linux is highly unstable and as someone quoted "it is like building a house on shifting sands" . Wubi version of linux is like a software installed inside vista but the only difference being it is not a software but a whole operating system inside of vista and well i personally dont have toog good opinion on vista.

So first off i found that i need a liveCD version of linux. LiveCD is the type of linux which is downloaded as a iso file and extracted and writtern on a disk.

So what is a iso file::

ISO files are special formats which are used to write contents onto a disk . but unlike normal files iso files cannot be dragged dropped into the cd. Rather it needs to be extracted and writtern on disk. To do this what we need some softwares to extract the iso images to the proper files...

https://help.ubuntu.com/community/BurningIsoHowto gives u a bit of introduction to iso images
http://www.ubuntu.com/getubuntu/download gives you the iso file of linux

What you do is download the iso file and then use the softwares like iso burner to burn it to a disk or dvd. Problem wouldnt burn or me because the disk were used also only one softwares allowed burning dvd.
But i managed it..


so i put my livecd disk on my system and restart it and well choose the "run linux without changes to my computer" option .What it does is it lets you run linux from the cd without installation. But since it is run from another media it is mightily slow... and well anything you do is not saved and you cant install pluggins and software.. basically a highly restricted freedom.

If that doesn't change anything, how about downloading the Boot Info Script to your Ubuntu desktop from http://sourceforge.net/projects/bootinfoscript/ , open a terminal (Applications > Accessories > Terminal) and do:

sudo bash ~/Desktop/boot_info_script*.sh



This will create a file called sudo bash Results.txt which can probably help you with the problem. It did to me atleast..

In a wubi version of the linux "root.disk" is the file which is stored in the windows which contains the entire file system of linux. Approximately the size of the data you had stored ..
When i did a search for the file system i could nt locate the .disk file at all.. What had happened I have no clue but all i know is the file was missing .. In fact the entire folder was missing...


So when i tried to recover using the following steps:

sudo fdisk -l
sudo mkdir /win
sudo mount /dev/sdxy /win
sudo mkdir /vdisk
sudo mount -o loop /win/ubuntu/disks/root.disk /vdisk



it executed step 1 2 3 and 4 but the virtual disk couldnt execute the 5th line and mount the file system because the file didnt exist.

I also came to understand that if the file is lost the file system is lost as in any of the files in the old linux become un recoverable..Bugged I searched more .. What happened is windows occasionally moves the file for no reason .. lol.. and well it had been moved..

One of the suggestion i saw was that the anti virus software decided it is a bad file and quarentied it ... checking anti virus logs helps as well

sudo fsck /win/ubuntu/disks/root.disk

can be used to help sort out the errors interfering with the boot.. well didnt work for me either...

so ran the checkdisk on my windows .. well to do this you log into windows, open a terminal, navigate to the folder where linux is installed and in the folder run this chkdsk /r. Of course you need admin rights.

This will request a restart .. do it ... well it will check the whole file system and give a report.. well happened windows is supposed to move the disk file to a folder in c:/ called found.0000..

When i opened my c:/ and looked for found.0000 i couldnt find the folder and when i used ava find to check my disk for found.0000 i found it and when i openied it .. there it was... emptyness.. no .disk file.. no nothing.. my files were poof....


i went back online searched and found if the files were gone very well your filesystem is gone so forget linux.. convinced i need to do all my years work again i decided to reinstall linux..
but as luck would have it i decided to give it one last try and let my live cd load ...

mounted up my windows and opened my home folder from live cd.. navigated to the /win folder and looked for found.0000/.. apparantly linux folder showed found.0000.. what i found in additon was another folder called found.0001... feeling wierd i opened it and there it was my .disk file .. nice and safe hidden away ....

i grabbed it copied it to the disks folder in ubuntu ... you should have seen me hopping around when i found it



sudo fdisk -l
sudo mkdir /win
sudo mount /dev/sdxy /win
sudo mkdir /vdisk
sudo mount -o loop /win/ubuntu/disks/root.disk /vdisk


did that and well i managed to mount a virtual disk and access the contents of wubi.. yayyyyyyy

wrote this long ass article so that anyone who has the same problem as me need not sit and learn all about online computing for 24 hrs straight

MY ADVICe::

Dont use wubi linux when you can very well do a partioned linux.. makes life easier

Back up , copy ,store else where and do anything to hide and keep copies of what you do


If you have a doubt feel free to ask me .. i think i can find the answer with another few hrs research lol

Sunday, November 22, 2009

Commit 1 of today

Ok seems i lazed out yesterday evening and wow got locked out of my own room for 3 hours.. laughs well sort of didnt have the key to my lock so guess yesterday evening went down the drain. Been lazing around since morning trying to do the collision detection .

First off I got the Qtimers to work . Nothing fancy about it either. When i started off with the cloth collision... I decided to give options. well more for my qt i guesss. .so well wrote a ground class..

well what did i write in the ground class... well basically it is a plane defined in the point normal form..

so something along the lines of

class ground{
vector normal;
point Point_on_plane;
}


and then i found the mathematical equations to find the distance between a point and the plane . well let cut the mathematics short and you know you can find resources on net. try this one (http://mathworld.wolfram.com/Point-PlaneDistance.html )

Well to find the distance between pt plane ax+by+cz+d=0 and point (x0,y0,z0) we basically find a vector betwee nthe point on plane and the point ..


By projecting the vector on the plane and finding magnitude we can find the distance between point and the plane

Vector connect = Point1 - PointonPlane

projectiondistance = | connect.normal | / |normal|

if this value is negative then it is on the side away from the normal and well vice versa.


So every point when it moves checks for crossing the plane and when it does a projection algorithm works to snap the point onto the plane.

Projection of point onto a plane p = q - dist * n ((q is the point to be projected , dist = distance between point and plane and n the normal of the plane ))

so well pretty much good and working so far . also attached is a little video of the progress in 3 days

sorry abt the background noise was recorded in linux heheheh

revno: 7
committer: sundar@animcentral
branch nick: qtClothSImulation
timestamp: Sun 2009-11-22 14:33:25 +0000
message:
Ok great my first step of collision. Collision etween the cloth and a plane.I created a new class called ground wis a plane defined in the point normal form. We can find the distance between a point a plane and as well as the projection. What happens here is that when the cloth simulates at each point it checks for whether the cloth is below or above the plane and when it finds it dropping the plane it projects the point onto the plane. Might as well add a little tolerance value so that the cloth shows little wrinkles or something to that effect.


Saturday, November 21, 2009

Oh and the current cloth ui




There you go something to chew on