Skip to main content

Runtime Scene Loading

There are two ways to get a SuperDex scene into Unreal. You can import it in the editor, so that the level's own actors and components are the physics scene, or you can load a scene file at runtime, so that a .superdex_scene file is the physics scene and Unreal mirrors it. Both can drive demos and data collection; they trade off differently.

Editor-authored levelRuntime scene file
Source of truthUnreal assets and the levelThe .superdex_scene or .superdex_scene_archive file
Changing the sceneEdit the level; reimport after Studio changesPoint the build at another file. Its physics and generic visuals need no re-cook; Blueprints, levels, and hooks it relies on must already be in the build
Unreal-side tuningEvery component and settings asset is editableGravity, solver, and contact layers come from the file
VisualsImported meshes and materials, full Unreal lightingBuilt at runtime from the file's render models (.glb) or collision shapes
Bots, controllers, sensorsThe scene importer places each bot with a SuperDexBotComponent; it skips the file's controllers and scene sensors (add controllers in Unreal)The native loader declares the file's bots, controllers included, but creates none until your code calls BotScene::InitializeBot
Same physics as Python and StudioAs close as the importers allow (see their limits)Loaded by the same native SuperDex Robotics loader
Ready-made support in the pluginsExample levels, Player Start, roboperatorsLoader, visualization, hooks, and the L_RuntimeSceneLoad example to start from

How runtime loading works​

USuperDexBotSceneSubsystem (a game-instance subsystem in SuperDexRobotics) owns the load. It reads the scene path from the command line when the game instance starts, before any actor's Begin Play:

SuperDexUnreal.exe -SuperDexSceneFile="C:\scenes\my_scene.superdex_scene_archive"

Use an absolute path; Unreal resolves a relative one against its own base directory, not the shell's working directory. The subsystem then:

  1. Claims the game instance's SuperDex Physics scene for the file. From then on Unreal components create no simulated actors in it, and level settings (gravity, solver params, contact layers) no longer apply; only step params and debug draw do.
  2. Fails if the physics scene already holds actors: the file must be the only source of physics actors.
  3. Populates the scene from the file and reports its state through GetState(): Disabled (no scene requested), Loaded, or Failed. Failed is terminal: the session does not quietly fall back to level physics, even when the request fails before loading, as with an empty -SuperDexSceneFile= path or a -SuperDexTaskFolder= that holds no tasks. The reason is in the log, prefixed SuperDexBotSceneSubsystem:.

Without -SuperDexSceneFile=, the subsystem stays Disabled and levels simulate their own components as usual.

Seeing the scene​

USuperDexBotSceneVisualizationComponent mirrors the loaded scene into the level: base-scene actors, spawned prefabs, and bot links, updated every frame. Add it to any actor in the level you run; it never loads a scene itself, and builds whenever the subsystem reports a load. Entries with a render model (.glb) are drawn with it, imported at runtime; the others, and every entry under -NoRenderModels, are drawn from their collision shapes. Rods are drawn from their visual mesh or contact skin; a rod with neither is visible only in SuperDex Physics debug draw.

Driving the scene's bots​

