Dustbin::Games Framework

A modular C++17 game and tool development framework built around the Irrlicht 3D Engine. It enforces strict separation of concerns through a Bidirectional Command Stack, Code-Generated Strongly Typed Messages, and a single unified JSON Project Definition.

C++17 / CMake 4.0+ 42 Modular Libraries Bidirectional Command Stack Automated C++ Message & Proxy Generator ZLib License

1. How the Framework Works

Instead of coupling user input, gameplay rules, physics, networking, and 3D/2D rendering inside monolithic classes, the Dustbin::Games Framework decomposes an application into two orthogonal layers:

1. Central Coordinator (CMainClass)

dustbin::CMainClass owns the IDataHub and the main ICommandStack. It registers itself as the Irrlicht IEventReceiver, captures engine log messages from startup into an inspectable log vector, and drives the main loop via while (l_cMain.run());.

2. Service Locator (IDataHub)

data::IDataHub creates and holds the IrrlichtDevice, IVideoDriver, ISceneManager, IGUIEnvironment, and IFileSystem, alongside pluggable framework subsystems: IFontManager, IAudioInterface, IL10n, ISceneRenderer, persistent getSettings(), and transient getGlobals().

3. Automatic Module Initialization

During project generation, the build scripts inspect every enabled module's module.json for an "initialize" entry and generate CInitModules.h/.cpp. Calling dustbin::modules::initFrameworkModules(&l_cMain) invokes each module's registration function in ascending priority order (e.g., priority 50 → 75 → 99 → 100).

4. Command Stack (ICommandStack)

All runtime work happens inside command::ICommand subclasses pushed to the stack via pushToStack(). Every frame, CCommandStack::run() executes active commands, removes commands whose hasFinished() returns true, and routes Irrlicht GUI/mouse/keyboard events to commands where handlesIrrlichtEvents() == true.

Application Startup Lifecycle

Every application generated by the framework follows a clean, predictable entry-point pattern (as seen in both VierGewinnt.cpp and TrackEd_Internal.cpp):

int main(void) {
  // 1. Configure application & project identifiers for portable settings/data paths
  dustbin::data::CDataHub::setApplicationName(_APPLICATION);
  dustbin::data::CDataHub::setProjectName    (_PROJECTNAME);

  // 2. Instantiate the central coordinator (creates CDataHub & main CCommandStack)
  dustbin::CMainClass l_cMain;

  // 3. Run auto-generated module initializers sorted by module.json priority
  //    (Registers FreeType fonts, L10n, SFML Audio, DustbinGUI factories, Shaders, Skybox, ODE, etc.)
  dustbin::modules::initFrameworkModules(&l_cMain);

  // 4. Push the initial command(s) onto the command stack (e.g. Main Menu or 3D Editor)
  l_cMain.getCommandStack()->pushToStack(
    new dustbin::command::CMenuMain(l_cMain.getDataHub(), l_cMain.getCommandStack())
  )->drop();

  // 5. Run the main loop until the command stack is cleared
  while (l_cMain.run());
  return 0;
}

Stack Stashing & Modal Execution (stash / stashPop)

A signature feature of command::ICommandStack is its ability to suspend and restore entire application states—including the active Irrlicht ISceneManager and IGUIEnvironment—without destroying them:

2. Complete List of Available Modules (42 Modules)

All 42 framework modules reside in _source/modules/. Each module is compiled as a separate static library target (DustbinFW_<module_name>) or included as a header-only interface library ("interface": true in module.json). When you select a module for an application, the project generator automatically resolves and includes all transitive module dependencies, VCPKG link libraries, and required data/ assets.

Core & System Modules

Module Name Type / Init Priority Dependencies Summary & Key Classes
core_mainclass Static Lib core_commandstack, core_datahub, helpers_dustbinhelpers Application entry-point coordinator (dustbin::IMainClass, dustbin::CMainClass). Owns the IDataHub and main ICommandStack, captures startup Irrlicht logs into a vector, and drives the per-frame execution loop.
core_datahub Static Lib render_default, audio_interfaces, font_interfaces, localize_dustbinl10n, system_platform Central service locator and shared resource container (data::IDataHub, data::CDataHub). Manages the Irrlicht device/driver/scene/GUI/filesystem, active font/audio/l10n/renderer subsystems, persistent settings, session globals, application identity metadata (getApplicationName(), getProjectName(), getSettingsName(), getVersion()), active data archive name (setDataFileName() / getDataFileName()), and custom named reference-counted objects.
core_commandstack Static Lib core_messages, core_log, font_interfaces Implements the bidirectional command stack architecture (command::ICommand, command::CCommandStack, command::CCommandProxy, command::ICommandDialogEdit, command::IStackObserver) with downward Input and upward Output message routing and stack stashing.
core_messages Header-Only Interface serializer_interfaces Foundational messaging interfaces: messages::IMessage (16-bit type ID, validity flag, cloning, serialization), messages::IMessageFactory (deserializing messages by type ID), and messages::IMessageProxyFilter (filtering messages across stack proxies).
core_threads Static Lib core_messages Multithreading primitives (threads::IThread wrapping std::thread) with built-in thread-safe mutex-protected message queues (threads::CInputQueue and threads::COutputQueue) that automatically clone broadcast messages.
core_log Static Lib None Lightweight global logging facility (dustbin::log(...) and dustbin::setLogCallback(...)) allowing any module or background worker thread to emit structured Irrlicht log messages without holding a direct pointer to IDataHub.
system_platform Static Lib helpers_dustbinhelpers, core_datahub Cross-platform OS abstractions (CPlatformWindows.cpp / CPlatformLinux.cpp) providing platform::portableGetDataPath(), portableGetFontPath(), getDrives(), portableItoa(), and portableDateStr().
system_datafile Static Lib
Init: 75
None Virtual file system archive loader. On application startup, queries data::IDataHub::getDataFileName() and automatically mounts the packaged data ZIP archive (configured via the _DATAFILE compile definition or Release Wizard) into Irrlicht's file system via addFileArchive(..., EFAT_ZIP) so all assets are loaded transparently.

