Log In  
Follow
aatish
[ :: Read More :: ]

Cart #springphysics-0 | 2020-11-20 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
25

Hi all. I put together a work in progress demo of a simple physics engine that can handle particles connected by springs. This uses a method known as Verlet integration which is stable and efficient, so you can simulate dozens of springs in real time.

The cart includes 4 demos: a pendulum, a string, a cloth, and a deformable rigid body.

The library implements the approach laid out by Thomas Jakobsen in the article Advanced Character Physics. The syntax is inspired by the physics simulation library toxiclibs.

Here's an example of the syntax to create two particles connected by a rigid spring (i.e. a pendulum).

  -- create particles
  p1 = particle(64,10)
  p2 = particle(10,10)
  p1:lock()

  -- create a spring, which takes 4 arguments
  -- particle 1, particle 2, length, stiffness (between 0 and 1)
  s = spring(p1, p2, 50, 0.5)

  -- add gravity
  physics:setforce(0,10)

  -- add particles and spring to the physics world
  physics:addparticle(p1)
  physics:addparticle(p2)
  physics:addspring(s)

I haven't implemented drag, friction, or collisions. But I figured I'd share this as is, in case it's helpful to folks. Feedback welcome.

P#84525 2020-11-20 11:25 ( Edited 2020-11-20 11:27)