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.
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.
[Please log in to post a comment]