Skip to content

Demo

Examples/Demo (“Mainframe Demo”) is a real game project: a project.mfproj, a node library and a GameHost desktop project (Demo.Desktop), built from the mfgame template and opened by the editor like any user game. It has one isolated scene per engine feature, switched from a nav bar, and every scene is a README screenshot. It replaced the old test game (an Engine subclass the editor could not open) and the editor-screenshot project. The proposal it was built from is future/demo-project.md; this page is the current state.

The Demo is not in MainframeEngine.slnx. It is built through its own Examples/Demo/Demo.slnx, exactly like a user project (engine by project reference, MainframeEnginePath in Directory.Build.props = ../..).

Examples/Demo/
├── Demo.slnx, Directory.Build.props, global.json, .gitignore, .gitattributes (template copies)
├── project.mfproj "Mainframe Demo", main scene basic_3d, window.icon, canvas_items stretch,
│ UI scaled with the screen from its 1280 × 720 base (ADR 0181), autoload Nav (DemoNavLayer), locales
├── Demo/ the node library: Src/{Nav,Basic3D,Basic2D,Audio,SoundFx,Ui,Physics,Spine,Particles,Animation3D,Shaders,Sprites2D,Tiles2D,Navigation,Paths2D,Paths3D,Music,Shared}
├── Demo.Desktop/ `GameHost.Run(args, typeof(Demo.DemoScenes).Assembly)` + `--write-scenes <dir>`
├── Demo.Tests/ xUnit v3 tests of the Demo (see Tests and CI)
└── Assets/
├── Scenes/{basic_3d,basic_2d,audio_2d,audio_3d,sound_fx,ui,physics_2d,physics_3d,spine,particles,animation_3d,shaders,sprites_2d,tiles_2d,navigation_2d,navmesh_2d,paths_2d,paths_3d,navigation_3d,navmesh_3d,adaptive_music,world_ui}.mfscene
├── Shaders/{ground,sway,dissolve}.slang + their SPIR-V and layouts (`just canvas-shaders`), the Shaders panel
├── Nav/, UI/, Basic3D/, Basic2D/, Audio/, SoundFx/, Physics/, Spine/, Particles/, Animation3D/, Paths2D/, Paths3D/ RmlUi panels (.rml/.rcss), one per scene
├── Sprites2D/hero.{png,mfres}: the generated sprite sheet and its SpriteFrames (written by `--write-scenes`)
├── Audio/ (Audio/Sfx/*.mfres: the ZzFX presets), Music/demo_loop.{mfsong,ogg}, Music/adaptive_theme.{mfsong,mfmusic} + adaptive_theme.stems/ (the baked stems), Models/TestModel/, Models/Character/ (the skinned test character), Models/Spine/SpineBoy/, Sky/, Basic2D/logo.png, icon.png
├── Settings/AudioBusLayout.mfres
└── locale/messages.pot, {es,qps}/LC_MESSAGES/messages.{po,mo}

Assets have editor-generated .mfmeta files (their UIDs) and they are tracked: scene files reference assets by UID ("ref": "tex_…"), and the scene writer derives resource keys from them, so a clone without the .mfmeta files would write different scenes. Binary content (PNG, OGG, .bin) is Git LFS (Examples/Demo/.gitattributes); .po, .pot and .mo are plain files so the localization check works without LFS.

project.mfproj declares the autoload Nav (DemoNavLayer). GameSession.AddAutoloads adds it as /root/Nav before the main scene, so it survives scene changes (SceneTree.ChangeSceneToFile replaces only CurrentScene). DemoNavLayer is a UiLayer (Layer = 100, above any scene UI) holding DemoNav : UiDocument (Assets/Nav/nav.rml):

  • two rows (72 dp; every scene panel starts below them, top: 88dp in Assets/UI/demo.rcss): the top row holds the logo, one tab per category (DemoScenes.Categories: 3D, 2D, Physics, Animation, Audio, UI) and, on the right, the controls below; the second row holds the open category’s scenes as underlined tabs. The open category is the current scene’s. Clicking a category opens the scene last open in it (its first the first time). Scenes are in the order of DemoScenes.All (the single registry: id, title, category, icon, path, builder), grouped by category so stepping walks a category before the next. A category’s row has room for about ten scenes, and a new category is one more entry in Categories (the A6 bar, one row of sixteen tabs at 14 dp, had run out of room);
  • an FPS readout and a language picker (en, es, qps; it sets UserSettings.Language, so it persists);
  • a gear button (tooltip “Settings (F10 / Start)”) that opens the engine’s settings menu with all three tabs, pausing the game (bus labels: SFX → “Effects”, UI → “Interface”);
  • the project’s input actions (project.mfproj, labelled and grouped, so the menu’s Controls tab lists them): scene_next/scene_prev (Page Down/Up, RB/LB) step through every scene, crossing categories and wrapping, settings (F10, Start) opens the menu, quit (Escape, "rebindable": false) quits; in Physics 3D drop (Mouse Left, RT) and rain (R, Y). Keys 1–6 open the categories, and without a project map (tests) Escape and the left button keep working. The tabs are widget-library buttons (tab-index: auto, nav: auto), so RmlUi’s focus navigation (Tab, and the gamepad’s D-pad and A) reaches them like any other button.

The layer keeps processing while the menu pauses the game (ProcessMode.Always: FPS and the active tab update).

DemoNav follows SceneTree.CurrentScene and highlights the scene tab whose id equals the scene root’s name, and its category, so --scene and the editor’s “play this scene” light the right tabs. Switching frees the previous scene.

Every scene is self-contained: its own camera, environment and lights, and a small RmlUi side panel (a UiLayer with Layer = 10 inside the scene) for its controls. A scene’s root node is named after its id.

Id (tab)What it showsControls
basic_3d (Basic 3D)Primitives with distinct StandardMaterial3Ds (opaque, blended glass, emissive lamp), the glTF test model, panoramic sky, a cascaded-shadow sun, a coloured omni and two shadowed spots, an orbiting camera (OrbitCamera)pause orbit, sun, lamps, exposure
basic_2d (Basic 2D)A Camera2D canvas (Y-down): gradient sky, layered hills, a sun with rays, orbiting circles and a Sprite2D (the engine logo), all CanvasItem draws (DemoShape2D, SunRays2D, Orbit2D)zoom, pause animation
audio_2d (Audio 2D)An AudioPlayer2D emitter sweeping left and right past the Camera2D listener (Sweeper2D); click anywhere for a positional blip and a fading ring (ClickToPlay2D)Master / SFX / Music bus faders, panning, max distance
audio_3d (Audio 3D)An AudioPlayer3D emitter orbiting an AudioListener3D (Orbiter), its audible range drawn with DebugLines (DistanceRing)attenuation model, low-pass at distance, Doppler, orbit speed
sound_fx (Sound FX)ZzFX sounds synthesised at run time: the current sound’s waveform (SoundWave2D), one button per preset (ZzfxStream .mfres files in Assets/Audio/Sfx, written by --write-scenes from fixed seeds), Randomize and Mutate (ZzfxPresets), the current ZzFX line to paste into the editor’s sound designer or the web designer; a looping song on the Music bus (Assets/Music/demo_loop.mfsong, rendered with just render-song to a seamless-loop .ogg + .mfmeta)presets, randomize, mutate, pitch randomness, music
ui (UI)The RmlUi widget gallery and a data-bound form (UiShowcase, Assets/UI/showcase.rml), plus a live counter of UI hot reloadsaccent, name, volume, quality, reset counter
world_ui (World UI)G11 (World-space UI): a street with Label3D signs (a three-line menu, a billboarded market sign, an autowrapped notice), six walkers (WorldUiWalker) with UiMarker3D nameplates whose bars drain and refill, a FixedSize + NoDepthTest debug tag per walker, a “press E” prompt on a crate and a waypoint that clamps to the screen edge; buildings have colliders, so nameplates behind them fade out; a terminal (WorldUiTerminal on a UiPanel3D) opens the gate (Tab: mouse or crosshair, the use action clicks)occlusion, distance scale, debug tags, camera orbit; Tab
physics_2d (Physics 2D)Box2D: a funnel and pegboard of StaticBody2Ds, RigidBody2D circles and boxes raining in (Spawner2D); joints (G9, Joints2DBuild): a swinging chain of PinJoint2Ds, a car on sprung, motorised WheelJoint2Ds that turns at the ends of the ground (Car2D), a plank bridge on breakable pins, and a lift: a platform a MotorJoint2D pulls up and down (Lift2D sets its offset and velocity) carrying two cratesclick to spawn, collision shapes, joints, reset (bodies, the bridge and the lift)
physics_3d (Physics 3D)Jitter2: a crate stack, a ramp, a CharacterBody3D pusher that shoves crates (Pusher3D), click-to-drop crates by ray query (Dropper3D); joints (G9, Joints3DBuild): a rope bridge of HingeJoint3D planks, a shop sign on a breakable WeldJoint3D a capsule mannequin (Mannequin3D, a Ragdoll3D) that falls when a crate hits it, and two Generic6DofJoint3D props (G9.10b, Joints3DBuild.AddSixDof): a gimbal dish that tilts up to 40° about X and Z and springs back level, and a drawer that slides 0.4 m out of its cabinet and soft-closes; three save slots (below)click the floor, rain crates, collision shapes, joints, reset (crates, mannequin, sign), save/load
paths_3d (Paths 3D)G13.5/G13.6 (Paths): AnimatableBody3D platforms on PathFollow3Ds in the physics callback carry the capsule (PathRider3D: WASD / arrows / left stick walk, Space or the panel’s Jump jumps): a lift ping-pongs up to a landing, a ferry shuttles between two pads, a turntable (Turntable3D) turns; a guard (PathGuard3D, a CharacterBody3D) walks a patrol route by the carrot recipe with the hinted closest query; a closed camera rail (RailCamera3D on a follower) circles the yard; PathMarkers3D shows the pathsspeed multiplier, pause, ride the camera rail, jump
spine (Spine)SpineBoy (SpineNode) on a lit floor, casting his shadow onto a backdrop wall (3D view), seen by a Camera3D or a Camera2D2D camera toggle, animation picker; 3D view: shaped (alpha-tested) shadow, turned away, billboard mode (ADR 0204)
particles (Particles)GpuParticles3D at night (ADR 0206): a campfire’s additive HDR flames and velocity-aligned embers that glow, lit smoke sorted back to front, a one-shot spark burst and a 3,000-streak rain box, with fog (Assets/Particles/soft.png is the soft sprite)rain, glow, burst of sparks
animation_3d (Animation 3D)The skinned test character (Models/Character/character.glb: a Skeleton3D, a skinned mesh, an AnimationPlayer with ten clips; ADR 0207/0208) running under a shadowing sun, with a hammer and a torch light on its right hand (a BoneAttachment3D added to the instance), and a physical skeleton (ADR 0212: PhysicalBoneSimulator3D.Build, 20 capsule PhysicalBone3Ds with cone-twist joints, the pelvis and head held for the active ragdoll, ADR 0235; the project runs 2 physics substeps for it) over a ground collider. One-shot clips return to idle (Animation3DPanel). Behind it a second instance on a RootMotionWalker (CharacterBody3D) is moved only by root motion (ADR 0210): half circles of the circle clip and forward jumps around a closed loop. To the left a workshop runs on keyframe tracks alone (G1a, one looping workshop animation on a physics-callback player): an AnimatableBody3D lift (position track with eased keys), a door on a cubic rotation track that a method key unlocks before it swings and locks after it shuts (DoorLatch’s [AnimationMethod]s; its indicator turns green), a lamp flickering on a cubic Energy value track and a ZzFX chime on an audio trackclip (crossfaded), crossfade time, speed, last event (Step, HammerFist, Tap), Ragdoll / Stand up, Active / Let go (fades the drives in or out over 0.3 s), Push (40 N·s to the chest)
shaders (Shaders)Spatial surface shaders (ADRs 0205, 0237): a ground whose albedo comes from the world position alone (ground.slang), fungal stalks in one MultiMeshInstance3D swaying with their shadows, out of step by instanceCustom (sway.slang), props dissolving with a glowing edge, cut out in their shadows too, and a hit flash (dissolve.slang); ShadersPanel sets the parameterswind, animate, dissolve, hit
sprites_2d (Sprites 2D)AnimatedSprite2Ds (ADR 0223) on one generated 4×4 sheet (HeroArt: a blob idling, running and jumping, a spinning coin; numbered frames) sliced into Assets/Sprites2D/hero.mfres, drawn with nearest filtering: a showcase hero, a hero patrolling the ground (Patrol2D, flipped at each turn) and five coins at different speeds, one backwards (Sprites2DPanel)animation, speed, backwards, flip, pause; frame and loop readouts (signals)
tiles_2d (Tiles 2D)TileMapLayers (G2b, Tile maps) painted from an ASCII level with one generated atlas (TilesArt, Assets/Tiles2D/tiles.png + tiles.mfres: collision on stone, water, trunks and bushes; surface custom data): Ground, Walls (stone and water) and a y-sorted Objects layer in which the Sprites 2D hero (TileHero2D, a CharacterBody2D) walks the paths behind and in front of trees, followed by a limited Camera2D; a TileShadow2D chases it on a NavigationGrid2D read from the walls layer (G3.6, Navigation); click the map to add or remove a wall and the shadow repathsshow collision, y-sort, walk speed, autopilot, shadow chases, show navigation; surface and wall-cell readouts; WASD / arrows / left stick walk (move_* actions)
navigation_2d (Navigation 2D)G3a (Navigation): a maze of StaticBody2D walls on a 26 × 15 NavigationGrid2D of 32 px cells whose Data (written by code as a physics bake gives it; Demo.Tests checks it against a real bake) holds the walls and three mud patches (weight 3); twelve NavChaser character bodies (collision layer 2, slower in mud) with NavigationAgent2Ds walk to the clicked point, each to its own spot on two rings (NavigationDemo2D); G3.7: the agents avoid each other, the walls (each wall body has a NavigationObstacle2D rectangle) and a boulder (NavPatrol, a moving radius obstacle) rolling up and down before the target, moving by the safe velocity from VelocityComputed; arrived chasers hold their spot and make way for late ones; “Click adds walls” turns clicks into wall blocks (SetCellSolid: every chaser repaths)diagonal mode, heuristic, jump point search, Visible Navigation (the server’s debug draw, restored on leaving), avoidance, async paths (G3.10: every agent’s PathMode Async), click adds walls; arrived count
navmesh_2d (Navigation Mesh 2D)G3.9 (Navigation meshes): a hall of three slanted walls and two round pillars (StaticBody2Ds under the Hall NavigationRegion2D, whose NavigationPolygon is baked from its baking rectangle with a 12 px agent radius when the scene is built, saved inline; Demo.Tests checks it against a fresh bake), a pond carved by a NavigationObstacle2D with AffectNavigationMesh, a river (a static body and an avoidance obstacle, parsed by neither region) and a far Bank region joined only by two ferries (NavigationLink2Ds); ten NavChasers follow funnel paths to the clicked point (NavigationMeshDemo2D), avoid each other and hop across a ferry on LinkReached; outer walls keep pushed chasers incarve the pond (re-bakes), Visible Navigation, avoidance, Bake again with the polygon count and bake time; ferry crossings, arrived count
navigation_3d (Navigation 3D)G3.11 (3D grids): six walls on a 24 × 16 m floor, a NavigationGrid3D of half-metre cells (its Data written by code as a physics bake gives it, 0.35 m agent radius; Demo.Tests checks it against a real bake) and eight NavChaser3D capsules (CharacterBody3D, gravity) whose NavigationAgent3Ds (PathHeightOffset 0.7) walk to the clicked floor point, on a ring (NavigationDemo3D)Visible Navigation (the 3D server’s debug draw, restored on leaving); arrived count
navmesh_3d (Navigation Mesh 3D)G3.12 (3D navigation meshes): uneven ground under a NavigationRegion3D — a floor, a terrace 1.5 m up reached by a 20° ramp, a deck reached by six 0.2 m stairs, a crate and pillars (static boxes with visuals) — whose NavigationMesh (0.35 m agent radius, 0.3 m climb, 0.15 m cells) is baked with Recast when the scene is built and saved inline (Demo.Tests checks it against a fresh bake); six NavChaser3D capsules walk to the clicked surface (NavigationDemo3D with KeepHitHeight)Visible Navigation (the polygons); arrived count
paths_2d (Paths 2D)G13 (Paths): a closed oval Path2D whose four PathFollow2D cars lap at their own Speeds (turning with the curve, a quarter lap apart), an open arc whose lift ping-pongs (Loop off, PingPong), and a guard (PathGuard2D) walking a rounded patrol route by the carrot recipe from a start inside it; PathTrack2D draws each path’s baked curvespeed multiplier, pause
adaptive_music (Music)Adaptive music: an AdaptiveMusicPlayer playing Assets/Music/adaptive_theme.mfmusic, baked with just bake-song from adaptive_theme.mfsong (the Demo loop’s ZzFX instruments at 140 BPM: Intro → Explore and Combat, both looping; a Hit stinger; a Perc layer (hats) and a Lead layer with a low-pass, both over intensity; area moves Explore to Combat at the next bar and back with the stinger). MusicVisualizer2D draws the sections (the playing one lit, the scheduled one outlined), the bar’s beats pulsing on the Beat signal and one bar per layer (height: gain, brightness: the low-pass cutoff), captioned in the engine’s Latointensity, area, Hit stinger, music on/off; section, bar.beat and the next section’s countdown

Save games (G4). The Physics 3D panel saves and loads the crates through the engine’s SaveServer (Projects → Save games): three slots (physics-1…3) with a thumbnail, the description (“16 crates”), play time and save time. The payload is CrateSave (Src/Physics/CrateSave.cs: positions, rotations, velocities, colours and the spawn counter) with a source-generated JSON context; the schema is at version 2 with one migration (version 1 had no spawn counter), so the pattern is visible. Dropper3D.Snapshot()/Restore() convert between crates and the payload. project.mfproj keeps two backups and turns thumbnails on (which enables frame capture); after a save the panel drops RmlUi’s cached thumbnail texture (UiServer.Reload(document, Textures)). A load that had to fall back to a backup says so (“restored the copy from 10:02”).

Mouse input in the 2D scenes is mapped from window points to canvas units through the root viewport’s stretch and camera transforms (CanvasInput.WindowToCanvas); Physics 3D uses Camera3D.ProjectRayOrigin/ProjectRayNormal and DirectSpaceState.

Spine is drawn through the 3D pipeline, so under a Y-down Camera2D the Y-up skeleton appears upside down; the 2D mode puts SpineBoy under a pivot rotated 180° about X (and scales per mode: 1 unit = 1 canvas pixel under the 2D camera). Both cameras live in the scene file, but the 2D mode detaches the Camera3D from the tree (SpinePanel.SetMode): the engine keeps a Camera3D active as long as any is in the viewport, so Current = false alone would never hand the view to the Camera2D (see Cameras & input). The panel re-adds the camera for 3D mode and frees it itself in OnExitTree when the scene ends while it is detached.

Several panel controls change state that is not part of the scene: the renderer’s exposure (Basic 3D), the audio bus volumes (Audio 2D) and the physics servers’ collision-shape drawing (Physics 2D and 3D). Each panel records the value on OnReady and restores it in OnExitTree, so leaving a scene does not change how the next one looks or sounds.

Scene files: --write-scenes and the contract

Section titled “Scene files: --write-scenes and the contract”

Scenes are built in code (DemoScenes.All[i].Build, helpers in DemoBuild.Add, which sets Owner so children are saved) and saved as .mfscene (format 2). The committed files are generated:

Terminal window
dotnet run --project Examples/Demo/Demo.Desktop -- --write-scenes Examples/Demo/Assets/Scenes

The same command rewrites the Sound FX presets (Assets/Audio/Sfx/*.mfres, keeping their UIDs) and the Sprites 2D sheet and SpriteFrames (Assets/Sprites2D/hero.png + hero.mfres, first, because the scene loads them). SceneFilesTests.CommittedScenesMatchTheBuilders is the contract: for every scene, building it and serializing it with the committed scene’s UID must reproduce the committed file byte for byte. Change a builder, regenerate, commit the scenes; a regeneration that leaves a diff means the file was stale (or an asset’s .mfmeta is missing, see Layout). The scenes stay editable in the editor, which loads the Demo’s node types from its assembly (no MissingNodes).

A Debug build of the Demo records its Assets/ folder in the MainframeContentSource assembly attribute (Demo.csproj); GameHost hands those folders to UiServer, which watches them. Editing a .rml or .rcss and saving reloads the document in the running game without a rebuild. The UI scene shows it: UiServer.HotReloadEnabled tells the page whether it is on, and UiServer.HotReloaded (also raised for stylesheet-only reloads) drives the reload counter and the last-reload time. Release builds of the engine do not hot reload and say so on the page.

just demo-screenshots (alias just qa; build/demo-screenshots.sh) builds the Demo in Release and runs Demo.Desktop once per scene (--fixed-fps 60 --max-frames 240 --screenshot docs/images/demo/<id>.png; GameHost saves the last frame, and the fixed step makes it deterministic), plus settings.png: the settings menu over Physics 3D, opened by the Demo’s own ++ --settings argument. The nav bar is part of every image. The game saves its framebuffer (2560 × 1440 on a HiDPI display), so the script then scales every PNG to 1280 × 720 (sips, else ImageMagick): the README’s Showcase grid shows them all at one size, beside the Forest’s 16:9 shots. The scene PNGs (docs/images/demo/, Git LFS) form the README’s Showcase gallery; re-take them when a scene changes visibly. They need the display awake (caffeinate -u).

  • Demo.Tests (dotnet test Examples/Demo/Demo.Tests): the scene registry (order, categories in contiguous runs, paths, root-name mapping), the nav bar (DemoNavTests: the second row shows the current scene’s category, both rows render with one active tab each, a category reopens its last scene, every scene is reachable from the bar, number keys open categories), the scene file contract above, switching every tab twice leaves exactly one scene, the project file (stretch mode, main scene and icon exist), canvas mouse mapping, DemoShape2D, and one test class per scene for its builder and panel (including that leaving a Physics scene restores the collision-shape overlay and toggling Spine back restores the Camera3D; Sound FX: the committed presets are the fixed-seed sounds, every button plays on the null device, the song’s .wav loads with its loop settings and the toggle loops it on the Music bus; Music: the committed bake loads with every stem, Intro continues to Explore, intensity brings the layers in and opens the filter, area moves to Combat on the bar and back, the stinger is heard, and the music stops at a bar and starts again). Tests that touch RmlUi are in the SerialRmlUi collection.
  • build/demo-smoke.sh <work-dir> [frames] (CI job template; just has no recipe, run it directly) builds Demo.Desktop and Demo.Tests with warnings as errors (the projects: a solution build leaves the engine, which is outside Demo.slnx, in Debug), runs Demo.Tests, then runs every Assets/Scenes/*.mfscene headless (--hidden --fixed-fps 60 --no-vsync) for a few frames with its own user-data folder, and fails on a non-zero exit, a missing screenshot or an [ERROR]/[FATAL] line in the scene’s log. It only cleans the per-scene folders and PNGs it creates under the work directory.
  • Saves and settings: Physics3DSaveTests (save, change the scene, load and compare every crate; a version-1 save migrates; an empty slot), DemoNavActionTests (F10 opens the menu, Escape closes it before it can quit, Page Down/Up step and wrap, the menu in Spanish and qps) and ProjectFileTests (actions, the locked quit, the saves section).
  • just qa-settings (build/qa-demo-settings.sh) runs the real Demo three times with its own user-data folder (artifacts/qa-settings) through DemoQa (++ --qa settings|check|saves): F10, rebind “rain” by pressing F in the menu, change volumes/mute/VSync/max FPS/UI scale/language, Escape (saves); restart and check every value came back from settings.json; save twice, cut the newest file in half (a crash mid-write) and check the load recovers the previous save and keeps the .corrupt-* file. Each run quits with 0 or 1.
  • The engine’s own render tests cover Spine under a Camera2D (a golden) independently of the Demo.

Catalogs are in Examples/Demo/Assets/locale (en source, hand-written es, qps pseudo-locale). just l10n-extract reads Examples/Demo/Demo/Src, the Demo’s Assets (RML and scene strings), the engine’s widget library, the engine’s settings.pot (the settings menu and input names) and the action labels of project.mfproj; just l10n-check (CI) fails on a stale .mo. See Localization.

Cameras & input · Canvas · Game UI · Audio · Physics · Projects & GameHost · Testing · Localization · Milestones