Skip to content

Physics Simple

App: apps/physics_simple/

A minimal physics demo: physics bodies are created automatically from Blender’s native Rigid Body settings when a .blend is instantiated. No Wren physics creation code is needed. The floor (static) and cube (dynamic) interact via Jolt.

Terminal window
% ./plume3d physics_simple

or

Terminal window
% ./../plume3d .
  • Loads Models/SimplePhysics.blend and instantiates four collections: GameCamera, GameLight, Environment (static floor), PhysicsCube (dynamic cube).
  • Physics bodies are automatically created from each object’s Rigid Body settings in Blender — no Physics.addDynamicBox call needed.
  • Space — toggles physics pause/resume (Physics.setSimulationPaused).
  • R — resets the cube position, zeroes velocity, and wakes it up (Physics.setPosition, Physics.setLinearVelocity, Physics.activate).
  • Shadow mapping is enabled: light.castsShadows = true, Graphics.setShadowMappingEnabled(true), Graphics.setShadowMapSize(2048).
[Game]
name = "physics_simple"
version = "0.0.1"
[Window]
width = 800
height = 600
resizable = true
[Physics]
collision_layers = ["Default", "Floor", "Cubes"]
collision_matrix = [[0,0], [0,1], [0,2], [1,2], [2,2]]

The blend must be created in Blender with the Plume3D addon. Key objects and their settings:

ObjectClass NameNode IdRigid Body
CameraGameCameramain_camera
LightGameLightmain_light
Ground plane(in Environment collection)Passive, Box
Falling cubePhysicsCubephysics_cubeActive, Box

Set Collision Layer to Floor on the ground and Cubes on the cube. Set Game Config Path to game.toml so the addon shows named collision layers.

  • PhysicssetSimulationPaused, setPosition, setLinearVelocity, setAngularVelocity, activate.
  • ResourceloadBlend (bodies auto-created on instantiate).
  • GraphicssetLights, setShadowMappingEnabled, setShadowBias, setShadowMapSize.
  • LightcastsShadows.
  • Scene, Node, Camera.
  • Add Physics.onContactBegin to detect when the cube lands.
  • Add Physics.addImpulse to let the player kick the cube.
  • Spawn more cubes with Physics.addDynamicBox in code.