Themes and creatures¶
Overview¶
DuneBox is highly customizable across both the C++ (DuneBox) and Python (sandcam) applications. This guide covers all the major features and how to configure them.
Color Themes (DuneBox C++)¶
DuneBox includes 5 built-in color themes that change the terrain elevation gradient, water color, and contour line color.
| Theme | Description |
|---|---|
| Topo | Classic topographic map colors (green → brown → white) |
| Ocean | Deep blue water emphasis, sandy shores |
| Volcanic | Reds, oranges, and dark greys: pairs with lava mode |
| Ice Age | Cool blues and whites, glacial feel |
| Alien | Otherworldly purples, greens, and cyans |
Controls¶
tkey: cycles through themes- Active theme is saved in
bin/data/settings/sandSurfaceRendererSettings.xml
Each theme defines: - Elevation gradient: color ramp from lowest to highest terrain - Water color: tint applied to the water simulation overlay - Contour color: color of topographic contour lines
Dinosaur Mode (sandcam)¶
sandcam includes a full dinosaur simulation with 6 species, biome-aware placement, and predator-prey mechanics.
Species¶
| Species | Biome | Role |
|---|---|---|
| T-Rex | Mountain / highland | Apex predator |
| Raptor | Forest / grassland | Pack predator |
| Stegosaurus | Grassland / beach | Herbivore |
| Triceratops | Grassland | Herbivore (defensive) |
| Pteranodon | Mountain peaks / sky | Aerial |
| Brachiosaurus | Forest | Large herbivore |
Each species has an elevation range: creatures only spawn in terrain zones matching their biome preference.
Predator-Prey Mechanics¶
- Predators (T-Rex, Raptor) chase nearby herbivores
- Herbivores (Stegosaurus, Triceratops, Brachiosaurus) flee from predators
- Triceratops can charge predators in defense
- Predators can kill prey on contact: prey respawns after a cooldown
Controls¶
Vkey: cycles creature sets (Modern, Prehistoric, All, None)
ArUco Marker Triggers¶
| Marker ID | Effect |
|---|---|
| 1–5 | Toys: boat, dino, house, tree, volcano |
| 10 | Spawn T-Rex pack |
| 11 | Spawn Raptor pack |
| 12 | Spawn Pteranodon flock |
| 13 | Extinction event (kills all dinosaurs) |
| 20 | Place a volcano at the tag |
| 21 | Trigger the nearest volcano |
| 100–103 | Sandbox corners (TL / TR / BR / BL) |
Volcano System (sandcam)¶
Place and trigger volcanoes anywhere on the terrain.
Placement¶
Okey: toggles click-to-place; click the sand to plant a vent and erupt- ArUco marker ID 20: places a volcano at the tag (debounced; snaps to a nearby vent)
- ArUco marker ID 21: triggers the nearest volcano
Eruption¶
- Click a placed volcano to trigger eruption
Eruption States¶
Volcanoes cycle through 5 states:
- Dormant: visible cone, no activity
- Rumbling: screen shake, smoke particles begin
- Erupting: sparks and ash particles launch from the crater
- Flowing: lava flows downhill using cellular automata (each cell propagates to lower neighbors)
- Cooling: lava darkens, activity subsides, returns to dormant
Particle Effects¶
- Smoke: rising grey particles during rumbling and eruption
- Sparks: bright orange particles launched from crater
- Ash: dark particles that drift and settle
- Steam: produced when lava meets water
Inter-App Sync¶
Volcano eruptions sync with the C++ DuneBox app via the inter-app bridge (see below), enabling lava mode and volcanic theme to activate automatically.
Ecosystem Simulation (sandcam)¶
A layered ecosystem that grows vegetation and manages food chains based on terrain.
Controls¶
Ekey: toggles ecosystem on/off
Vegetation Layers¶
Three layers of vegetation grow based on water proximity and elevation:
- Grass: grows near water at low-mid elevations
- Shrubs: grows at mid elevations where grass is established
- Trees: grows at mid elevations where shrubs are established (slowest)
Biome Zones¶
The terrain is classified into 7 biome zones based on elevation and moisture:
- Deep water, shallow water, beach, grassland, forest, mountain, snow
Food Chain¶
- Vegetation → consumed by herbivores
- Herbivores → hunted by carnivores
- Carrying capacity limits populations naturally: overpopulation leads to die-off
Game Modes (sandcam)¶
sandcam includes 4 educational game modes, each with star ratings (★★★) on completion.
| Key | Game | Objective |
|---|---|---|
| F1 | Build a Dam | Contain rising water by sculpting terrain barriers |
| F2 | Volcano Defense | Protect a village from lava by diverting flow with terrain |
| F3 | Watershed Puzzle | Route rainfall to a target reservoir using channels |
| F4 | Biome Sculpt | Shape terrain to match a target elevation distribution |
All game modes use a CPU-based water simulation for game logic (separate from DuneBox's GPU water sim), so games work independently of the C++ app.
Day/Night Cycle (Both Apps)¶
A dynamic lighting cycle that affects visuals and creature behavior across both DuneBox and sandcam.
Controls¶
Nkey: toggles day/night cycle on/off+/-keys: increase/decrease cycle speedPkey: pause the cycle at current phase
Phases¶
| Phase | Lighting | Details |
|---|---|---|
| Dawn | Warm orange tones | Sun rises, birds begin ambient audio |
| Day | Full brightness | Normal simulation lighting |
| Dusk | Golden-purple gradient | Sun sets, transition period |
| Night | Dark blue tones | Stars and moon visible, sun hidden |
Behavior Changes¶
- Creatures slow 50% at night: reduced movement speed during night phase
- Sound changes: crickets and owl sounds at night; bird calls at dawn (see Sound System)
Earthquake Gesture (sandcam)¶
Trigger earthquakes by physical interaction or keyboard.
Activation¶
- Hand slap: detected from rapid depth changes across the sensor
Kkey: manual trigger
Effects¶
- Expanding shockwave rings radiate from the epicenter
- Dinosaur stampede: all dinosaurs flee at 2× speed
- 70% chance to trigger eruption on nearby volcanoes
Sound System (sandcam)¶
Spatial audio that reacts to terrain and simulation events.
Controls¶
Skey: mute/unmute all sound
Ambient Sounds¶
| Sound | Trigger |
|---|---|
| Water | Terrain-reactive volume (louder with more water) |
| Wind | Always present, varies with terrain height |
| Crickets | Night phase only |
Event Sounds¶
| Sound | Trigger |
|---|---|
| Creature spawn/despawn | Creature added or removed |
| Marker detect/lost | ArUco marker enters or leaves view |
| Eruption | Volcano erupts |
| Earthquake | Earthquake triggered |
Configuration¶
Sound settings are stored in the settings JSON: - Master volume: overall volume level - Per-category volumes: ambient, events, creatures, UI
Web Dashboard (sandcam)¶
Press U in sandcam, then open http://127.0.0.1:8765/. Setup, LAN access and the PIN are covered in Run it from a tablet.
To restyle it, edit web/assets/app.css. The color, type and spacing tokens at the top of that file are shared with the sandcam sidebar and the DuneBox (C++) panel and documented in DESIGN.md; change them together so the three surfaces stay consistent.
DEM Loading (sandcam)¶
Load real-world terrain data as a depth overlay.
Controls¶
F5: saves a snapshot of the current terrain toassets/terrains/saved/- DEM overlay /
[]cycling is not implemented in the live app (load_dem()exists for scripts only)
GeoTIFF Support¶
For loading custom GeoTIFF elevation files, install the optional rasterio dependency:
Inter-App Bridge¶
TCP-based communication between sandcam (Python) and DuneBox (C++).
Controls¶
Bkey: toggles the bridge on/off
Architecture¶
- Protocol: TCP with JSON messages on
localhost:9876 - sandcam (Python) = server
- DuneBox (C++) = client
Synced Data¶
| Data | Direction | Description |
|---|---|---|
| ArUco markers | sandcam → DuneBox | Marker positions and IDs |
| Theme changes | sandcam → DuneBox | Theme switch commands |
| Volcano eruptions | sandcam → DuneBox | Eruption triggers and lava state |
| App state | DuneBox → sandcam | Setup or running, depth camera, water, lava, theme, day and night, frame rate (every half second) |
| Dashboard commands | sandcam → DuneBox | Water, lava, eruption, next theme, day and night, start |
ArUco Marker Reference¶
IDs 1 to 5, 10 to 13, 20, 21 and 100 to 103 are listed under Dinosaur Mode and in the sandcam setup guide.
Adding Custom Marker Events¶
- Print an ArUco marker: use OpenCV dictionary DICT_4X4_250 (same as the files in sandcam's
calibration/folder). Pick an unused ID. - Register the event in
interaction_engine.py - Attach the marker to a physical toy (tape it to the bottom of a figurine, boat, etc.)
- Place the toy on the sand → the webcam detects the marker → the event fires
sandcam: Adding Custom Creatures¶
Creatures are biome-aware: they appear based on terrain elevation. The system is defined in creatures.py.
Adding a New Creature¶
-
Create a sprite: any PNG image with transparency. Place it in
assets/creatures/. -
Register it in
creatures.py: -
Biome types (lowest to highest elevation):
deep_water,shallow_water,beach,grassland,forest,mountain,snow
DuneBox (C++): Adding Games¶
The C++ DuneBox has a game plugin system in src/Games/. Each game is a class that inherits from a base game interface.
Existing games: - Shape an Island: draw an island in the sand - Sandimals: fish and sharks swim in water areas - Animals & Mothers: match animals with their habitats
Adding new C++ games requires more effort than Python: refer to the existing game classes as templates.
Inspiration & References¶
- RiverWeyTrust/ARSandbox-Adds: lava flows, snow effects
- danigeos/sARndbox: erosion & sedimentation simulation
- SARndbox calibration videos: see what others have built