Log In  

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)

absolutly stunning

P#87049 2021-02-01 00:41

That is absolutely incredible. I would like to try to implement the cloth physics for the grid background of my game. If I mention you in the code and in the description of the game, would it be ok?

P#95217 2021-07-23 19:10 ( Edited 2021-07-24 02:26)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-04-19 12:49:41 | 0.011s | Q:20