Rendering & 3D Scene Modules

Module Name Type / Init Priority Dependencies Summary & Key Classes
render_default Static Lib None Defines the engine-independent render::ISceneRenderer interface (shadow map pass, scene pass, node registration) and provides the standard fallback renderer render::CSceneRenderer_default wrapping ISceneManager::drawAll().
render_dustbinshader Static Lib
Init: 99
core_mainclass, core_datahub
Data: data/shaders
Custom GLSL shadow-mapping scene renderer based on the Dustbin::Games Shader pipeline. Registers itself with IDataHub::setSceneRenderer(...) via registermodule_render_dustbinshader.
render_aishader Static Lib
Init: 99
core_mainclass, core_datahub
Data: data/shaders_ai
Advanced GLSL shader pipeline supporting solid and transparent Cascaded Shadow Mapping (CSM), transparent depth atlas passes, and 2-layer multi-texture blending (used in FlatTrack Racing). Registered via registermodule_render_aishader.
scene_skybox Static Lib
Init: 100
None Procedural atmospheric skybox scene node (scene::CDustbinSkyBox & CDustbinSkyboxFactory). Generates 6 cubemap faces asynchronously on a background thread using the Preetham scattering model with a 24-hour day/night cycle, latitude-based sun/moon paths, stars, and procedural clouds.
scene_cameracontrol Static Lib None Interactive 3D camera controller (scene::CCameraControl) implementing irr::IEventReceiver for orbiting, panning, and zooming an ICameraSceneNode in 3D editors and tools.
scene_nodedata Static Lib None Internal scene node ID tracker (scene::INodeDataManager, scene::CNodeDataManager). Assigns unique internal IDs to ISceneNode* instances so editors, physics, and serializers can reference nodes reliably even when Irrlicht node IDs collide.
scene_animators Static Lib
Init: 99
None Custom Irrlicht scene node animators and factory registered on startup via registermodule_scene_dustbinanimators.
scene_audionodes Static Lib
Init: 99
audio_3dsound, physics_interfaces Custom scene nodes that attach positional 3D sound sources and physics sound triggers to parent scene nodes. Registered via registermodule_scene_audionodes.
scene_unknown Static Lib
Init: 99
core_log, helpers_dustbinhelpers Provides fallback factories for unknown scene nodes and unknown animators (registermodule_scene_unknownnodes) so generic scene editors can load, inspect, and re-save scenes containing game-specific node types without losing their serialized attributes.

Physics & Audio Modules

Module Name Type / Init Priority Dependencies Summary & Key Classes
physics_interfaces Static Lib core_commandstack, core_messages Engine-independent 3D physics interfaces (physics::IPhysicsManager, IPhysicsObject, IPhysicsNodeBody) and pre-generated physics messages (CPhysicsMessages.h / scripts/physics.json: PhysicsObjectMoved, PhysicsObjectTrigger, PhysicsObjectSetState, PhysicsStep, PhysicsObjectEnabled/Disabled) plus IPhysicsEngineCommand and IDefaultSceneCommand.
physics_ode Static Lib
Init: 99
physics_interfaces
VCPKG: ODE::ODE
Concrete 3D rigid-body physics implementation using the Open Dynamics Engine (ODE) with double precision and trimesh collision support (CCommandPhysics_ODE). Registered via registermodule_physics_ode.
audio_interfaces Header-Only Interface None Core audio abstractions (audio::IAudioInterface, no-op fallback CAudioInterface_None, ISound3d, IPhysicsSound, INodeAudioDataProvider) decoupling game/scene code from the audio backend.
audio_3dsound Static Lib audio_interfaces, helpers_dustbinhelpers, core_log Physics-driven 3D positional sound effects: CPhysicsSound_Movement (continuous velocity-scaled rolling/sliding sound), CPhysicsSound_Impact (collision impulse sound), and CPhysicsSound_Activation / Deactivation.
audio_sfml Static Lib
Init: 99
audio_3dsound, scene_audionodes
VCPKG: SFML::Audio
Default audio engine implementation powered by SFML Audio (CAudioInterface_SFML, CSound2d, CSound3d). Registered with IDataHub on startup via registermodule_audio_sfml.

