API reference
API reference
Select your platform
No SDKs available
No versions available

UMRUKSubsystem Class

Extends UGameInstanceSubsystem, FTickableGameObject
The Mixed Reality Utility Kit subsystem.
This subsystem acts as a container for scene/anchor data. It has methods to load the scene data from the device or a JSON file. After the scene data has been loaded it will be stored inside the subsystem to make it possible to query the data from everywhere. In addition, it offers methods to fulfill queries on the scene data like ray casts or simple content placement.
The subsystem only contains core functionality that is useful for most cases. More specific functionality is part of actors. For example, if your goal is to spawn meshes in the place of scene anchors you can place the AMRUKAnchorActorSpawner in the level to do this. When a level loads you would first load the anchor data from the device with this subsystem by calling LoadSceneFromDevice() and then the AMRUKAnchorActorSpawner will listen for the subsystem to load the scene data and then spawn the actors accordingly.
You can expect methods in this subsystem to take all loaded rooms into consideration when computing. If you want to use a method only on a single specific room, there is most of the time a method with the same name on the AMRUKRoom.

Fields

EnableWorldLock : bool
When world locking is enabled the position of the VR Pawn will be adjusted each frame to ensure the room anchors are where they should be relative to the camera position. This is necessary to ensure the position of the virtual objects in the world do not get out of sync with the real world.
Signature
bool UMRUKSubsystem::EnableWorldLock
OnCaptureComplete : FOnCaptureComplete
An event that will trigger when the capture flow completed. The Success parameter indicates whether the scene was captured successfully or not.
Signature
FOnCaptureComplete UMRUKSubsystem::OnCaptureComplete
OnRoomCreated : FOnRoomCreated
An event that gets fired after a room has been created.
Signature
FOnRoomCreated UMRUKSubsystem::OnRoomCreated
OnRoomRemoved : FOnRoomRemoved
An event that gets fired when a room gets removed.
Signature
FOnRoomRemoved UMRUKSubsystem::OnRoomRemoved
OnRoomUpdated : FOnRoomUpdated
An event that gets fired after a room has been updated.
Signature
FOnRoomUpdated UMRUKSubsystem::OnRoomUpdated
OnSceneLoaded : FOnLoaded
An event that will trigger when a scene is loaded either from Device or from JSON. The Success parameter indicates whether the scene was loaded successfully or not.
Signature
FOnLoaded UMRUKSubsystem::OnSceneLoaded
Rooms : TArray< TObjectPtr< AMRUKRoom > >
Contains a list of rooms that are tracked by the mixed reality utility kit subsystem.
Signature
TArray<TObjectPtr<AMRUKRoom> > UMRUKSubsystem::Rooms
SceneLoadStatus : EMRUKInitStatus
The status of the scene loading. When loading from device this is an asynchronous process so will be in the Busy state until it moves to Complete or Failed.
Signature
EMRUKInitStatus UMRUKSubsystem::SceneLoadStatus

Friend Declarations

FMRUKDistanceMapSpec : class
Signature
friend class FMRUKDistanceMapSpec
FMRUKSpec : class
Signature
friend class FMRUKSpec

Member Functions

