PDA

View Full Version : String Physics



Nitrogen
20-07-2006, 09:38 AM
I've just updated my website with a physics 'sandbox' I made using one of my favorite algorithms: springs...

Springs let you do amazing things with relatively very simple algorithms (such as simulating mass, inertia and a center of gravity)

http://www.sulaco.co.za/nitrogen/projectinfo.asp?id=29

It lets you create vertexes and link them together to form boxes or ropes (in 2D) then you press play and you can drag the vertexes around under gravity...
If you drag too hard your creation will break under the impact.

It's pretty stable but still not time independent. Something about the way I set out the code makes it stubbornly resist a time-varying physics 'tick'.

Traveler
20-07-2006, 10:37 AM
An excellent demo! It reminds me a lot of www.sodaplay.com/ (http://www.sodaplay.com/). Did you get the inspiration from that site or have you used an other source? Nevertheless, its nice work.

One odd thing I noticed is that when you modify the timescale repeatedly within a session (up until you press the reset button again), the model starts to move faster and faster. Even when you turn it back down again.

Relfos
20-07-2006, 12:49 PM
Hi Nitrogen!
I found the spring demos in your site, and after reading it I started implementing something similar into my 3d engine.
The class I implemented its now capable of creating a spring system from a arbitrary mesh, and apply gravity and wind forces.
I found some problems in my implementation, for example, if the wind/gravity force is too big, the flag starts to stretch to insanely huge distances! However, if I change the spring cofficient, this solves the problem, but the flag starts shaking, not good :roll:
The temporary solution I found its to normalize the external forces before adding them to the particles force.
Next step is to add colision support, so I can apply this system to characters hair and the hair doesn't go through their bodies.

This gif animation is really bad, too many frameskips, the original is way better :wink:
http://img89.imageshack.us/img89/5912/tugapodflagyu4.gif

Nitrogen
20-07-2006, 02:53 PM
Thanks guys, yea it is one way or another based on the Sodaplay dynamic..

Back when I was still into VB, I found a Sodaplay replica built in VB called Botz. I was so amazed by this program that I pulled it apart piece by piece to see how they did it... Eventually I added terrain and tried a 3D version and many others (like my cloth sim) but this is the first time I did it from scratch from the ground up...

Yea you will find many bugs with it. Especially with the time scale control (I only implemented that last night!)