Technical Overview - GabrieleGiuseppini/Floating-Sandbox GitHub Wiki

Still busy writing this page. I'll expand it and go into details soon!

This game is a C++ implementation of a particular class of particle systems, namely a mass-spring-damper network. With a mass-spring-damper network it is possible to simulate a rigid body by decomposing it into a number of infinitesimal particles ("points"), which are linked to each other via spring-damper pairs. Springs help maintain the rigidity of the body, while dampers are mostly to maintain the numerical stability of the system.

At any given moment, the forces acting on a point are:

  • Spring forces, proportional to the elongation of the spring (Hooke's law) and thus to the positions of the two endpoints
  • Damper forces, proportional to the relative velocity of the endpoints of the spring and thus to the velocity of the two endpoints
  • Gravity and buoyance forces, proportional to the mass and "wetness" of the points
  • Forces deriving from the interactions with the user, who can apply radial or angular forces, generate explosions, and so on

Water that enters the body moves following gravitation and pressure gradients, and it adds to the mass of each "wet" point rendering parts of the body heavier.

Bodies are loaded from png images; each pixel in the image becomes a point in the simulated world, and springs connect each point to all of its neighbours. The color of the pixel in the original image determines the material of the corresponding point, based on a dictionary containing tens of materials; the material of a point in turn determines the physical properties of the point (e.g. mass, water permeability, electrical conductivity) and of the springs attached to it (e.g. stiffness, strength).

An optional texture map may be applied on top of the body, which will be drawn according to a tessellation of the network of points.

Users can interact with a body in different ways:

  • Break parts of the body
  • Slice the body in pieces
  • Apply radial forces and angular forces
  • Deploy timer bombs and remotely-controlled bombs
  • Pin individual points of the body so that their position (and velocity) become frozen