chain simulator: can you do it?

Community Forums/Showcase/chain simulator: can you do it?

Najdorf(Posted 2005) [#1]
I made this "chain simulator" some time ago...

http://radicalrebound.com/chain.exe

i.e. there are a bunch of balls linked one to each other, and you can grab one (clicking the mouse) moving all the chain.

It uses a really neat trick to do the physics (which otherwise are really a mess), the code is 280 lines.

I'm not giving the code away yet: can you do something similar?


Bot Builder(Posted 2005) [#2]
Sure. Its easy. Physics isnt a mess at all. All you need to do this is an integrator and a constraint system. I'm suprised it took as much as 280 lines. Especially since the balls dont even have collisions. and its 2d...

The only time physics is a mess is when you factor in stuff like relativity, quantum mechanics, and string theory.

Started coding this 4:40 PM (now its 5:20 PM) so, a 40 minute job



This system can actually mimic any physical structure in 2 dimensions. Just 94 lines. I would add ball-ball collision, but im too lazy, and have only met your challenge. Done this before in 3d, and it was pretty simple. Same stuff actually except for collisions.


Najdorf(Posted 2005) [#3]
wow.

I thought I was pretty smart to get the algorithm, but looks that everybody knows it... you move the balls as if there was no link then you get them back together in various iterations, right? its a neat trick, I thought I had invented haha.

yeah, its 280 lines because I skip a line between two lines and I added some stuff that is commented and I put some code to change the colors :P

oh, since youre there you might also check out this one, its good enough

http://radicalrebound.com/particles.zip

I'm sure you can do this one :P


Bot Builder(Posted 2005) [#4]
Yeah, this method is usually used in any game where you see ragdolls. It is also used in alot of rigid body systems, at least as a base, since fairly complex collision algorithms for affecting individual points must be invoked. 2d is a really nice place to do physics, once you get to 3d, the collisiosn stuff gets yah :) not impossible but alot harder than 2d.

Anyway, yah, thats pretty cool. I could probably make it, but since we have the allegro version there's not too much point.


Najdorf(Posted 2005) [#5]
lol

you were-are in the allegro forums too? I quit using allegro (not that I used it much, I made that thing only!), I bought blitzmax, very cool.

I'd like to do a 2d beatem-up where characters are made of balls, but I never get the time. I stopped at the chain thing haha...

yeah, I guess in 3D its a mess but I just love 2D. Moreover I have never seen a 2d beatemup using ragdoll. I guess its a matter of applying strength to keep the "human chain" from collapsing and making it move. but it should be cool.

just have to find some time...


Bot Builder(Posted 2005) [#6]
Nah, I just recognize the dll.

Yeah, 2d ragdoll would be cool. It'd have to be semi-3d though or else it wouldnt work.


Bouncer(Posted 2005) [#7]
Najdorf: Somebody got that idea first ;)
http://www.lionhead.com/personal/mhealey/index.html


Najdorf(Posted 2005) [#8]
thats awesome. I'll keep it simpler though.