UMjCamera¶
Represents a MuJoCo
element as an Unreal sensor component.
Placed in the Sensors group because cameras are observation devices, not geometry. The component is cheap by default: no render target or GPU cost is incurred until SetStreamingEnabled(true) is called. Key design points: - No ExportTo / RegisterToSpec — camera is UE-side only, not fed back to MuJoCo. - SetStreamingEnabled() allocates the RT and calls IStreamingManager::AddViewInformation so textures load correctly even when the player pawn is far away. - RequestReadback() enqueues a non-blocking GPU→CPU copy; check IsReadbackReady() on a subsequent tick, then consume with ConsumePixels().
| Attribute | Value |
|---|---|
| Kind | Class |
| UE Macro | UCLASS |
| Inherits | UMjComponent |
| Blueprint Spawnable | ✅ Yes |
Properties¶
Public Properties¶
| Property | Type | Description |
|---|---|---|
Pos |
FVector |
|
Quat |
FQuat |
|
fovy |
float |
|
ipd |
float |
|
output |
float |
|
target |
FString |
|
TrackingMode |
EMjCameraTrackingMode | |
Projection |
EMjCameraProjection | |
CaptureMode |
EMjCameraMode | What this camera captures. Read at SetStreamingEnabled(true) time — |
DepthNearCm |
float |
Near clip plane for Depth capture, centimetres. Values below this read as 0. |
DepthFarCm |
float |
Far clip plane for Depth capture, centimetres. Values beyond read as the maximum. |
StreamingBoost |
float |
Boost factor passed to IStreamingManager::AddViewInformation. |
CaptureComponent |
USceneCaptureComponent2D* |
The underlying SceneCaptureComponent2D. Capture is disabled by default. |
RenderTarget |
UTextureRenderTarget2D* |
The render target. Null until SetStreamingEnabled(true) is first called. |
bEnableZmqBroadcast |
bool |
If true, the camera will automatically broadcast its frames over ZeroMQ when streaming is enabled. |
ZmqEndpoint |
FString |
The ZMQ Endpoint for this specific camera (e.g., tcp://0.0.0.0:5558). Must be unique per camera. |
Pos¶
Override-enabled (
bOverride_Pos)
- Type: FVector
- Editor: ✏️ EditAnywhere
- Blueprint: 🔵 ReadWrite
- Category: MuJoCo|MjCamera|Spatial Pose
Quat¶
Override-enabled (
bOverride_Quat)
- Type: FQuat
- Editor: ✏️ EditAnywhere
- Blueprint: 🔵 ReadWrite
- Category: MuJoCo|MjCamera|Orientation
fovy¶
Override-enabled (
bOverride_fovy)
- Type: float
- Editor: ✏️ EditAnywhere
- Blueprint: 🔵 ReadWrite
- Category: MuJoCo|MjCamera
ipd¶
Override-enabled (
bOverride_ipd)
- Type: float
- Editor: ✏️ EditAnywhere
- Blueprint: 🔵 ReadWrite
- Category: MuJoCo|MjCamera
output¶
Override-enabled (
bOverride_output)
- Type: float
- Editor: ✏️ EditAnywhere
- Blueprint: 🔵 ReadWrite
- Category: MuJoCo|MjCamera
target¶
Override-enabled (
bOverride_target)
- Type: FString
- Editor: ✏️ EditAnywhere
- Blueprint: 🔵 ReadWrite
- Category: MuJoCo|MjCamera
TrackingMode¶
Override-enabled (
bOverride_TrackingMode)
- Type: EMjCameraTrackingMode
- Editor: ✏️ EditAnywhere
- Blueprint: 🔵 ReadWrite
- Category: MuJoCo|MjCamera
Projection¶
Override-enabled (
bOverride_Projection)
- Type: EMjCameraProjection
- Editor: ✏️ EditAnywhere
- Blueprint: 🔵 ReadWrite
- Category: MuJoCo|MjCamera
CaptureMode¶
What this camera captures. Read at SetStreamingEnabled(true) time —
- Type: EMjCameraMode
- Editor: ✏️ EditAnywhere
- Blueprint: 🔵 ReadWrite
- Category: MuJoCo|Camera
DepthNearCm¶
Near clip plane for Depth capture, centimetres. Values below this read as 0.
- Type: float
- Editor: ✏️ EditAnywhere
- Blueprint: 🔵 ReadWrite
- Category: MuJoCo|Camera
- Notes: Override-enabled (
CaptureMode)
DepthFarCm¶
Far clip plane for Depth capture, centimetres. Values beyond read as the maximum.
- Type: float
- Editor: ✏️ EditAnywhere
- Blueprint: 🔵 ReadWrite
- Category: MuJoCo|Camera
- Notes: Override-enabled (
CaptureMode)
StreamingBoost¶
Boost factor passed to IStreamingManager::AddViewInformation.
- Type: float
- Editor: ✏️ EditAnywhere
- Blueprint: 🔵 ReadWrite
- Category: MuJoCo|Camera|Streaming
CaptureComponent¶
The underlying SceneCaptureComponent2D. Capture is disabled by default.
- Type: USceneCaptureComponent2D*
- Editor: 👁 VisibleAnywhere
- Blueprint: 🟢 ReadOnly
- Category: MuJoCo|Camera
RenderTarget¶
The render target. Null until SetStreamingEnabled(true) is first called.
- Type: UTextureRenderTarget2D*
- Editor: 👁 VisibleAnywhere
- Blueprint: 🟢 ReadOnly
- Category: MuJoCo|Camera
bEnableZmqBroadcast¶
If true, the camera will automatically broadcast its frames over ZeroMQ when streaming is enabled.
- Type: bool
- Editor: ✏️ EditAnywhere
- Blueprint: 🔵 ReadWrite
- Category: MuJoCo|Camera|Network
ZmqEndpoint¶
The ZMQ Endpoint for this specific camera (e.g., tcp://0.0.0.0:5558). Must be unique per camera.
- Type: FString
- Editor: ✏️ EditAnywhere
- Blueprint: 🔵 ReadWrite
- Category: MuJoCo|Camera|Network
Functions¶
Public Functions¶
General¶
| Function | Returns | Description |
|---|---|---|
ExportTo() |
void | Exports camera properties to a MuJoCo spec camera structure. |
ImportFromXml() |
void | Imports properties from a MuJoCo XML |
ExportTo¶
Exports camera properties to a MuJoCo spec camera structure.
- Signature:
ExportTo(mjsCamera*Element,mjsDefault*def)
ImportFromXml¶
Imports properties from a MuJoCo XML
node.
- Signature:
ImportFromXml(const class FXmlNode*Node, const struct FMjCompilerSettings& CompilerSettings)
MuJoCo|Camera¶
| Function | Returns | Description |
|---|---|---|
SetStreamingEnabled() |
void | Allocates the render target and begins streaming / scene capture. |
RequestReadback() |
void | Enqueues a non-blocking asynchronous GPU→CPU pixel readback. |
IsReadbackReady() |
bool |
Returns true when the GPU→CPU copy started by RequestReadback() is complete. |
ConsumePixels() |
TArray<FColor> |
Consumes and returns the pixel array from the last completed readback. |
GetActualZmqEndpoint() |
FString |
Returns the ZMQ endpoint actually bound (may differ from ZmqEndpoint if auto-incremented). |
GetSelf() |
UMjCamera* | Returns the bound camera component pointer (for UI wiring). |
SetStreamingEnabled¶
Allocates the render target and begins streaming / scene capture.
- Signature:
SetStreamingEnabled(boolbEnable) - Blueprint: 🔵 Callable
RequestReadback¶
Enqueues a non-blocking asynchronous GPU→CPU pixel readback.
- Signature:
RequestReadback() - Blueprint: 🔵 Callable
IsReadbackReady¶
Returns true when the GPU→CPU copy started by RequestReadback() is complete.
- Signature:
IsReadbackReady() - Blueprint: 🔵 Callable
- Returns: bool
ConsumePixels¶
Consumes and returns the pixel array from the last completed readback.
- Signature:
ConsumePixels() - Blueprint: 🔵 Callable
- Returns: TArray
GetActualZmqEndpoint¶
Returns the ZMQ endpoint actually bound (may differ from ZmqEndpoint if auto-incremented).
- Signature:
GetActualZmqEndpoint() - Blueprint: 🔵 Callable
- Returns: FString
GetSelf¶
Returns the bound camera component pointer (for UI wiring).
- Signature:
GetSelf() - Blueprint: 🔵 Callable
- Returns: UMjCamera*
Private Functions¶
General¶
| Function | Returns | Description |
|---|---|---|
RefreshHiddenComponentsFromSegPools() |
void | For non-seg modes: rebuild HiddenComponents from the currently-live seg pools. |
RefreshHiddenComponentsFromSegPools¶
For non-seg modes: rebuild HiddenComponents from the currently-live seg pools.
- Signature:
RefreshHiddenComponentsFromSegPools()