ClearScene ()
Removes and clears every room.
Signature
void UMRUKSubsystem::ClearScene()
Returns
void
CreateEnvironmentRaycaster ()
This function creates an environment raycaster, which is used to perform raycasting operations against the device depth. Unlike Raycast() and RaycastAll(), no space setup is required for performing these raycasts. It initializes the necessary components and resources required for the raycasting process. The environment raycaster may take a few frames to initialize. During this time, its status can be checked using the EnvironmentRaycasterStatus() function. Alternatively, you can directly call RaycastEnvironment(), which will return a status of NotReady if the raycaster is not yet ready.
Signature
void UMRUKSubsystem::CreateEnvironmentRaycaster()
Returns
void
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam ()
Signature
UMRUKSubsystem::DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnLoaded, bool, Success)
Parameters
FOnLoaded
bool
Success
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam ()
Signature
UMRUKSubsystem::DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnCaptureComplete, bool, Success)
Parameters
FOnCaptureComplete
bool
Success
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam ()
Signature
UMRUKSubsystem::DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnRoomCreated, AMRUKRoom *, Room)
Parameters
FOnRoomCreated
Room
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam ()
Signature
UMRUKSubsystem::DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnRoomUpdated, AMRUKRoom *, Room)
Parameters
FOnRoomUpdated
Room
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam ()
Signature
UMRUKSubsystem::DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnRoomRemoved, AMRUKRoom *, Room)
Parameters
FOnRoomRemoved
Room
Deinitialize ()
Signature
void UMRUKSubsystem::Deinitialize() override
Returns
void
DestroyEnvironmentRaycaster ()
Destroy the environment raycaster. This function is responsible for cleaning up and releasing any resources associated with the environment raycaster. It should be called when the raycaster is no longer needed to ensure proper resource management and avoid memory leaks.
Signature
void UMRUKSubsystem::DestroyEnvironmentRaycaster()
Returns
void
DiscoveryIsRunning ()
Signature
bool UMRUKSubsystem::DiscoveryIsRunning() const
Returns
bool
EnvironmentRaycasterStatus ()
Get the status of the environment raycaster. This function returns the current status of the environment raycaster, which indicates whether the raycaster is ready to perform raycasting operations, is still initializing, or has encountered an error.
Signature
EMRUKEnvironmentRaycasterStatus UMRUKSubsystem::EnvironmentRaycasterStatus() const
Returns
EMRUKEnvironmentRaycasterStatus  The current status of the environment raycaster.
GetActorClassBounds ( Actor )
Signature
FBox UMRUKSubsystem::GetActorClassBounds(TSubclassOf< AActor > Actor)
Parameters
Actor: TSubclassOf< AActor >
Returns
FBox
GetBestPoseFromRaycast ( RayOrigin , RayDirection , MaxDist , LabelFilter , OutPose , PositioningMethod )
Get a suggested pose (position & rotation) from a raycast to place objects on surfaces in the scene. There are different positioning modes available. Default just uses the position where the raycast hit the object. Edge snaps the position to the edge that is nearest to the user and Center simply centers the position on top of the surface.
Signature
AMRUKAnchor * UMRUKSubsystem::GetBestPoseFromRaycast(const FVector &RayOrigin, const FVector &RayDirection, double MaxDist, const FMRUKLabelFilter &LabelFilter, FTransform &OutPose, EMRUKPositioningMethod PositioningMethod=EMRUKPositioningMethod::Default)
Parameters
RayOrigin: const FVector &  The origin of the ray.
RayDirection: const FVector &  The direction of the ray.
MaxDist: double  The maximum distance the ray should travel.
LabelFilter: const FMRUKLabelFilter &  The label filter can be used to include/exclude certain labels from the search.
OutPose: FTransform &  The calculated pose.
PositioningMethod: EMRUKPositioningMethod  The method that should be used for determining the position on the surface.
Returns
AMRUKAnchor *  The anchor that was hit by the ray if any. Otherwise a null pointer.
GetCurrentRoom ()
Return the room that the headset is currently in. If the headset is not in any given room then it will return the room the headset was last in when this function was called. If the headset hasn't been in a valid room yet then return the first room in the list. If no rooms have been loaded yet then return null.
Signature
AMRUKRoom * UMRUKSubsystem::GetCurrentRoom() const
Returns
AMRUKRoom *
GetKeyWall ( Tolerance )
Return the longest wall in the current room that has no other walls behind it.
Signature
AMRUKAnchor * UMRUKSubsystem::GetKeyWall(double Tolerance=0.1)
Parameters
Tolerance: double  The tolerance to use when determining wall that are behind.
Returns
AMRUKAnchor *  The wall anchor that is the key wall in the room.
GetLargestSurface ( Label )
Return the largest surface for a given label in the current room.
Signature
AMRUKAnchor * UMRUKSubsystem::GetLargestSurface(const FString &Label)
Parameters
Label: const FString &  The label of the surfaces to search in.
Returns
AMRUKAnchor *  The anchor that has the largest surface if any. Otherwise, a null pointer.
GetRoomLayoutManager ()
Signature
class UOculusXRRoomLayoutManagerComponent * UMRUKSubsystem::GetRoomLayoutManager()
Initialize ( Collection )
Signature
void UMRUKSubsystem::Initialize(FSubsystemCollectionBase &Collection) override
Parameters
Collection: FSubsystemCollectionBase &
Returns
void
IsPositionInSceneVolume ( WorldPosition , TestVerticalBounds , Tolerance )
Checks if the given position is on or inside of any scene volume in the rooms. All rooms will be checked and the first anchors scene volume that has the point on or inside it will be returned.
Signature
AMRUKAnchor * UMRUKSubsystem::IsPositionInSceneVolume(const FVector &WorldPosition, bool TestVerticalBounds=true, double Tolerance=0.0)
Parameters
WorldPosition: const FVector &  The position in world space to check
TestVerticalBounds: bool  Whether the vertical bounds should be checked or not
Tolerance: double  Tolerance
Returns
AMRUKAnchor *  The anchor the WorldPosition is in. A null pointer otherwise.
LaunchSceneCapture ()
Launch the scene capture. After a successful capture the scene should be updated.
Signature
bool UMRUKSubsystem::LaunchSceneCapture()
Returns
bool  Whether the capture was successful.
LoadSceneFromDevice ( SceneModel )
Load rooms and anchors from the device. If the scene is already loaded the scene will be updated with the changes.
Signature
void UMRUKSubsystem::LoadSceneFromDevice(EMRUKSceneModel SceneModel=EMRUKSceneModel::V1)
Parameters
SceneModel: EMRUKSceneModel
Returns
void
LoadSceneFromJsonString ( String , SceneModel )
Load rooms and anchors from a JSON representation. If the scene is already loaded the scene will be updated with the changes.
Signature
void UMRUKSubsystem::LoadSceneFromJsonString(const FString &String, EMRUKSceneModel SceneModel=EMRUKSceneModel::V1)
Parameters
String: const FString &
SceneModel: EMRUKSceneModel
Returns
void
Raycast ( Origin , Direction , MaxDist , LabelFilter , OutHit )
Cast a ray and return the closest hit anchor in the scene.
Signature
AMRUKAnchor * UMRUKSubsystem::Raycast(const FVector &Origin, const FVector &Direction, float MaxDist, const FMRUKLabelFilter &LabelFilter, FMRUKHit &OutHit)
Parameters
Origin: const FVector &  Origin The origin of the ray.
Direction: const FVector &  Direction The direction of the ray.
MaxDist: float  The maximum distance the ray should travel.
LabelFilter: const FMRUKLabelFilter &  The label filter can be used to include/exclude certain labels from the search.
OutHit: FMRUKHit &  The closest hit.
Returns
AMRUKAnchor *  The anchor that the ray hit
RaycastAll ( Origin , Direction , MaxDist , LabelFilter , OutHits , OutAnchors )
Cast a ray and collect hits against the volumes and plane bounds in every room in the scene. The order of the hits in the array is not specified.
Signature
bool UMRUKSubsystem::RaycastAll(const FVector &Origin, const FVector &Direction, float MaxDist, const FMRUKLabelFilter &LabelFilter, TArray< FMRUKHit > &OutHits, TArray< AMRUKAnchor * > &OutAnchors)
Parameters
Origin: const FVector &  Origin The origin of the ray.
Direction: const FVector &  Direction The direction of the ray.
MaxDist: float  The maximum distance the ray should travel.
LabelFilter: const FMRUKLabelFilter &  The label filter can be used to include/exclude certain labels from the search.
OutHits: TArray< FMRUKHit > &  The hits the ray collected.
OutAnchors: TArray< AMRUKAnchor * > &  The anchors that were hit. Each anchor in this array corresponds to a entry at the same position in OutHits.
Returns
bool  Whether the ray hit anything
RaycastEnvironment ( Origin , Direction , MaxDistance )
Perform a raycast in the environment using the device's depth information.
This function casts a ray from the specified origin in the given direction and returns the first hit encountered within the specified maximum distance. It is necessary to call CreateEnvironmentRaycaster() before using this function to ensure that the environment raycaster is properly initialized. After raycasting is finished, DestroyEnvironmentRaycaster() can be called to clean up any resources associated with the raycaster.
The status of the returned FMRUKEnvironmentRaycastHit can be checked to determine if the raycast was successful.
Signature
FMRUKEnvironmentRaycastHit UMRUKSubsystem::RaycastEnvironment(const FVector &Origin, const FVector &Direction, float MaxDistance=0)
Parameters
Origin: const FVector &  The starting point of the ray in world space.
Direction: const FVector &  The direction in which the ray is cast.
MaxDistance: float  The maximum distance the ray should travel. Defaults to 0, which is treated as infinity.
Returns
FMRUKEnvironmentRaycastHit  A structure containing information about the raycast hit, if any.
SaveSceneToJsonString ()
Save all rooms and anchors to JSON. This JSON representation can than later be used by LoadSceneFromJsonString() to load the scene again.
Signature
FString UMRUKSubsystem::SaveSceneToJsonString()
Returns
FString  the JSON string.
SpawnInterior ( SpawnGroups , CutHoleLabels , ProceduralMaterial , ShouldFallbackToProcedural )
Spawn meshes on the position of the anchors of each room. The actors should have Z as up Y as right and X as forward. The pivot point should be in the bottom center.
Signature
TArray< AActor * > UMRUKSubsystem::SpawnInterior(const TMap< FString, FMRUKSpawnGroup > &SpawnGroups, const TArray< FString > &CutHoleLabels, UMaterialInterface *ProceduralMaterial=nullptr, bool ShouldFallbackToProcedural=true)
Parameters
SpawnGroups: const TMap< FString, FMRUKSpawnGroup > &  A map which tells to spawn which actor to a given label.
CutHoleLabels: const TArray< FString > &  Labels for which the generated mesh should have holes. Only works with planes.
ProceduralMaterial: UMaterialInterface *  Material to apply on top of the procedural mesh if any.
ShouldFallbackToProcedural: bool  Whether or not it should by default fallback to generating a procedural mesh if no actor class has been specified for a label.
Returns
TArray< AActor * >  The spawned actors.
SpawnInteriorFromStream ( SpawnGroups , RandomStream , CutHoleLabels , ProceduralMaterial , ShouldFallbackToProcedural )
Spawn meshes on the position of the anchors of each room from a random stream. The actors should have Z as up Y as right and X as forward. The pivot point should be in the bottom center.
Signature
TArray< AActor * > UMRUKSubsystem::SpawnInteriorFromStream(const TMap< FString, FMRUKSpawnGroup > &SpawnGroups, const FRandomStream &RandomStream, const TArray< FString > &CutHoleLabels, UMaterialInterface *ProceduralMaterial=nullptr, bool ShouldFallbackToProcedural=true)
Parameters
SpawnGroups: const TMap< FString, FMRUKSpawnGroup > &  A map which tells to spawn which actor to a given label.
RandomStream: const FRandomStream &  A random generator to choose randomly between actor classes if there a multiple for one label.
CutHoleLabels: const TArray< FString > &  Labels for which the generated mesh should have holes. Only works with planes.
ProceduralMaterial: UMaterialInterface *  Material to apply on top of the procedural mesh if any.
ShouldFallbackToProcedural: bool  Whether or not it should by default fallback to generating a procedural mesh if no actor class has been specified for a label.
Returns
TArray< AActor * >  The spawned actors.
SpawnRoom ()
Signature
AMRUKRoom * UMRUKSubsystem::SpawnRoom()
Returns
AMRUKRoom *
TryGetClosestSeatPose ( RayOrigin , RayDirection , OutSeatTransform )
Finds the closest seat given a ray.
Signature
AMRUKAnchor * UMRUKSubsystem::TryGetClosestSeatPose(const FVector &RayOrigin, const FVector &RayDirection, FTransform &OutSeatTransform)
Parameters
RayOrigin: const FVector &  The origin of the ray.
RayDirection: const FVector &  The direction of the ray.
OutSeatTransform: FTransform &  The seat pose.
Returns
AMRUKAnchor *  If any seat was found the Anchor that has seats available will be returned. Otherwise a null pointer.
TryGetClosestSurfacePosition ( WorldPosition , OutSurfacePosition , LabelFilter , MaxDistance )
Get the position on the surface that is closest to the given position with respect to the distance in all rooms.
Signature
AMRUKAnchor * UMRUKSubsystem::TryGetClosestSurfacePosition(const FVector &WorldPosition, FVector &OutSurfacePosition, const FMRUKLabelFilter &LabelFilter, double MaxDistance=0.0)
Parameters
WorldPosition: const FVector &  The position in world space from which the closest surface point should be found.
OutSurfacePosition: FVector &  The closest position on the closest surface if any. Otherwise zero.
LabelFilter: const FMRUKLabelFilter &  The label filter can be used to include/exclude certain labels from the search.
MaxDistance: double  The distance to which a closest surface position should be searched. Everything below or equal to zero will be treated as infinity.
Returns
AMRUKAnchor *  The Anchor on which the closest surface position was found or a null pointer otherwise.
UnregisterRoom ( Room )
Signature
void UMRUKSubsystem::UnregisterRoom(AMRUKRoom *Room)
Parameters
Room: AMRUKRoom *
Returns
void