Bouncy strings

Ever since Visionary Render gained the ability to easily render 3D connected splines they have been crying out for some kind of bouncy, flexible simulation. 

This gem is bouncy strings implemented in Visionary Render using the 3D spline and only Lua script.

This can be used to add a little more interactive realism to scenes, the stiffness of the springs can be increased allowing it to make almost passable cables.

Hopefully this will act as a spring board for inspiration and further development.


The main code is this simple psuedo physics code.

function SpringImpulse(pntA, pntB, unstretchedDistance)
  local grav = vrVec3(0, -0.03, 0)
  local springVec = (pntA - pntB)
  local distance = vrLength(springVec)
  local force = (distance - unstretchedDistance) / unstretchedDistance
  springVec = springVec * (1.0/distance)  local forceVec = springVec * force;
  forceVec = grav + forceVec * __TimeDelta * 20.0
  return forceVec 

Using this the impulse for each knot in the spline can be calculated and applied. More complex springy networks can be acheived by integrating the impulse contributions in different ways. Considering mass would make the effect superior.

It actually works best without gravity which might be appropriate in some situations, such as underwater.

Tom is the author of this solution article.

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.