cyberspace-demo: Real first-person fly-through of the Net

Replace the spinning-cube placeholder with a proper System Shock
Cyberspace fly-through (shodan.fandom.com/wiki/Cyberspace):

- Camera dragged along a gently curving data-current spline with
  banking roll and weightless bob; look direction blended toward
  straight-ahead so the vanishing point stays centered
- Octagonal tunnel rings + longitudinal ribs with depth fade and
  near-plane segment clipping; radius swells between four named
  zones (military spur / research grotto / data cistern / security
  grid) via smoothstep blends
- Wiki-canon objects recycled around a 256-unit loop: data object
  (purple cube), data fragment (yellow square + orange diamonds),
  infonode signpost, security mine, integrity restorative, ICE
  pyramid growths, and SHODAN's diamond core with Bezier tentacles
  + rotating shield ring once per loop
- NetDeck-style HUD: 3x5 bitmap font, crosshair, LNK/TRACE meters,
  zone banners, DIST/VEL/NODE readouts; Space = freeze convention
- 3x3 view matrix built per frame from the path tangent; Bresenham
  lines against the direct framebuffer, dimc() depth fading

Verified: clean build (0 warnings), 240-frame smoke, 5000-frame
soak, frame dumps inspected at five flight points.
This commit is contained in:
Dejvino
2026-11-16 21:02:10 +01:00
parent 57d79ee296
commit cebfed96a8
2 changed files with 70 additions and 57 deletions
+57 -46
View File
@@ -1,53 +1,60 @@
# 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.
A first-person wireframe fly-through of Cyberspace, inspired by
[System Shock's Cyberspace](https://shodan.fandom.com/wiki/Cyberspace)
from the Shodan Fandom wiki. The camera is dragged along a "river of data"
through immense rooms of glowing wireframe, populated with the classic
Cyberspace objects — a vibe study for the NetDeck game's jack-in view.
## 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
Everything renders as glowing wireframe on a 320x240 framebuffer, exactly
like the wiki describes: *"important programs manifest as floating geometric
shapes in immense rooms of glowing wireframe. Hallways between rooms
represent rivers of data between nodes, which drag the user along in
digital currents."*
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.
- **Data current** — the camera follows a gently curving spline path,
banking into curves and bobbing weightlessly; the tunnel of octagonal
rings swells between narrow hallways and vast rooms (zones) with
smoothstep radius blends.
- **Cyberspace objects** (per the wiki's Objects list), recycled around a
256-unit loop so the flight never ends:
| Object | Wiki appearance | In the demo |
|---|---|---|
| Data Object | spinning purple cube | two nested counter-rotating wireframe cubes |
| Data Fragment | yellow square + 4 orange diamonds | spinning square with octahedra on the diagonals |
| Infonode | geometric signpost | green pylon + octahedron head + orbiting spark |
| Security Mine | blue sphere | pulsing billboard circles + orange prime blink |
| Integrity Restorative | red cross | three-axis red wireframe cross |
| I.C.E. Barrier | geometric growths | cluster of magenta pyramids, shimmering |
| SHODAN's core | vertical diamond ending in four curved tentacles | Bézier tentacles + rotating shield ring, once per loop |
- **Void stars** — distant fixed points for orientation (rotation-only
parallax, translation-free, infinity-depth).
- **NetDeck-style HUD chrome** — crosshair, LNK/TRACE meters, zone banner
(MILITARY SPUR / RESEARCH GROTTO / DATA CISTERN / SECURITY GRID), DIST /
VEL / NODE readouts in a 3x5 bitmap font.
## Controls
- Default: auto-rotating fly-through
- Press **SPACE** to toggle between auto-spin and manual rotation
- Press **ESCAPE** or **Q** to quit
- **SPACE** — freeze / resume the current (NetDeck `Space` freeze convention)
- **f / s** — faster / slower current
- **h** — toggle HUD
- **ESC** — 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
make smoke APP=Cyberflythrough
# 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
```
@@ -59,29 +66,33 @@ cyberspace-demo/
│ └── main.cpp # SDL3 host loop — window, framebuffer, setup()/loop()
└── examples/
└── Cyberflythrough/
└── Cyberflythrough.cpp # Wireframe 3D demo sketch
└── Cyberflythrough.cpp # Cyberspace fly-through sketch
```
## How It Works
The sketch implements the standard emulator contract:
- `setup()` — called once at launch, initializes rotation angles
- `setup()` — called once at launch, seeds the object/streak/star fields
- `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
- consumes keys from `emu::keyboard` (freeze, speed, HUD)
- advances the camera along the data-current spline (`pathX/pathY`),
banks the roll into curves, simulates streaks and object recycling
- transforms world → view space with one 3x3 matrix per frame
(yaw/pitch from the path tangent, blended toward straight-ahead) and
perspective-projects
- draws octagonal tunnel rings + longitudinal ribs with depth fade,
near-plane segment clipping, and the object wireframes
- draws HUD chrome and sets `emuGfx::dirty = true`
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
Geometry notes:
- All lines are Bresenham's algorithm against the direct framebuffer.
- Depth fade multiplies each color by a per-segment brightness using
`dimc()`, giving the glowing-wireframe-into-the-distance look without
a z-buffer.
- Segments are clipped against the near plane in view space so objects
sweeping past the camera don't smear across the screen.
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.
Potential next steps toward NetDeck integration: replace the scripted
camera with trackball-steered flight, pin the tunnel zones to actual
network nodes (AIRLK/JUNC/HIVE), and let data-object pickups arm the
daemon keys (`1` FRENZY.EXE / `2` BLIND).