GUI, Fonts, Input & Localization Modules

Module Name Type / Init Priority Dependencies Summary & Key Classes
gui_dustbingui Static Lib
Init: 99
localize_dustbinl10n, font_interfaces, controller_dustbincontroller, helpers_dustbinhelpers, core_datahub, core_mainclass, font_freetype Comprehensive suite of custom Irrlicht GUI elements and factories (registermodule_gui_dustbingui), including log displays (CGuiLogDisplay), ribbon menus, custom tabs, buttons, and XML-driven dialog layouts.
font_interfaces Header-Only Interface None Defines font::IFontManager for querying TrueType fonts by name/style/size, registering custom fonts, enumerating system fonts, and managing the font cache.
font_freetype Static Lib
Init: 75
font_interfaces, helpers_dustbinhelpers
VCPKG: Freetype::Freetype
FreeType-powered implementation of font::IFontManager (font::CFontManager and font::CGUITTFont) providing anti-aliased TrueType (.ttf / .otf) glyph rasterization and kerning. Registered at priority 75 via registermodule_font_freetype.
localize_interfaces Header-Only Interface None Defines the l10n::IL10n localization interface for translating UI strings and identifiers across languages.
localize_dustbinl10n Static Lib
Init: 75
helpers_dustbinhelpers, localize_interfaces, core_mainclass, core_datahub Dictionary-based localization system (registermodule_dustbinl10n). Stores localized strings in text files; in Debug builds, missing translation keys are automatically collected and written out on program exit.
controller_dustbincontroller Static Lib None Configurable input controller abstraction (controller::IDustbinController) mapping keyboard keys and joystick axes, buttons, and POV hats to logical game controls: Fader ([0..1] or combined bidirectional axis [-1..1]), Button, and single-tick Trigger. Supports saving/loading mappings via irr::io::IAttributes.
event_eventhandlers Static Lib None Structured base classes (event::IGuiEventHandler and event::IMouseEventHandler) that decompose Irrlicht's irr::SEvent union into clean virtual methods (onButtonClicked, onCheckboxChanged, onTreeviewNodeSelected, mouse button/wheel callbacks, etc.).

Networking & Serialization Modules

Module Name Type / Init Priority Dependencies Summary & Key Classes
network_enet Static Lib core_commandstack, core_threads, core_messages, serializer_interfaces, core_log
VCPKG: unofficial-enet
Bridges the command stack across the network over reliable UDP using ENet in background threads. CCommandENetServer serializes incoming Output messages and broadcasts them to clients, while deserializing client packets into Input messages. CCommandENetClient serializes incoming Input messages to the server and emits server packets as Output messages.
network_discovery Static Lib core_commandstack, core_threads, serializer_interfaces, core_log
VCPKG: unofficial-enet
Automatic LAN server discovery over UDP broadcast datagrams (CCommandDiscoveryServer and abstract CCommandDiscoveryClient with pure virtual serverFound(name, ip, port) callback). Operates on background threads every 500 ms without requiring user IP entry.
serializer_interfaces Header-Only Interface None Defines type tags (enSerializeDataTypes: String, WString, UInt8..64, Int8..64, Float32/64, Boolean, Vector3df/2df/2di, Quaternion) and the ISerializer, IDeSerializer, and ISerializerFactory interfaces.
serializer_bin Static Lib serializer_interfaces Architecture-independent binary serializer (CSerializerBin, CDeSerializerBin, CSerializerFactoryBin). Encodes multi-byte numbers/vectors in canonical big-endian network byte order and std::wstring as portable UTF-8 with strict bounds checking. Used for network packets.
serializer_xml Static Lib serializer_interfaces, helpers_dustbinhelpers Human-readable XML implementation (CSerializerXML, CDeSerializerXML) of ISerializer and IDeSerializer. Used for saving game replays (e.g., replay.xml in VierGewinnt) and structured data files.
data_serializerbin Static Lib serializer_interfaces Compact binary data serializer/deserializer encoding typed tokens with a "msg\0" header for local binary persistence.

Editors & Helper Modules

