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

Ok my MID - Day post

Things going on well so far. Did the UI for the cloth. Amazingly the cloth ui worked without major jiffy and creating a flutter. i am pleased with how the fibre - blend ui works. Though i need to change the heading hehehhe

revno: 6
committer: sundar@animcentral
branch nick: qtClothSImulation
timestamp: Sat 2009-11-21 11:37:30 +0000
message:
Ok great my target to start for today is going good.. got the ui for the cloth working .. Now can do all the setting for both the sphere and the cloth from the ui.. Pretty much the options include the wireframe thingie normals and drawing debug points. BUG:: Normals and DbGpoints dont consider the excluded regions so as not to calculate the normals every time but then again it is necessary and hence code need to be modified there



Well one problem i faced was the normal part which for some reason didnt really accept the points with the normal was added but well all good and things work fine as of now so well fingers crossed as i enter the simulation part ..heheh

Goood Morning fellas

new day today. Nice and bright a bit cloudy but well slept late again. Come on folks it is a saturday but well i made the first commit of today.. shooosh i havent started to work today jus committing yesterdays work

revno: 5
committer: sundar@animcentral
branch nick: qtClothSImulation
timestamp: Sat 2009-11-21 09:58:50 +0000
message:
Did a few good things.. First off created the cloth. A little algorithm to allocated teh grid of the cloth and well it basically create quads joining the points calculate normals and well the grid from the cloth works perfectly now . Also found this nice way of allocating and de allocating a array instead of using a dynamically sized vector. I dont know which is faster though .. let me do some checks and see... TOdo:: create the gui linking for the cloth and should be starting off on the actual cloth simulation



Oh ya lets move the cloth today !!!

Friday, November 20, 2009

commit 4 of today

Ok so far so good.. things progressing well and working just the way i want it to work.. got the camera working

revno: 4
committer: sundar@animcentral
branch nick: qtClothSImulation
timestamp: Fri 2009-11-20 16:23:35 +0000
message:
There u go some more advances to the ui.. i never change do i.. hehhehe .. ok got the cam working from the ui.. now that the base is done lets finally start with the cloth



TODO at some point of time will have to remove the necessity of using jons camera class... that camera class is something i have really never worked upon ... hmmm well anyways this will do for now off to doing cloth simulations yayyy and someone whack up my mind to commit regularly coz anything can go wrong anywhere laughs

ooo wait the user interface pics




Hmm how can i not paste it after working on it hehehehe here it goes

oooo Making progress

Laughs!!!!


Peter spoiled me.. His words that first aim at the user interface corrupted me.. been working on the user interface for 3 hrs now.. ehmmm dont tell but been a bit longer than that..... hhehehe ok fine i did something to show off so all is good.. aint it ....

revno: 3
committer: sundar@animcentral
branch nick: qtClothSImulation
timestamp: Fri 2009-11-20 13:07:23 +0000
message:
ok what did i do.. well created and rectified the sphere class which now allows for all parameters varied from the qt interface.. now gonna see if i can work on the cloth part. TOdo:: the wireframe bit which can wait till last . Oh the interface modifications which can wait as well..



There is the revision history if you want to know what happened... well right now i got a over exposed sphere on screen but well it looks cool so no worries ... hehehehehe


rest in next and will be pretty soon

ok did my next commit

revno: 2
committer: sundar@animcentral
branch nick: qtClothSImulation
timestamp: Fri 2009-11-20 08:50:19 +0000
message:
Added The sphere to primitives. Works on the basis of generating a cos sin table which basically plots circles all through the length and the breath to create intersection points. Once this is done we make quads between the intersection points .


Oh ya it is pretty much mentioned in the commit message . Oh i came across this funky piece of bazaar script i had writtern in the past to do the commits. Well seems i am pretty lazy after all chuckles....

It basically does my doxygen running and stuff.. Oh my run script wrote that as well..

not a big one but pfffft scripts are meant to be small hehehe

#!/bin/bash
clear

for search in *release/ClothDemo*;
do
if [ -f "$search" ]
then
echo "Removing Previous Instance**"
rm -f $search
fi
done

echo "Running QMAKE "
qmake
echo " done ..... "
echo " "
echo "Running make files "
make
echo " done ..... "
echo " "
echo " Executing Codes "
echo " "
cd release
./ClothDemo
cd ..




there does nothing really doesit hahahhahahaha just runs qmake and make oh the reason i am a lazy ass and dont feel like going into folders .... lol

ok what i write here

Well a little blog for me to keep track of what I do over the next week so that i know exactly where and how i went wrong and how i managed to fix it.Will put up code snippet. Any one is free to give out their free comments on the codes..

revno: 1
committer: sundar@animcentral
branch nick: qtClothSImulation
timestamp: Thu 2009-11-19 22:11:09 +0000
message:
Blank commit of 3d library interface with qt


yuuus that is what i have done so far.. integrated my library with the QT so that my library works with it. will be putting regular updates. dont check the timing it will be random.. lol