Functional API

Context: Dataflow
Node groups: ContinuumScene, ContinuumTriggers, ContinuumSimulation, ContinuumResults, ContinuumExport

This page covers the scene nodes: rigid bodies, cloth and SPH water. The real-time smoke, liquid, particle, ocean and shore nodes are listed on the Physics toolbox page.

In a dataflow graph every Continuum node is a function: it reads only its inputs and returns a new value. A scene is built by threading a SceneDescription through nodes, Simulate turns it into a SimulationResult, and result nodes read meshes, poses and events from it.

1. The contract

  • Immutable values. A node that "adds" something returns a new description and leaves its input untouched. Branch a graph freely: two variations of one scene share everything upstream.
  • Same inputs, same output, bit for bit. Simulate keeps this because the engine is deterministic on any number of threads, so Divooka may cache any node against its inputs.
  • Export nodes write files but are idempotent: the same result writes the same files, and the nodes return the paths written.
  • Divooka types at the boundary. Positions and vectors are Vector3d, orientations Quaterniond, meshes StreamedVertexMeshData, scalars double, counts int, and things in a scene are named by string. All in Divooka's axes, +Z up, SI units.

2. Scene nodes (ContinuumScene)

Scene

Node Inputs (defaults) Returns
NewScene gravity 9.81 m/s², couplingRate 120 Hz, clothSubsteps 15, seed 1 an empty scene, gravity along −Z
SetGravity scene, gravity vector (m/s²) the scene with gravity in any direction
SetWind scene, velocity (m/s), gusts 0 (m/s) the scene with a steady wind that pushes cloth, bodies and water

couplingRate is how often the solvers exchange forces: 120 Hz suits rigid bodies and cloth; use 200 to 480 Hz when light bodies float in water. clothSubsteps is 10 for soft cloth and 15 to 20 for hanging or loaded cloth.

Bodies

Shape nodes make a BodyDescription; AddBody puts it into a scene. Every body needs a unique name.

Node Inputs (defaults) Notes
Ground name "ground", height 0, friction 0.6 an infinite plane, solid below
Box name, size (full extents), position (centre), motion Dynamic, density 1000, friction 0.6, restitution 0.1
Sphere name, radius, position, motion, density, friction, restitution
Cylinder name, radius, length, position, … upright, axis along Z
Capsule name, radius, length (ends included), position, … upright, axis along Z
MeshBody name, mesh, position, motion Static, unitScale 1, density, friction, restitution static meshes collide with their exact triangles; moving ones as their convex hull
Rotated body, rotation (quaternion) the body turned about its centre
RotatedAbout body, axis, degrees
Launched body, velocity (m/s) an initial velocity
AddBody scene, body the scene with the body

motion is one of Static (never moves; ground, walls, terrain), Dynamic (moves under gravity, contacts, water, cloth and blasts) or Kinematic (moved by the graph with MoveKinematic in a session; pushes everything, nothing pushes it).

Typical densities: wood 600, water 1000, concrete 2400, steel 7850 kg/m³.

Cloth

Node Inputs (defaults) Notes
AddCloth scene, name, center, sizeX 1, sizeY 1, cells 32, density 0.2 kg/m², bendingStiffness 1e-5 N·m, friction 0.4, pin None a flat rectangular sheet in the XY plane
AddClothMesh scene, name, mesh, unitScale 1, density, bendingStiffness, friction, pin a cloth from any surface, as placed in the world

cells counts cells along the longer side. density is 0.1 to 0.3 kg/m² for light fabrics and 0.5 or more for canvas; bendingStiffness 1e-5 drapes like cotton and 1e-3 like card. pin holds vertices in place: None, Corners, or one edge (EdgeMinX, EdgeMaxX, EdgeMinY, EdgeMaxY).

Water

Node Inputs (defaults) Notes
AddWaterTank scene, name, tankMin, tankMax, depth, particleRadius 0.01 a tank filled to a depth
AddWater scene, name, tankMin, tankMax, fillMin, fillMax, particleRadius 0.01, viscosity 1e-6 m²/s any block of water in a tank, for example a dam-break column

Bodies need a few particles across their thinnest side. Halving particleRadius costs about sixteen times as much. A tank's walls hold the water, not bodies; where a ground plane is the tank's floor, the ground holds the water.

Triggers

AddTrigger(scene, trigger) adds a trigger made with the ContinuumTriggers nodes. Triggers are evaluated after every coupling step, in the order they were added. See Events and triggers.

3. Simulating (ContinuumSimulation)

Node Inputs (defaults) Returns
Simulate scene, duration 2 s, framesPerSecond 30, recordWater true, threads 0 a SimulationResult

Frame 0 is the scene before the first step, so a 2 s run at 30 fps has 61 frames. threads 0 uses the engine's shared pool; any number gives the same result. recordWater false leaves water particles out of the frames (12 bytes per particle per frame).

4. Reading a result (ContinuumResults)

Node Inputs Returns
FrameCount result the number of frames, frame 0 included
FrameAt result, time the frame nearest a time
FrameTime result, frame the time of a frame (s)
GetFrame result, frame a SimulationFrame
BodyPosition, BodyRotation, BodyVelocity result, body, frame a body's state in a frame
BodyPath result, body its position in every frame it exists in
BodyNames result, frame the bodies in a frame, spawned ones included
BodyMesh result, body, frame one body's surface placed in the world
BodiesMesh result, frame every body as one mesh (grounds left out)
ClothMesh result, cloth, frame a cloth's surface
WaterParticles, WaterParticleCount result, water, frame a water body's particles
WaterSurface result, water, frame the water's surface as a mesh, splashes included
Events, EventsOf result (, trigger) the events recorded, in order
FirstEventTime result, trigger when a trigger first fired, or −1

A body's mesh is its collision shape. For a render-quality asset, place your own model by BodyPosition and BodyRotation instead.

5. Export (ContinuumExport)

Node Inputs (defaults) Writes
ExportSequence result, folder, prefix "continuum" prefix.0000.obj per frame (every body and cloth a named object) and prefix_water.0000.ply per water body per frame
ExportFrame result, frame, path one frame as OBJ

Files are in Divooka's axes. See Geometry and export.

6. Values

Type What it holds
SceneDescription gravity, wind, rates, seed, bodies, cloths, water and triggers
BodyDescription a body's shape, pose, motion, velocity and material
TriggerCondition, TriggerAction, TriggerDescription a trigger and its parts
SimulationResult the scene that was run, the frame rate, the frames and the events
SimulationFrame Index, Time and every body's BodyState (position, rotation, velocity), plus cloth and water positions
SimulationEvent the trigger's name, the time, a position, the bodies involved and a value (speed, height or count)