Module Name Type / Init Priority Dependencies Summary & Key Classes
commands_guieditor Static Lib
Init: 50
core_commandstack, core_log, core_mainclass, editor_commands, editor_general, editor_undoredo, event_eventhandlers, font_freetype, gui_dustbingui, helpers_dustbinhelpers, localize_dustbinl10n, system_platform Complete 2D GUI Editor command suite (MainDialog, AttributeCommand, TreeCommand, CommandUIElement, HotkeyCommand) and dialog assets (data/dialogs/Editor_2d.xml) for visually building Irrlicht/DustbinGUI XML layouts.
commands_sceneeditor Static Lib
Init: 50
audio_interfaces, controller_dustbincontroller, core_commandstack, core_log, core_mainclass, editor_commands, editor_general, editor_undoredo, event_eventhandlers, gui_dustbingui, helpers_dustbinhelpers, localize_dustbinl10n, physics_interfaces, scene_cameracontrol, scene_nodedata, scene_animators, system_platform Extensible 3D Scene Editor command suite (CEditor3dMain, MouseCommand, CameraCommand, MoveNodeCommand, TreeCommand, AttributeCommand, TestSceneCommand) with built-in 3D gizmos, scene tree hierarchy, attribute editing, and in-editor physics/audio scene playtesting.
editor_commands Static Lib
Init: 99
font_interfaces, helpers_dustbinhelpers, core_commandstack, gui_dustbingui, localize_dustbinl10n, editor_undoredo Specialized modal attribute editor commands (ICommandEditAttributeFactory for file pickers, textures, meshes, sounds, colors, vectors) and the custom Irrlicht material inspector (CGuiMaterialEditor, registered via registermodule_gui_materialeditor).
editor_general Static Lib
Init: 99
core_datahub, editor_undoredo, editor_commands General attribute inspection UI (gui::CGuiAttributeEditor for any irr::io::IAttributeExchangingObject) and attribute undo/redo state items (undoredo::CUndoRedoAttributes). Registered via registermodule_editor_general.
editor_undoredo Static Lib editor_general Linear undo/redo history stack manager (undoredo::IUndoRedoManager, CUndoRedoManager, IUndoRedoItem) with modification flag tracking for editors.
helpers_dustbinhelpers Static Lib system_platform General-purpose utilities: CStringHelpers (UTF-8/wstring conversions, splitting, trimming), CDataHelpers, CDrawHelpers, CSceneHelpers / CSceneLoader, CInputLimiter, CUuidGenerator, math::CBezier, and gui::IProgressCallback.
helpers_random Static Lib None Deterministic, cross-platform 64-bit PRNG (helpers::CRandom) implementing xoshiro256** with SplitMix64 seeding and rejection-sampled ranged queries, guaranteeing bit-identical sequences across Windows/Linux and x86/x64/ARM.

3. The Messaging System in Detail

In a Dustbin::Games Framework application, commands on the ICommandStack never call gameplay methods directly on one another. Instead, every command::ICommand is linked into a vertical doubly-linked chain via two pointers:

Two Strict Message Directions:
  • Input Messages (sendInputMessage → flows DOWN): Originate from commands higher up on the stack (such as user input handlers, AI controllers, network servers receiving client requests, or one-shot startup triggers) and travel downward through m_pOutputCommand->receiveInputMessage(pMsg) toward the authoritative game logic or physics engine at the bottom of the stack.
  • Output Messages (sendOutputMessage → flows UP): Originate from lower-level commands (such as the game rules engine, physics simulation, or network client receiving server broadcasts) and travel upward through m_pInputCommand->receiveOutputMessage(pMsg) toward 3D scene renderers, audio nodes, HUD overlays, camera controllers, and replay recorders.
Command Stack and Bidirectional Message Flow Architecture
Figure 1: Architecture of CMainClass, IDataHub, and the vertical ICommandStack showing downward Input and upward Output message flow.

How a Message Travels Through ICommand

When a command calls sendInputMessage(l_pMsg) (or one of the generated type-safe helper methods like sendInput_CoinDrop(playerId, column)), the following exact sequence occurs inside ICommand:

  1. sendInputMessage(a_pMessage) checks if there is a command below it (m_pOutputCommand != nullptr).
  2. If a lower command exists, it invokes m_pOutputCommand->receiveInputMessage(a_pMessage).
  3. Inside receiveInputMessage(a_pMessage), the receiving command first calls its virtual handleMessageInput(a_pMessage) hook, and then automatically forwards the message further down the stack by calling sendInputMessage(a_pMessage).
  4. When the message finally reaches the bottom-most command on the stack (where m_pOutputCommand == nullptr), inputMessageWillBeDeleted(a_pMessage) is called and the message object is automatically deleted (delete a_pMessage).

The exact mirror process happens for Output Messages traveling upward via sendOutputMessage → m_pInputCommand->receiveOutputMessage → handleMessageOutput → auto-deletion at the top of the stack (m_pInputCommand == nullptr).

Automated C++ Code Generation from JSON

Writing manual message classes, serialization logic, type-switch dispatchers, and stack filters by hand is error-prone. The framework's message generator (generate_messages_cpp in scripts/python_modules/ProjectGenerator.py, invoked via ProjectManagement.py or CreateProjectFiles.py) takes the "message_definition" section of the project JSON and generates four categories of C++ files:

1. Message Enum & Classes (C<Base>.h/.cpp)

Generates the enum class en<Enum> and strongly-typed messages::C<MessageName> subclasses deriving from messages::IMessage. Each class includes typed member fields, getters, a value constructor, a deserializing constructor C<Msg>(IDeSerializer*) with strict type-tag validation, clone(), and serialize(ISerializer*).

2. Message Factory (C<Factory>.h/.cpp)

