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

AMRUKRoom Class

Extends AActor
Represents a room in the MRUK. A room holds (MRUK)Anchors as children for entities such as Desk, Floor, Ceiling, Walls, etc. Those entities are defined with their label. It also provides events which will be triggered when an anchor has been added, removed or updated from space setup.
This room class calculates different helper properties such as Outline, Edges, Bounds and provides room functions as helpers such as determine if a point in space (XYZ) is inside the room, generating points on surfaces, generate points in room (floating), raycasts and more.

Constructors

AMRUKRoom ( ObjectInitializer )
Signature
AMRUKRoom::AMRUKRoom(const FObjectInitializer &ObjectInitializer)
Parameters
ObjectInitializer: const FObjectInitializer &

Fields

AllAnchors : TArray< TObjectPtr< AMRUKAnchor > >
All anchors of this room.
Signature
TArray<TObjectPtr<AMRUKAnchor> > AMRUKRoom::AllAnchors
AnchorUUID : FOculusXRUUID
The anchors UUID
Signature
FOculusXRUUID AMRUKRoom::AnchorUUID
CeilingAnchor_DEPRECATED : TObjectPtr< AMRUKAnchor >
The ceiling anchor of this room. Deprecated, only kept for compatibility.
Signature
TObjectPtr<AMRUKAnchor> AMRUKRoom::CeilingAnchor_DEPRECATED
CeilingAnchors : TArray< TObjectPtr< AMRUKAnchor > >
The ceiling anchors of this room.
Signature
TArray<TObjectPtr<AMRUKAnchor> > AMRUKRoom::CeilingAnchors
FloorAnchor_DEPRECATED : TObjectPtr< AMRUKAnchor >
The floor anchor of this room. Deprecated, only kept for compatibility.
Signature
TObjectPtr<AMRUKAnchor> AMRUKRoom::FloorAnchor_DEPRECATED
FloorAnchors : TArray< TObjectPtr< AMRUKAnchor > >
The floor anchors of this room.
Signature
TArray<TObjectPtr<AMRUKAnchor> > AMRUKRoom::FloorAnchors
GlobalMeshAnchor : TObjectPtr< AMRUKAnchor >
The global mesh anchor of this room.
Signature
TObjectPtr<AMRUKAnchor> AMRUKRoom::GlobalMeshAnchor
OnAnchorCreated : FOnAnchorCreated
Event that gets fired if a new anchor was created in this room.
Signature
FOnAnchorCreated AMRUKRoom::OnAnchorCreated
OnAnchorRemoved : FOnAnchorRemoved
Event that gets fired if a anchor gets removed from this room.
Signature
FOnAnchorRemoved AMRUKRoom::OnAnchorRemoved
OnAnchorUpdated : FOnAnchorUpdated
Event that gets fired if a anchor in this room was updated. E.g. volume or plane changed.
Signature
FOnAnchorUpdated AMRUKRoom::OnAnchorUpdated
RoomBounds : FBox
Bounds of the room.
Signature
FBox AMRUKRoom::RoomBounds
RoomEdges_DEPRECATED : TArray< FVector >
Edges of the room. Only valid when using a single floor.
Signature
TArray<FVector> AMRUKRoom::RoomEdges_DEPRECATED
RoomMesh : TObjectPtr< UMRUKRoomMesh >
Contains the mesh data for the room, including vertices and faces. This property can be used to access the geometric representation of the room. This property will be null if Scene Model V1 was chosen when loading the scene.
Signature
TObjectPtr<UMRUKRoomMesh> AMRUKRoom::RoomMesh
SceneModel : EMRUKSceneModel
The scene model from which the room was loaded.
Signature
EMRUKSceneModel AMRUKRoom::SceneModel
SeatAnchors : TArray< TObjectPtr< AMRUKAnchor > >
All anchors which are possible to sit on.
Signature
TArray<TObjectPtr<AMRUKAnchor> > AMRUKRoom::SeatAnchors
SpaceHandle : FOculusXRUInt64
The space handle of this anchor
Signature
FOculusXRUInt64 AMRUKRoom::SpaceHandle
WallAnchors : TArray< TObjectPtr< AMRUKAnchor > >
The wall anchors of this room.
Signature
TArray<TObjectPtr<AMRUKAnchor> > AMRUKRoom::WallAnchors