The loader declares the scene's bots but does not create them, because only your project knows which of the offered bots it drives. That step, and binding Unreal to the result, is C++; the Runtime Scene Load example does both:

  • USuperDexBotSceneSubsystem::GetBotScene() returns the native BotScene; create the bots you use with BotScene::InitializeBot. The scene steps on its own thread, so make that call through the Mochi scene's QueueOrExecuteCommand, wait with WaitForQueuedCommands(), and check each result before using it. Then, back on the game thread, call NotifySceneContentsChanged() so the visualization rebuilds:

    UGameInstance* GameInstance = GetGameInstance();
    USuperDexBotSceneSubsystem* Subsystem = GameInstance->GetSubsystem<USuperDexBotSceneSubsystem>();
    superdex::robotics::BotScene* BotScene = Subsystem->GetBotScene();
    UMochiSceneObject* SceneObject =
    GameInstance->GetSubsystem<UMochiGameInstanceSubsystem>()->GetScene();

    superdex::robotics::Bot* Bot = nullptr;
    superdex::Error Error;
    SceneObject->QueueOrExecuteCommand([&](mochi::Scene*) {
    Bot = BotScene->InitializeBot("my_bot", Error);
    });
    SceneObject->WaitForQueuedCommands();
    if (!Bot) {
    UE_LOG(LogTemp, Error, TEXT("InitializeBot failed: %s"),
    UTF8_TO_TCHAR(Error.ToString().c_str()));
    return;
    }
    Subsystem->NotifySceneContentsChanged();
  • USuperDexBotComponent::BindToExistingBot lets a level's bot component, such as the one in a roboperator, pose its skeletal mesh from a scene-owned bot instead of creating its own. bHideMeshWhenBoundToSceneBot (on by default) leaves drawing to the visualization.

  • USuperDexBotSceneSubsystem::EnsureLoaded loads a fallback path when the command line gave none, for editor iteration. Call it before any actor's Begin Play, for example from an actor's PostInitializeComponents.

These hooks are not exposed to Blueprint. While a scene file owns the physics scene, a level-authored bot component that is not bound creates no bot of its own. The scene's slots and each bot's roboperatorClass tell your code which bots to offer and which rig drives each; see Slots and roboperators.

The Runtime Scene Load Example​

/SuperDexExamples/RuntimeSceneLoad/L_RuntimeSceneLoad builds its workcell at runtime from a scene file instead of from actors placed in the level. It loads assets/scenes/runtime_scene_load/runtime_scene_load.superdex_scene, a SuperDex scene modeled on L_Sampler that differs from it in a few places: the workbench as its base scene, the arms and proxy hands in left and right slots, seven of L_Sampler's prefabs as spawnable prefabs, and one task per prefab in its tasks/ folder. The level adds the lighting, the player setup, keyboard overlay, and FPS/SPS counter, and one ASuperDexRuntimeSceneLoadExample actor (in the SuperDexTeleop module) that does the C++ work above:

  • Loads the scene through the subsystem and draws it.
  • Brings up each slot's selected bot (the slot's first, at first) and spawns the roboperator from its Roboperators list whose class the bot names in roboperatorClass, at the bot's base and bound to the scene bot.
  • Before every physics step, drives the bot's scene controllers from what that roboperator's TeleopNode last published: a Pose controller takes the arm pose target, a JointPositions controller the joint targets, and a MOCHI_ARTICULATED_POSE controller follows the tracked hand. Other controllers are not driven.
  • Spawns the current task's objects, steps through a task folder, and resets the objects. Each episode puts the bots back in the poses the scene first brought them up in.
  • On Win64, records each episode with SuperDex Recorder when Record is on or -SuperDexRecord is passed. Each recording references the loaded scene and task files by name and content hash.

Any scene whose bots name roboperators in that list runs with its own bots, prefabs, and controllers. The example is a starting point, not a framework: one actor in SuperDexTeleop/Public/Examples/SuperDexRuntimeSceneLoadExample.h and its .cpp, to copy into your own module and change.

L_RuntimeSceneLoad in play: two FR3 arms with DG-5F (long, seed) hands over the workbench, the shape box with four loose pieces in front of it, the keyboard-shortcut overlay, and the FPS/SPS counter.
The 02_shape_box task loaded at runtime, with both slots on the FR3 + DG-5F (long, seed) arm.

Settings and controls​

The actor's properties are in the SuperDex Robotics → Runtime Scene Load category, which the Details panel shows first:

PropertyPurpose
Scene FileThe scene, relative to the project directory. -SuperDexSceneFile= overrides it.
Task FileA .superdex_task, or a folder whose tasks play in name order, relative to the project directory. -SuperDexTaskFolder= or -SuperDexTaskFile= on the command line of the editor or a packaged executable overrides it.
RoboperatorsThe roboperator classes the scene's bots name in roboperatorClass.
SlotsPer scene slot: its Name, the Handedness of the hand that drives it, and its Cycle Bot Key.
Record, Recording Directory, Record Contact ForcesRecording on Win64. -SuperDexRecord, -SuperDexRecordDir=, and -SuperDexRecordContacts override them; the directory defaults to <Project>/Saved/SuperDexRecorder.