Generates a concrete messages::IMessageFactory implementation whose createMessage(IDeSerializer*) reads the 16-bit message type ID from a binary or XML stream and instantiates the matching C<MessageName> class. Used by network_enet and replay loaders.

3. Command Interfaces (I<Interface>.h/.cpp)

For every entry in "interfaces", generates a base command class deriving from command::ICommand (or a custom base class). Messages listed in send.input / send.output become ready-to-call methods (sendInput_X(...), sendOutput_Y(...)). Messages listed in receive.input / receive.output become pure virtual callbacks (virtual void onInput_X(...) = 0;, virtual void onOutput_Y(...) = 0;) automatically unpacked inside the generated handleMessageInput / handleMessageOutput switch statements!

4. Stack Proxy Filters (C<Proxy>.h/.cpp)

When an application uses multiple command stacks (e.g. "main" and "physics"), the generator analyzes which messages are sent on one stack and received on the other, and automatically emits an IMessageProxyFilter class (forwardInputMessage / forwardOutputMessage) that only forwards relevant messages across the stack boundary.

Case Study 1: Message Flow in VierGewinnt (SourceForge Repository)

VierGewinnt (Connect Four) is a single-stack turn-based 3D game that showcases how complete separation between game rules, 3D rendering, human mouse raycasting, Minimax AI, XML replay recording, and LAN multiplayer is achieved purely through the command stack.

VierGewinnt Command Stack and Network Message Flow Diagram
Figure 2: The VierGewinnt Command Stack in both local gameplay mode (left) and split LAN multiplayer mode using network_enet (right).

Defined Messages in VierGewinnt.json (14 Messages)

Message Name Direction Fields (Name : Type) Purpose in the Game Flow
StartGame Input ↓ No fields Sent once by the transient CCommandStartGame at the top of the stack to trigger player registration.
RegisterPlayer Input ↓ PlayerUUID: String, Name: String Sent downward by each player controller (CCommandUserInput or CCommandAIInput) upon receiving StartGame.
PlayerRegistered Output ↑ PlayerUUID: String, Name: String, PlayerID: UInt8 Sent upward by CCommandGameLogic assigning internal PlayerID (1 or 2) to the matching UUID.
PlayerReady Input ↓ PlayerID: UInt8 Sent downward by a player controller to confirm it has received its PlayerID and is ready to start.
ActivePlayer Output ↑ PlayerID: Int8 Broadcast upward by CCommandGameLogic to announce whose turn it is (1 or 2).
HoverColumn Input ↓ PlayerID: UInt8, Column: UInt8 Sent downward by the active player/AI when hovering a board column (0..6, or 255 if none).
ColumnHovered Output ↑ PlayerID: UInt8, Column: UInt8 Validated and echoed upward by CCommandGameLogic so CCommandGameScene highlights the 3D column arrow.
ClickColumn Input ↓ PlayerID: UInt8, Column: UInt8 Sent downward by the active controller when clicking a column.
ColumnClicked Output ↑ PlayerID: UInt8, Column: UInt8 Echoed upward by CCommandGameLogic for visual/audio click feedback in CCommandGameScene.
CoinDrop Input ↓ PlayerID: UInt8, Column: Int8 Sent downward by the active player controller requesting to drop a chip into Column.
CoinDropped Output ↑ PlayerID: Int8, Column: UInt8 Sent upward by CCommandGameLogic after updating the 6×7 board array; triggers the 3D falling coin animation in CCommandGameScene and updates the board state inside CCommandAIInput.
WinStreak Output ↑ Coin1: Vector2di, Coin2: Vector2di, Coin3: Vector2di, Coin4: Vector2di Sent upward by CCommandGameLogic when 4-in-a-row is detected, providing the grid coordinates of the 4 winning coins so CCommandGameScene can highlight them.
GameFinished Output ↑ Winner: Int8 Sent upward by CCommandGameLogic when the match ends (0 = draw, 1 = Player 1 wins, 2 = Player 2 wins).
Delay Replay timestamp: UInt32 Inserted by CCommandRecorder into replay.xml (using serializer_xml) before each recorded Output message so CCommandReplay can reproduce exact match timing.

Generated Command Interfaces in VierGewinnt

Zero-Refactor Replay & LAN Multiplayer in VierGewinnt:
  • Replay System: CCommandRecorder sits near the top of the stack and intercepts every Output message coming from CCommandGameLogic, serializing a CDelay timestamp message and the Output message itself into replay.xml via CSerializerXML. When the user clicks "Replay" in the main menu, CMenuMain simply pushes CCommandReplay at the bottom of the stack (in place of CCommandGameLogic) and CCommandGameScene above it! CCommandReplay reads replay.xml and emits the recorded Output messages upward at their original timestamps—CCommandGameScene renders the entire match without knowing it is watching a replay.
  • LAN Multiplayer (network_enet + network_discovery): On the Host machine, CCommandGameServer (deriving from CCommandENetServer) is pushed above CCommandRecorder. It automatically serializes all Output messages traveling up from CCommandGameLogic using CSerializerFactoryBin and broadcasts them over UDP to the client, while deserializing incoming client packets and injecting them downward as Input messages. On the Client machine, CCommandGameClient (deriving from CCommandENetClient) sits at the bottom of the stack (replacing CCommandGameLogic!), with CCommandGameScene and the remote player's CCommandUserInput above it.

