Skip to content

FMujocoSpecWrapper

Helper class to simplify building a MuJoCo mjSpec structure from Unreal Engine components.

Handles coordinate system conversion, unique naming, and resource management (VFS for meshes). Acts as a bridge between high-level UE components and low-level MuJoCo C API.

Attribute Value
Kind Class

Properties

Public Properties

Property Type Description
Spec mjSpec*
VFS mjVFS*
MeshCacheSubDir FString Sub-directory name for mesh cache (set to articulation name).
CreatedBodyNames TArray<FString> storage of created body names for view reconstruction.

Spec

  • Type: mjSpec*

VFS

  • Type: mjVFS*

MeshCacheSubDir

Sub-directory name for mesh cache (set to articulation name).

  • Type: FString

CreatedBodyNames

storage of created body names for view reconstruction.

  • Type: TArray

Functions

Public Functions

General

Function Returns Description
FMujocoSpecWrapper() Constructor.
CreateBody() mjsBody* Creates a body in the spec.
CreateFrame() mjsFrame* Creates a frame in the spec attached to a specific parent body.
AddMeshAsset() FString Registers a mesh asset in the spec and VFS.
AddPrimitiveGeom() mjsGeom* Adds a primitive geom to a body (Direct creation).
AddMeshGeom() mjsGeom* Adds a mesh geom to a body (Direct creation).
AddFreeJoint() void Adds a legacy free joint.
AddDefault() void Adds a default class from a component.
ReconstructViews() TArray<BodyView> Reconstructs implementation views for binding after compilation.
PrepareMeshForMuJoCo() TArray<FString> Prepares a static mesh for MuJoCo (exports OBJ, logs it).
GetUniqueName() FString Generates a unique name for a MuJoCo object to avoid collisions.
FMujocoSpecWrapper

Constructor.

  • Signature: FMujocoSpecWrapper(mjSpec* InSpec, mjVFS* InVFS)
CreateBody

Creates a body in the spec.

  • Signature: CreateBody(const FString& Name, const FString& ParentName, const FTransform& WorldTransform)
  • Returns: mjsBody*
CreateFrame

Creates a frame in the spec attached to a specific parent body.

  • Signature: CreateFrame(const FString& Name, mjsBody* ParentBody, const FTransform& WorldTransform)
  • Returns: mjsFrame*
AddMeshAsset

Registers a mesh asset in the spec and VFS.

  • Signature: AddMeshAsset(const FString& MeshName, const FString& FilePath, const FVector& Scale)
  • Returns: FString
AddPrimitiveGeom

Adds a primitive geom to a body (Direct creation).

  • Signature: AddPrimitiveGeom(mjsBody* Body, mjtGeom Type, const FVector& Size, const FVector4& RGBA)
  • Returns: mjsGeom*
AddMeshGeom

Adds a mesh geom to a body (Direct creation).

  • Signature: AddMeshGeom(mjsBody* Body, FTransform RelTrans, const FString& MeshAssetName, const FString& GeomNameSuffix, const FVector4& RGBA)
  • Returns: mjsGeom*
AddFreeJoint

Adds a legacy free joint.

  • Signature: AddFreeJoint(mjsBody* Body, const FString& JointName)
AddDefault

Adds a default class from a component.

  • Signature: AddDefault(class UMjDefault* DefaultComp)
ReconstructViews

Reconstructs implementation views for binding after compilation.

  • Signature: ReconstructViews(const mjModel* m, mjData* d, const FString& Prefix)
  • Returns: TArray<BodyView>
PrepareMeshForMuJoCo

Prepares a static mesh for MuJoCo (exports OBJ, logs it).

  • Signature: PrepareMeshForMuJoCo(UStaticMeshComponent* SMC, bool bComplexMeshRequired, float CoACDThreshold)
  • Returns: TArray
GetUniqueName

Generates a unique name for a MuJoCo object to avoid collisions.

  • Signature: GetUniqueName(const FString& BaseName, mjtObj Type, const AActor* ContextActor)
  • Returns: FString