2D Constraint based rope

Constraint based rope simulation

Constraint based rope simulation

So I was looking into some cool stuff to do with my 3D engine when I came across this. I’ve always been a fan of physics simulation based realism so I began to work this out in 2D. The first demo was using elastic constraints between particles but that made a very instable system. It can be improved with better integrators like RK4 but that still didn’t result in the desired result. I might have other plans for these elastic constraints later though. You can read more about elastic constraints here [Gaffer's tutorial on spring physics] and here [Gamasutra's "Exploring spring models"]. So I went on with inelastic infinitely ’stiff’ constraints which were mentioned in this ["Advanced Character Physics" by Thomas Jakobsen] great resource on computer physics simulation. The result worked out pretty well and will be easy to port to 3D. Which will happen when I’m done with a little (very interesting) side project using the same code. More about that later… Check out the working demo after the ‘Continue Reading’ link.

Below is the working simulation, use your mouse to move the rope. The simulation uses quite a lightweight rope with little friction. Combinations of elastic and inelastic constraints can be used to simulate a lot of different interesting stuff like pudding, crashing cars, stresses on buildings and cloth. Expect more examples soon.

Download source code

Comments (19) Trackbacks (4)
  1. DeltaFrog
    10:59 pm on March 14th, 2009

    Any chance on seeing a source file? :)

    • admin
      10:53 am on March 15th, 2009

      Mailed it to you, as soon as I get a good way to view source code on here I’ll post it for everyone.

  2. k
    1:26 pm on March 19th, 2009

    Could i see the source files as well?

    • admin
      3:17 pm on March 19th, 2009

      Mailed it to you, again, as soon as I get a good way to view source code on here I’ll post it for everyone…

  3. Bouldo
    4:39 am on March 20th, 2009

    Hi mate,
    trying to do a rope simulator would love to see your source, would be super helpful.

    • admin
      11:48 am on March 20th, 2009

      Wow lots of interest in the source code! Didn’t even know people wanted it.. Soon I’ll write some more in depth details about the rope simulator and maybe you guys can even help me with a problem! ;)

  4. KevinW
    8:09 am on April 4th, 2009

    Hey, I’d love to take a look at your source if you don’t mind. I’ve been trying to make a chain simulator and keep getting stuck.

  5. Ymer
    8:10 pm on April 7th, 2009

    Hi! I would love to see the source as well!

  6. BryanW
    6:47 pm on April 11th, 2009

    I also would like to see your source, i have been trying to get something like this working in xna and reallt need some help

  7. Vijaya
    1:39 pm on April 13th, 2009

    Hi! Can I see the source code too?!

  8. Tim
    8:25 pm on April 17th, 2009

    I’d love to take a look at the source too please. Trying to create a free flowing necklace, changing the beads and links.

  9. F.G
    3:28 pm on April 23rd, 2009

    Its so great!! Could i see the source code please?

  10. Steven
    1:32 pm on May 20th, 2009

    Could you mail me the source code plz,

    Very nice work

  11. zap
    9:01 am on June 9th, 2009

    the source?

  12. Erik
    7:55 pm on June 22nd, 2009

    Could you please just dump the source unformatted here as there seems to be many people interested in it (including myself).

  13. JF
    8:50 am on June 29th, 2009

    I am curious to know how you got rid of the ’springiness’ factor in doing spring models, when I attempted to make a simulated rope I just got something that felt like a bungee cord,

    Even after tweaking constants, I think I am missing a key concept, so I will get in line and also request a peek at the source code.. namely your choice in constants

  14. Tim
    2:32 pm on July 1st, 2009

    I’d love it too if you could e-mail me the source as I’m trying to do a rope sim in AS 2.

    Why not post a link to a zip file in the wordpress entry?

  15. admin
    12:26 pm on July 19th, 2009

    I’m sorry for keeping some of you guys waiting, but had some problems approving the comments, added a download link for the source code now…

Sorry, the comment form is closed at this time.