Case Study 2: Multi-Stack Proxy Message Flow in FlatTrack Racing (SourceForge Repository)

FlatTrack Racing demonstrates a more advanced architectural pattern: Multiple Command Stacks connected by a Command Proxy (command::ICommandProxy) and Shared Message Includes (physics.json).

In FlatTrack Racing, the "message_definition" in DustbinFlatTrack.json (and Messages/FlatTrackRacing.json) includes the framework's built-in physics.json (with "generate": false, since those classes are already compiled inside physics_interfaces) and assigns interfaces to two distinct command stacks: "main" and "physics".

FlatTrack Racing Multi-Stack Proxy Architecture Diagram
Figure 3: Multi-stack message flow in FlatTrack Racing between the "main" stack and the "physics" stack via CCommandRace and the generated CPhysicsProxy filter.

How the Two Command Stacks Connect via CCommandProxy

When playtesting a track in CTheActualSceneEditor::createTestSceneCommands(), the editor stashes the editing scene and constructs the main stack from bottom to top:

  1. Bottom of "main" stack — CCommandRace (derives from CCommandTestScene → CCommandProxy): In its constructor, CCommandRace creates a second internal command stack (the "physics" stack) and pushes:
    • CCommandPhysics_ODE (at the bottom of the "physics" stack, implementing IPhysicsEngineCommand from physics.json, stepping the ODE world at a fixed 16 ms step).
    • CRaceLogic (implementing IRaceLogic, tracking lap counts and checkpoint trigger order).
    • 1 to 4 CCarController instances (implementing IPhysicsController, one for each RaceCar1..4 node found in the scene).
    Finally, CCommandRace calls startProxy(), which places a partner CCommandProxy at the top of the "physics" stack linked to CCommandRace.
  2. Above CCommandRace on the "main" stack: CCommandCameraChase (ICameraChase) → CCommandCarUI (ICarUIHandler) → CCommandDefaultScene (IDefaultSceneCommand) → CCommandUserInput (IControllerInput) → CCommandTestSceneUI (at the top).

Messages & Cross-Stack Routing in FlatTrack Racing

Message Name Defined In Origin Stack & Sender Crosses Proxy? Receiving Commands & Actions
CarControls FlatTrackRacing.json Main Stack (Input ↓)
CCommandUserInput (IControllerInput)
Yes (Main → Physics)
Allowed by CPhysicsProxy::forwardInputMessage
Received as Input on the "physics" stack by CCarController (IPhysicsController), which applies throttle, steering, handbrake, and gear shifts to the car's ODE physics body.
PhysicsStep
(ID: 1003)
physics.json Physics Stack (Output ↑)
CCommandPhysics_ODE
Yes (Physics → Main)
Allowed by CPhysicsProxy::forwardOutputMessage
Received on the "physics" stack by CRaceLogic (updates lap timer in simulation steps) and CCarController (triggers sendOutput_CarState(...) after each physics step).
PhysicsObjectMoved
(ID: 1000)
physics.json Physics Stack (Output ↑)
CCommandPhysics_ODE
Yes (Physics → Main)
Allowed by CPhysicsProxy::forwardOutputMessage
Forwarded to the "main" stack and received as Output by:
• CCommandCameraChase (updates chase camera target/transform)
• CCommandCarUI (tracks car position)
• CCommandDefaultScene (updates Irrlicht 3D scene node positions, rotations, and 3D velocity audio).
PhysicsObjectTrigger
(ID: 1001)
physics.json Physics Stack (Output ↑)
CCommandPhysics_ODE
Yes (Physics → Main)
Allowed by CPhysicsProxy::forwardOutputMessage
Received on the "physics" stack by CRaceLogic (IRaceLogic) when a car hits a checkpoint trigger volume. If the checkpoint is valid in sequence, CRaceLogic emits a Checkpoint Output message.
CarState FlatTrackRacing.json Physics Stack (Output ↑)
CCarController (IPhysicsController)
Yes (Physics → Main)
Allowed by CPhysicsProxy::forwardOutputMessage
Carries 19 fields (Speed, RPM, Gear, Steering, Throttle, HandBrake, Clutch, ShiftUp/Down indicators, front wheel steering angle, 4 wheel roll pitch angles, and 4 wheel suspension displacements). Received on the "main" stack by CCommandCarUI to update the cockpit HUD and visual wheel/suspension sub-meshes.
Checkpoint FlatTrackRacing.json Physics Stack (Output ↑)
CRaceLogic (IRaceLogic)
Forwarded via Proxy to Main Stack Carries CarId, Checkpoint, LapNo, LapCount, and Timestamp. Received by CCommandCarUI (ICarUIHandler) to display sector/lap times on the racing HUD.
BeforeRenderScene FlatTrackRacing.json Main Stack (Output ↑)
CCommandRace::run()
No (Local to Main Stack) Emitted right after m_pDrv->beginScene() before shadow-map and scene rendering. Received by CCommandCarUI to apply visual wheel steering/pitch/suspension transforms right before draw calls.

