cyberspace-demo: Add flythrough demo built on the emulator template

Copy of emulator-template with the Cyberflythrough sketch (pseudo-3D
grid flight with tracing entities). Host includes the 60 fps pacing and
delta-time Demo sample; APP defaults to Cyberflythrough.
This commit is contained in:
Dejvino
2026-11-16 20:49:20 +01:00
parent 2b0da875a5
commit 89e235cafe
7 changed files with 1462 additions and 0 deletions
+87
View File
@@ -0,0 +1,87 @@
# T-Deck Cyberspace Demo
A wireframe 3D fly-through demo inspired by [System Shock's Cyberspace](https://shodan.fandom.com/wiki/Cyberspace)
from the Shodan Fandom wiki. Renders a rotating wireframe cube that appears to fly
through a tunnel, evoking the cyberspace aesthetic from the System Shock games.
## Overview
This demo demonstrates a wireframe 3D rendering engine capable of:
- Rotating cube geometry with X/Y/Z axis spin
- Perspective projection for depth perception
- Color-coded edges (SHODAN green for vertical, cyber teal for horizontal)
- Pulsing central "SHODAN core" visual effect
The visual style draws from the System Shock cyberspace environment: a
wireframe 3D space where the player moves weightlessly, collecting data
and facing SHODAN's security programs.
## Controls
- Default: auto-rotating fly-through
- Press **SPACE** to toggle between auto-spin and manual rotation
- Press **ESCAPE** or **Q** to quit
## Building & Running
```bash
# Build and run the cyberflythrough demo
make run
# Build with different APP name
make run APP=Cyberflythrough
# Headless smoke test (240 frames, dump BMP)
make smoke
# Clean built binary
make clean
```
## Key Features
| Feature | Description |
|---------|-------------|
| **Wireframe cube** | 8 vertices, 12 edges rotating in 3D |
| **Perspective projection** | Objects get smaller with "depth" |
| **SHODAN aesthetic** | Green vertical edges, teal horizontal edges |
| **Pulsing core** | Central green eye pulses rhythmically |
| **320x240 resolution** | Optimized for T-Deck screen |
## File Structure
```
cyberspace-demo/
├── README.md # This file
├── Makefile # Build configuration
├── shim.h # Arduino API shim (millis, random, etc.)
├── src/
│ └── main.cpp # SDL3 host loop — window, framebuffer, setup()/loop()
└── examples/
└── Cyberflythrough/
└── Cyberflythrough.cpp # Wireframe 3D demo sketch
```
## How It Works
The sketch implements the standard emulator contract:
- `setup()` — called once at launch, initializes rotation angles
- `loop()` — called once per frame (~60 fps)
- Clears framebuffer to black
- Increments rotation angles for continuous spin
- Projects 8 cube vertices through rotation + perspective
- Draws all 12 cube edges using Bresenham's line algorithm
- Draws a pulsing "SHODAN core" in the center
- Sets `emuGfx::dirty = true` to present the frame
The wireframe rendering uses fixed-function transformation:
1. Rotate vertices around X, Y, and Z axes
2. Project 3D coordinates to 2D using perspective division
3. Draw connecting edges between cube vertices
Edge colors are differentiated: vertical edges (connecting front/back faces)
are rendered in SHODAN green (0xFF00FF00), while horizontal edges are
cyber teal (0xFF00AAFF), helping convey the 3D structure.
The central "eye" effect is a pulsing circle that rhythmically expands
and contracts, evoking SHODAN's omnipresent observation within cyberspace.