Skip to content

Physics Stack

App: apps/physics_stack/

Demonstrates automatic rigid body stacking: a tower of dynamic cubes on a static floor, with contact events logged to the console when cubes collide. Bodies are created automatically from Blender’s Rigid Body settings on instantiation — no Physics.addDynamicBox calls needed.

Terminal window
% ./plume3d physics_stack
  • Loads Models/StackDemo.blend and instantiates GameCamera, GameLight, Environment (static floor), and stacked Cubes (dynamic rigid bodies).
  • Registers Physics.onContactBegin to log every collision pair and contact point.
  • Shadow mapping enabled: light.castsShadows = true, Graphics.setShadowMappingEnabled(true), Graphics.setShadowMapSize(2048).
Physics.onContactBegin(_scene) { |nodeA, nodeB, px, py, pz, nx, ny, nz|
Logger.info("Contact: %(nodeA.name) <-> %(nodeB.name) at (%(px), %(py), %(pz))")
}

Create Models/StackDemo.blend in Blender with the Plume3D addon:

ObjectClassCollision LayerRigid Body
Floor planein Environment collectionFloorPassive, Box
Stacked cubesStackedCubes collectionBoxesActive, Box
CameraGameCamera
LightGameLight
[Physics]
collision_layers = ["Default", "Floor", "Boxes"]
collision_matrix = [[0,0], [0,1], [0,2], [1,2], [2,2]]
  • PhysicsonContactBegin (contact event callbacks).
  • ResourceloadBlend (bodies auto-created on instantiate).
  • GraphicssetLights, setShadowMappingEnabled, setShadowBias, setShadowMapSize.
  • LightcastsShadows.