How the Code Generator Automatically Built CPhysicsProxy.cpp

Because DustbinFlatTrack.json declares a proxy entry with "commandstack": "main" and "createsstack": "physics":

"proxies": [
  {
    "name": "PhysicsProxy",
    "comment": "This is the proxy which creates the physics command stack and it forwards commands forth and back",
    "commandstack": "main",
    "createsstack": "physics"
  }
]

The message generator cross-referenced all messages sent by interfaces on "main" against those received by interfaces on "physics" (and vice versa), automatically generating CPhysicsProxy::forwardInputMessage and CPhysicsProxy::forwardOutputMessage:

bool CPhysicsProxy::forwardInputMessage(messages::IMessage *a_pMsg) {
  irr::u16 l_iType = a_pMsg->getType();
  return l_iType == (irr::u16)enFlatTrackMsg::CarControls;
}

bool CPhysicsProxy::forwardOutputMessage(messages::IMessage *a_pMsg) {
  irr::u16 l_iType = a_pMsg->getType();
  return l_iType == (irr::u16)enPhysicsMsg::PhysicsObjectMoved
      || l_iType == (irr::u16)enFlatTrackMsg::CarState
      || l_iType == (irr::u16)enPhysicsMsg::PhysicsObjectTrigger
      || l_iType == (irr::u16)enPhysicsMsg::PhysicsStep;
}

4. The JSON Project Definition File