Friend Declarations

FMRUKSpec : class
Signature
friend class FMRUKSpec

Member Functions

AddAnchorToRoom ( Anchor )
Signature
void AMRUKRoom::AddAnchorToRoom(AMRUKAnchor *Anchor)
Parameters
Anchor: AMRUKAnchor *
Returns
void
AttachProceduralMeshToWalls ( WallTextureCoordinateModes , CutHoleLabels , ProceduralMaterial )
Attach a procedural mesh to the walls. This is done at the room level to ensure the UV coordinates can be done in a seamless way if desired.
Signature
void AMRUKRoom::AttachProceduralMeshToWalls(const TArray< FMRUKTexCoordModes > &WallTextureCoordinateModes, const TArray< FString > &CutHoleLabels, UMaterialInterface *ProceduralMaterial=nullptr)
Parameters
WallTextureCoordinateModes: const TArray< FMRUKTexCoordModes > &  Mode of the wall texture coordinates.
CutHoleLabels: const TArray< FString > &  Labels for which holes should be cut into the plane meshes
ProceduralMaterial: UMaterialInterface *  Material to apply on top of the procedural mesh.
Returns
void
AttachProceduralMeshToWalls ( CutHoleLabels , ProceduralMaterial )
Signature
void AMRUKRoom::AttachProceduralMeshToWalls(const TArray< FString > &CutHoleLabels, UMaterialInterface *ProceduralMaterial=nullptr)
Parameters
CutHoleLabels: const TArray< FString > &
ProceduralMaterial: UMaterialInterface *
Returns
void
ClearRoom ()
Clear all anchors from the room.
Signature
void AMRUKRoom::ClearRoom()
Returns
void
ComputeCentroid ( Z )
Compute the centroid of the room by taking the points of the floor boundary. The centroid may be outside of the room for non convex rooms. The Z value determines the height of the resulting vectors and ranges from 0 to 1. A Z value of 1 corresponds to the ceiling positions Z, while a Z value of 0 corresponds to the floor positions Z. Any value between 0 and 1 will interpolate between the two values. In case the floor and ceiling anchors haven't been loaded yet a zero vector will be returned.
Signature
FVector AMRUKRoom::ComputeCentroid(double Z=0.5)
Parameters
Z: double  Value used for interpolation of Z.
Returns
FVector  The centroid.
ComputeWallMeshUVAdjustments ( WallTextureCoordinateModes , OutAnchorsWithPlaneUVs )
Compute the wall mesh texture coordinate adjustments that are needed to generate proper texture coordinates for the walls.
Signature
void AMRUKRoom::ComputeWallMeshUVAdjustments(const TArray< FMRUKTexCoordModes > &WallTextureCoordinateModes, TArray< FMRUKAnchorWithPlaneUVs > &OutAnchorsWithPlaneUVs)
Parameters
WallTextureCoordinateModes: const TArray< FMRUKTexCoordModes > &  The texture coordinate mode to use for the walls.
OutAnchorsWithPlaneUVs: TArray< FMRUKAnchorWithPlaneUVs > &  The computed texture coordinate adjustment with the wall anchor.
Returns
void
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam ()
Signature
AMRUKRoom::DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnAnchorUpdated, AMRUKAnchor *, Anchor)
Parameters
FOnAnchorUpdated
Anchor
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam ()
Signature
AMRUKRoom::DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnAnchorCreated, AMRUKAnchor *, Anchor)
Parameters
FOnAnchorCreated
Anchor
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam ()
Signature
AMRUKRoom::DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnAnchorRemoved, AMRUKAnchor *, Anchor)
Parameters
FOnAnchorRemoved
Anchor
DoesRoomHave ( Labels )
Check if the room does have any of the labels.
Signature
bool AMRUKRoom::DoesRoomHave(const TArray< FString > &Labels)
Parameters
Labels: const TArray< FString > &  The labels to check.
Returns
bool  Whether the label was found in the room.
EndPlay ( Reason )
Signature
void AMRUKRoom::EndPlay(EEndPlayReason::Type Reason) override
Parameters
Reason: EEndPlayReason::Type
Returns
void
FindAnchorByUuid ( Uuid )
Signature
AMRUKAnchor * AMRUKRoom::FindAnchorByUuid(const FOculusXRUUID &Uuid)
Parameters
Uuid: const FOculusXRUUID &
Returns
AMRUKAnchor *
GenerateProceduralSceneMesh ( Material )
Generate the triangle mesh of the scene mesh anchor. For the generation successful the room needs to have an anchor that is labeled with GLOBAL_MESH.
Signature
bool AMRUKRoom::GenerateProceduralSceneMesh(UMaterialInterface *Material)
Parameters
Material: UMaterialInterface *  Material to apply on the generated triangle mesh.
Returns
bool  On Success true, otherwise false.
GenerateRandomPositionInRoom ( OutPosition , MinDistanceToSurface , AvoidVolumes )
Generate a uniform random position within the room.
Signature
bool AMRUKRoom::GenerateRandomPositionInRoom(FVector &OutPosition, float MinDistanceToSurface=0.0f, bool AvoidVolumes=false)
Parameters
OutPosition: FVector &  Contains the randomly generated position.
MinDistanceToSurface: float  The minimum distance between the generated position and the closest surface/volume.
AvoidVolumes: bool  If true then the position will not be inside a volume and min distance away from it.
Returns
bool  Return true if success otherwise false. If this fails it can be because the min distance to surface is too large.
GenerateRandomPositionInRoomFromStream ( OutPosition , RandomStream , MinDistanceToSurface , AvoidVolumes )
Generate a uniform random position within the room from a random stream.
Signature
bool AMRUKRoom::GenerateRandomPositionInRoomFromStream(FVector &OutPosition, const FRandomStream &RandomStream, float MinDistanceToSurface=0.0f, bool AvoidVolumes=false)
Parameters
OutPosition: FVector &  Contains the randomly generated position.
RandomStream: const FRandomStream &  A random generator used to generate the position on the plane.
MinDistanceToSurface: float  The minimum distance between the generated position and the closest surface/volume.
AvoidVolumes: bool  If true then the position will not be inside a volume and min distance away from it.
Returns
bool  Return true if success otherwise false. If this fails it can be because the min distance to surface is too large.
GenerateRandomPositionOnSurface ( SpawnLocation , MinDistanceToEdge , LabelFilter , OutPosition , OutNormal )
Generates a random position on the surface of a given spawn location, while ensuring that the generated position is at least MinDistanceToEdge away from any edges. The LabelFilter parameter allows you to specify which types of surfaces should be considered for generating the random position.
Signature
bool AMRUKRoom::GenerateRandomPositionOnSurface(EMRUKSpawnLocation SpawnLocation, float MinDistanceToEdge, FMRUKLabelFilter LabelFilter, FVector &OutPosition, FVector &OutNormal)
Parameters
SpawnLocation: EMRUKSpawnLocation  The location where the random position should be generated.
MinDistanceToEdge: float  The minimum distance from the edge that the generated position must have.
LabelFilter: FMRUKLabelFilter  A filter that specifies which types of surfaces should be considered for generating the random position.
OutPosition: FVector &  The generated position.
OutNormal: FVector &  The normal vector of the generated position.
Returns
bool  A boolean value indicating whether a valid position was found. If no valid position could be found, both OutPosition and OutNormal will be set to zero vectors.
GetAnchorsByLabel ( Label )
Finds all anchors in this room that have the given label attached.
Signature
TArray< AMRUKAnchor * > AMRUKRoom::GetAnchorsByLabel(const FString &Label) const
Parameters
Label: const FString &  The label to search for.
Returns
TArray< AMRUKAnchor * >  An array off anchors with the given label.
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 * AMRUKRoom::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.
GetCeilingAnchor ()
Signature
AMRUKAnchor * AMRUKRoom::GetCeilingAnchor() const
Returns
AMRUKAnchor *
GetFirstAnchorByLabel ( Label )
Finds the first anchor in this room that has the given label attached.
Signature
AMRUKAnchor * AMRUKRoom::GetFirstAnchorByLabel(const FString &Label) const
Parameters
Label: const FString &  The label to search for.
Returns
AMRUKAnchor *  If found, the Anchor that has the label attached. Otherwise a null pointer.
GetFloorAnchor ()
Signature
AMRUKAnchor * AMRUKRoom::GetFloorAnchor() const
Returns
AMRUKAnchor *
GetKeyWall ( Tolerance )
Return the longest wall in the room that has no other walls behind it.
Signature
AMRUKAnchor * AMRUKRoom::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.
Signature
AMRUKAnchor * AMRUKRoom::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.
GetRoomEdges ()
Signature
TArray< FVector > AMRUKRoom::GetRoomEdges() const
Returns
TArray< FVector >
InitializeRoom ()
Signature
void AMRUKRoom::InitializeRoom()
Returns
void
IsPositionInRoom ( Position , TestVerticalBounds )
Check whether the position is inside the room or not.
Signature
bool AMRUKRoom::IsPositionInRoom(const FVector &Position, bool TestVerticalBounds=true)
Parameters
Position: const FVector &  The position in world space to check.
TestVerticalBounds: bool  Whether the room should be constrained by vertical bounds or not in the check.
Returns
bool  Whether the position is inside the room or not.
IsPositionInSceneVolume ( WorldPosition , TestVerticalBounds , Tolerance )
Checks if the given position is on or inside of any scene volume in the room. Floor, ceiling and wall anchors will be excluded from the search.
Signature
AMRUKAnchor * AMRUKRoom::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.
IsWallAnchor ( Anchor )
Check if the given anchor is a wall anchor.
Signature
bool AMRUKRoom::IsWallAnchor(AMRUKAnchor *Anchor) const
Parameters
Anchor: AMRUKAnchor *  The anchor to check.
Returns
bool  Whether the anchor is a wall anchor or not.
LoadGlobalMeshFromDevice ( Material )
Deprecated, use GenerateProceduralSceneMesh instead. Load the triangle mesh of the global mesh anchor if it's available.
Signature
bool AMRUKRoom::LoadGlobalMeshFromDevice(UMaterialInterface *Material=nullptr)
Parameters
Material: UMaterialInterface *  The Material to show if the global mesh is visible.
Returns
bool  On success true, otherwise false.
LoadGlobalMeshFromJsonString ( JsonString , Material )
Deprecated, use GenerateProceduralSceneMesh instead. Load the triangle mesh of the global mesh anchor. For this function to succeed you need to make sure to have a global mesh specified in the JSON file. Not every JSON file has a global mesh in it.
Signature
bool AMRUKRoom::LoadGlobalMeshFromJsonString(const FString &JsonString, UMaterialInterface *Material=nullptr)
Parameters
JsonString: const FString &  The string with the JSON data.
Material: UMaterialInterface *  Material to apply on the global mesh.
Returns
bool  On Success true, otherwise false.
Raycast ( Origin , Direction , MaxDist , LabelFilter , OutHit )
Cast a ray and return the closest hit anchor
Signature
AMRUKAnchor * AMRUKRoom::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 volume and plane bounds in this room. The order of the hits in the array is not specified.
Signature
bool AMRUKRoom::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
RemoveAnchor ( Anchor )
Signature
void AMRUKRoom::RemoveAnchor(AMRUKAnchor *Anchor)
Parameters
Anchor: AMRUKAnchor *
Returns
void
SpawnAnchor ()
Signature
AMRUKAnchor * AMRUKRoom::SpawnAnchor()
Returns
AMRUKAnchor *
SpawnInterior ( SpawnGroups , CutHoleLabels , ProceduralMaterial , ShouldFallbackToProcedural )
Spawn meshes on the position of the anchors of the 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 * > AMRUKRoom::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 * >  All spawned interior actors.
SpawnInteriorFromStream ( SpawnGroups , RandomStream , CutHoleLabels , ProceduralMaterial , ShouldFallbackToProcedural )
Spawn meshes on the position of the anchors of the 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 * > AMRUKRoom::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 wich 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 * >  All spawned interior actors.
TryGetClosestSeatPose ( RayOrigin , RayDirection , OutSeatTransform )
Finds the closest seat given a ray.
Signature
AMRUKAnchor * AMRUKRoom::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 , OutSurfaceDistance , LabelFilter , MaxDistance )
Get the position on the surface that is closest to the given position with respect to the distance.
Signature
AMRUKAnchor * AMRUKRoom::TryGetClosestSurfacePosition(const FVector &WorldPosition, FVector &OutSurfacePosition, double &OutSurfaceDistance, 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.
OutSurfaceDistance: double &  The distance between WorldPosition and OutSurfacePosition.
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.