The Daily Click ::. Downloads ::. Engine ::. Verlet Chain Example
 

Verlet Chain Example
Author: Pixelthief Submitted: 21st October, 2007 Favourites:0
Genre: Engine Downloads: 679
Rated:


Edited By Pixelthief on 10/21/2007

Just a very simple example of verlet integration; Used on nodes of a chain, it creates very realistic chain physics. Likewise, if the concept it applied further, it can be used for very good ragdoll-esque physics. Sadly, TGF/MMF's lack of defined functions makes this absurdly more difficult then it should be, so I simply showed how it can be applied to distinct nodes of a chain.

My code is fairly obfuscated, but if you want to understand how it works, I advise this reading:
http://en.wikipedia.org/wiki/Verlet_integration

Left-Click positions smiley
Right-Click makes smiley poop a new node

The Zip file includes both a compiled .exe file, and an opensource TGF file, which requires Advanced Math Object, Fastloop, and 1000 Global Values object (all included in the folder)

Review This Download



 


http://claniraq.googlepages.com/Verlet.zip (270 kkb )



Posted by DaVince 21st October, 2007

What's with the burping sounds when I add pieces to the chain?

Not bad, still feels a bit unrealistic/buggy when the smiley is pulling the chain towards it. Dropping the chain and swinging it looks nice, though.
 
Posted by Pixelthief 21st October, 2007

Oh hey, its a little clippy because it adds the pulling effect of the chain on the smiley to its position every frame, AFTER it sets its position to the cursor. So it drags it just a little bit to the side. You can simply put the "set position to XMouse * 1000" event to the bottom of the event list, to make it smoother.
 
Posted by Aptennap 22nd October, 2007

Well, great job creating it.
 
Posted by Guru Rinpoche 22nd October, 2007

Awesome! My mind is blown.
 
Posted by Pixelthief 23rd October, 2007

While I make it look a little confusing in the code; the actual verlet integration is extremely simple.

Instead of using:
Pos(x+1) = Pos(x) + 1 * velocity
and
velocity = velocity + 1 * acceleration

You use:
Pos(x+1) = Pos(x) + (Pos(x) - Pos(x-1)) + acceleration


Because the constraints actively pull on the object, collision will naturally occur if a node hits a barrier; hence you can throw a wireframe model at a side, and with no other actions then saying (if x > 500, set x to 500), it will handle the collision on its own.

However, it will not do such as physics would dictate, with frictions, nor will it work if the object has only a single node (nothing to pull on it means it cannot bounce)
 
Posted by MBK 9th February, 2008
Rated :

Ok, this is kewl, but i'm a moron, so math is not my strong suit
 
Posted by Airflow 14th March, 2008
Rated :

awesome!
 
Posted by Assault Andy 6th June, 2009
Rated :

Awesome use of maths.
 

 



Author

Favourite



Advertisement

Worth A Click