In L_RuntimeSceneLoad, Scene File and Task File point two folders above the project, at the repository's assets/scenes/runtime_scene_load/, and Record is on. The keys follow L_Sampler, and the level's keyboard overlay lists them:

KeyAction
Ctrl+A / Alt+ANext bot in the left / right slot.
B / NPrevious / next task.
MReset the task's objects.
SpaceClutch the roboperators, as in L_Sampler.
EnterStart recording an episode, or keep the one recording and start the next.
BackspaceDiscard the episode being recorded and start the next.

Changing a slot's bot or the recording state restarts the episode. Each key is a property of the actor, and each action is also a Blueprint-callable function (CycleSlotBot, NextTask, ResetTask, RecordOrKeep, and so on).

The SuperDexRuntimeSceneLoadExample actor's Details panel with SuperDex Robotics, Runtime Scene Load expanded: Scene File and Task File paths into assets/scenes/runtime_scene_load, 12 Roboperators, 2 Slots, Record checked, Recording Directory, Record Contact Forces, and the key properties.
The example actor in L_RuntimeSceneLoad: the repository's scene and tasks, its roboperator classes and two slots, and recording on.

Running the example in a packaged build​

A packaged build has no repository beside it, so pass both paths as absolute paths:

SuperDexUnreal.exe /SuperDexExamples/RuntimeSceneLoad/L_RuntimeSceneLoad -SuperDexSceneFile="C:\project_superdex\assets\scenes\runtime_scene_load\runtime_scene_load.superdex_scene" -SuperDexTaskFolder="C:\project_superdex\assets\scenes\runtime_scene_load\tasks"

The scene's README lists its tasks and where it differs from L_Sampler.

Producing a scene file​

For what a scene file holds, see SuperDex Scenes.

  • SuperDex Studio authors .superdex_scene files and exports archives in its Scene Editor.
  • From a running level, the Blueprint node ExportSuperDexBotScene (in SuperDexRoboticsFunctionLibrary) writes the current physics scene to <OutputDir>.superdex_scene_archive, with actors in their current pose and bots as bot archives. It works in the editor and Play In Editor only. Set bCaptureLiveScene to capture the scene exactly as it is.

Tasks and Repeated Episodes​

Pass -SuperDexTaskFile="C:\tasks\trial.superdex_task" to parse a task alongside the scene, or -SuperDexTaskFolder="C:\tasks" to select the first task in a folder's filename-sorted playlist. The folder takes precedence when both switches are supplied. Task files are separate from scene archives.

The subsystem holds the task but does not apply its reset state. Your C++ host resolves placements and any randomization, calls SpawnTaskInstance for the required objects, then NotifySceneContentsChanged once after the batch so visualization rebuilds. DestroyAllTaskInstances removes those objects; AdvanceToNextTask changes the parsed task without replacing the scene or its bots. The host still owns robot/controller reset, episode timing, and recording boundaries. See Bot Tasks for the format and outcome semantics.

Packaging​

The project cooks the maps listed in Config/DefaultGame.ini (MapsToCook), which include L_RuntimeSceneLoad; add the level you run to that list. Scene files are read from disk at runtime, so they are not cooked: ship them next to the build, or anywhere -SuperDexSceneFile= can reach. The same file also always cooks /InterchangeAssets/gltf, Unreal's stock glTF materials, which the render models imported at runtime instance; a project of your own that draws .glb render models at runtime needs that entry too.

Runtime scene loading is supported on Windows only. It is not supported in the experimental Meta Quest standalone build, even though L_RuntimeSceneLoad is cooked into that package. Recording a runtime-loaded scene needs SuperDex Recorder, which is also Win64-only. For the Windows build steps, see the SuperDex Unreal README.

See Also​