Every Dustbin::Games Framework project (such as VierGewinnt/project/VierGewinnt.json, FlatTrack/project/DustbinFlatTrack.json, or the framework's own scripts/dustbineditors.json) is driven by a single combined JSON project definition file.

This file is managed visually via scripts/ProjectManagement.py (which unifies the Project Settings, Project Wizard, Message Wizard, and Release Wizard in one GUI) or built headless from the command line via scripts/CreateProjectFiles.py <project.json>.

Top-Level JSON Structure

A combined project definition JSON file consists of four top-level keys:

{
  "settings": { ... },            // 1. Project metadata & relative directory paths
  "projectdefinition": { ... },   // 2. Executable targets (apps), source/header folders & selected modules
  "message_definition": [ ... ],  // 3. One or more message/interface/proxy code-generation sets
  "release_definitions": [ ... ]  // 4. Standalone release packaging & asset compression configs
}

4.1. "settings" & "projectdefinition" Sections

Important Path Resolution Rule:
  • settings.projectfolder is resolved relative to the folder containing the project .json file (e.g., when VierGewinnt.json is located in VierGewinnt/project/VierGewinnt.json, setting "projectfolder": ".." resolves the project root to VierGewinnt/).
  • All other paths in the JSON file—cmakefolder, buildfolder, app source / header folders, message outputfolder_source / outputfolder_header, and release file paths—are resolved relative to settings.projectfolder!
"settings": {
  "projectname": "FlatTrackRacing",
  "company": "Dustbin::Games",
  "projectfolder": "..",
  "cmakefolder": "project",
  "buildfolder": "project/build",
  "version_major": 0,
  "version_minor": 1
},
"projectdefinition": {
  "apps": {
    "TrackEd_Internal": {
      "SettingsName": "TrackEd_Internal",
      "source": [
        "project/_source/TrackEd_Internal",
        "project/_source/GuiClasses",
        "project/_source/General_Game",
        "project/_source/General_TrackEd"
      ],
      "header": [
        "project/_source/TrackEd_Internal",
        "project/_source/GuiClasses",
        "project/_source/General_Game",
        "project/_source/General_TrackEd"
      ],
      "modules": [
        "commands_sceneeditor",
        "physics_ode",
        "render_aishader",
        "audio_3dsound",
        "scene_skybox",
        "gui_dustbingui"
        // Transitive dependencies (core_mainclass, core_datahub, core_commandstack, etc.)
        // are automatically resolved and added during generation!
      ]
    }
  }
}

For each application in projectdefinition.apps, the generator:

  1. Injects standard application compile definitions: _APPLICATION="<AppName>", _PROJECTNAME="<ProjectName>", _VERSION="<major>.<minor>" (from version_major/version_minor), and _SETTINGSNAME="<SettingsName>".
  2. Traverses the module.json files of all listed modules to compute the full transitive dependency closure.
  3. Generates <first_source_folder>/CInitModules.h and CInitModules.cpp (always overwritten) containing dustbin::modules::initFrameworkModules(IMainClass*) sorted by each module's initialize.priority.
  4. Creates an initial entry-point file <first_source_folder>/<AppName>.cpp only if it does not already exist (safe to customize), initializing application identity and data archive metadata in IDataHub.
  5. Copies any module-required assets (declared in module.json's "data" array, such as shaders, editor XML dialogs, and button icons) into the project's data/ directory.

4.2. "message_definition" Section

The "message_definition" key is a JSON array, allowing a single project to generate multiple independent message sets (for example, dustbineditors.json defines separate message sets for the 2D GUI Editor and the 3D Scene Editor). Each entry in the array supports the following schema:

{
  "general": {
    "outputfolder_source": "project/_source/General_Game/_generated",
    "outputfolder_header": "project/_source/General_Game/_generated",
    "includepath": "_generated",
    "basefilename": "FlatTrackMessages",
    "enumeration": "FlatTrackMsg",
    "factoryname": "FlatTrackMsgFactory",
    "baseclasses": {
      "ICommandDialogEdit": "command/ICommandDialogEdit.h"
    }
  },
  "include": [
    {
      "file": "physics.json",
      "generate": false
    }
  ],
  "messages": [
    {
      "name": "CarControls",
      "id": 2000, // Optional explicit 16-bit enum ID
      "comment": "With this message the car is controlled",
      "fields": [
        { "name": "objectId",  "type": "UInt32",  "comment": "The Id of the car" },
        { "name": "throttle",  "type": "Float32", "comment": "The throttle position (-1.0 .. 1.0)" },
        { "name": "handbrake", "type": "Boolean", "comment": "Is the handbrake active?" }
      ]
    }
  ],
  "interfaces": [
    {
      "name": "TestSceneInput",
      "comment": "Reacts to the ESCAPE key to stop testing",
      "commandstack": "main",
      "irreventhandler": true,
      "inherits": {
        "baseclass": "command::CCommandTestScene",
        "include": "CCommandTestScene.h",
        "constructor": [
          { "type": "data::IDataHub *", "name": "a_pHub" },
          { "type": "irr::scene::ISceneManager *", "name": "a_pSmgr" },
          { "type": "command::ICommandStack *", "name": "a_pStack" }
        ]
      },
      "send":    { "input": [], "output": [] },
      "receive": { "input": [], "output": [] }
    }
  ],
  "proxies": [
    {
      "name": "PhysicsProxy",
      "comment": "Forwards messages between main and physics command stacks",
      "commandstack": "main",
      "createsstack": "physics"
    }
  ]
}

Supported Message Field Data Types (17 Types)

JSON Field Type Generated C++ Type Default Initializer ISerializer / IDeSerializer Methods
String const std::string & "" addString / getString
WString const std::wstring & L"" addWString / getWString (UTF-8 on wire in serializer_bin)
UInt8, UInt16, UInt32, UInt64 irr::u8, irr::u16, irr::u32, irr::u64 0 addU8..addU64 / getU8..getU64
Int8, Int16, Int32, Int64 irr::s8, irr::s16, irr::s32, irr::s64 0 addS8..addS64 / getS8..getS64
Float32, Float64 irr::f32, irr::f64 0.0f, 0.0 addF32, addF64 / getF32, getF64
Boolean bool false addBool / getBool
Vector3df const irr::core::vector3df & irr::core::vector3df() addVector3df / getVector3df
Vector2df, Vector2di const irr::core::vector2df &, const irr::core::vector2di & irr::core::vector2df(), vector2di() addVector2df/2di / getVector2df/2di
Quaternion const irr::core::quaternion & irr::core::quaternion() addQuaternion / getQuaternion

4.3. "release_definitions" & Build Pipeline Tooling

The "release_definitions" array (used by the Release Wizard in ProjectManagement.py and seen in VierGewinnt.json) configures how compiled Release executables, data/ assets, and third-party license files are packaged for distribution:

"release_definitions": [
  {
    "destination_folder": "release",
    "compress_data": false,
    "zip_filename": null,
    "files": [
      {
        "path": "project/build/Release/VierGewinnt.exe",
        "target": "VierGewinnt.exe",
        "type": "application",
        "size": 7135744,
        "selected": true
      },
      {
        "path": "data/dialogs/4_gewinnt.xml",
        "target": "data/dialogs/4_gewinnt.xml",
        "type": "data",
        "size": 105224,
        "selected": true
      }
    ]
  }
]

Running the Full Generation Pipeline

Whether triggered by clicking ⚡ Generate (Messages → CMakeLists → Adjust Projects) in scripts/ProjectManagement.py or running python scripts/CreateProjectFiles.py <project.json>, the pipeline executes three automated steps in strict order:

  1. Step 1 — Generate C++ Messages: Generates all message headers/sources, factories, command interfaces, and proxy filters for every entry in "message_definition" so the files exist on disk before CMake scans source directories.
  2. Step 2 — Generate CMakeLists.txt & Module Initializers: Resolves module dependencies, writes CMakeLists.txt, generates CInitModules.h/.cpp (and initial <App>.cpp if missing), and copies module data/ assets into the project folder.
  3. Step 3 — Run CMake & Adjust Visual Studio Projects: Invokes cmake in settings.buildfolder with static VCPKG triplet flags (-DVCPKG_TARGET_TRIPLET=x64-windows-static, -DUSE_DRAGDROP=On) and post-processes the generated .vcxproj files via AdjustProjects.py.