Skip to content

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
Fovy float Vertical field of view in degrees (fovy= attribute).
Resolution FIntPoint Capture resolution (pixels). Defaults to 640×480.
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:/:5558). Must be unique per camera.

Fovy

Vertical field of view in degrees (fovy= attribute).

  • Type: float
  • Editor: ✏️ EditAnywhere
  • Blueprint: 🔵 ReadWrite
  • Category: MuJoCo|Camera

Resolution

Capture resolution (pixels). Defaults to 640×480.

  • Type: FIntPoint
  • Editor: ✏️ EditAnywhere
  • Blueprint: 🔵 ReadWrite
  • Category: MuJoCo|Camera

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:/: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 node.
ExportTo

Exports camera properties to a MuJoCo spec camera structure.

  • Signature: ExportTo(mjsCamera* cam, mjsDefault* def)
ImportFromXml

Imports properties from a MuJoCo XML node.

  • Signature: ImportFromXml(const class FXmlNode* Node)

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(bool bEnable)
  • 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*