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

AMRUKAnchor Class

Extends AActor
Represents an anchor in the Mixed Reality Utility Kit. This combines an Unreal actor with the scene anchor. The actor is placed at the position of the anchor and the actor's rotation is set to match the rotation of the anchor. Provides functions to check if a position is inside the volume or plane of the anchor, raycast against the anchor, etc...

Constructors

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

Fields

AnchorUUID : FOculusXRUUID
The anchors UUID
Signature
FOculusXRUUID AMRUKAnchor::AnchorUUID
ChildAnchors : TArray< TObjectPtr< AMRUKAnchor > >
Array of all children attached to it, e.g. if this is a wall, it could have an array of door/window frames. If this is a desk it could have an array of screens on it.
Signature
TArray<TObjectPtr<AMRUKAnchor> > AMRUKAnchor::ChildAnchors
ParentAnchor : TObjectPtr< AMRUKAnchor >
Pointer to the parent anchor, e.g. if this is a door or window frame the parent will be a wall. If this is a screen it could have a desk parent.
Signature
TObjectPtr<AMRUKAnchor> AMRUKAnchor::ParentAnchor
PlaneBoundary2D : TArray< FVector2D >
If the anchor has a plane attached to it, this represents the boundary of it in local coordinate space. For rectangular boundaries this will be the same as the PlaneBounds.
Signature
TArray<FVector2D> AMRUKAnchor::PlaneBoundary2D
PlaneBounds : FBox2D
If the anchor has a plane attached to it, this represents the bounds of that plane in local coordinate space.
Signature
FBox2D AMRUKAnchor::PlaneBounds
ProceduralMeshComponent : TObjectPtr< UProceduralMeshComponent >
Procedural mesh that is generated from the anchor geometry.
Signature
TObjectPtr<UProceduralMeshComponent> AMRUKAnchor::ProceduralMeshComponent
Room : TObjectPtr< AMRUKRoom >
The room this anchor is placed in.
Signature
TObjectPtr<AMRUKRoom> AMRUKAnchor::Room
SceneMeshIndices : TArray< int >
Indices of the global mesh. Only populated if the anchor is has the label GLOABL_MESH and the option UseSharedLibraryForAnchorLoading is set to true.
Signature
TArray<int> AMRUKAnchor::SceneMeshIndices
SceneMeshPositions : TArray< FVector >
Positions of the global mesh. Only populated if the anchor is has the label GLOABL_MESH and the option UseSharedLibraryForAnchorLoading is set to true.
Signature
TArray<FVector> AMRUKAnchor::SceneMeshPositions
SemanticClassifications : TArray< FString >
The semantic classification of the anchor, also sometimes refered to as labels for short. This can be for example FLOOR, COUCH, TABLE, SCREEN, BED, LAMP, etc...
Signature
TArray<FString> AMRUKAnchor::SemanticClassifications
SpaceHandle : FOculusXRUInt64
The space handle of this anchor
Signature
FOculusXRUInt64 AMRUKAnchor::SpaceHandle
VolumeBounds : FBox
If the anchor has a volume attached to it, this represents the bounds of that volume in local coordinate space.
Signature
FBox AMRUKAnchor::VolumeBounds

Protected Member Functions

EndPlay ( Reason )
Signature
void AMRUKAnchor::EndPlay(EEndPlayReason::Type Reason) override
Parameters
Reason: EEndPlayReason::Type
Returns
void

Member Functions

AttachProceduralMesh ( PlaneUVAdjustments , CutHoleLabels , GenerateCollision , ProceduralMaterial )
Attach a procedural mesh to the anchor. The mesh will match the size, position and shape of the volume and/or plane if they are set.
Signature
void AMRUKAnchor::AttachProceduralMesh(TArray< FMRUKPlaneUV > PlaneUVAdjustments, const TArray< FString > &CutHoleLabels, bool GenerateCollision=true, UMaterialInterface *ProceduralMaterial=nullptr)
Parameters
PlaneUVAdjustments: TArray< FMRUKPlaneUV >  Scale and offset to apply to the UV texture coordinates. If more than one is specified then multiple UV texture coordinates are created (up to 4) and adjustments applied to each. This can be left empty in which case a single set of UV texture coordinates are created in the range 0 to 1 for the plane.
CutHoleLabels: const TArray< FString > &  Labels for which the generated mesh should have holes. Only works with planes.
GenerateCollision: bool  Whether to generate collision geometry or not
ProceduralMaterial: UMaterialInterface *  Material to use on the procedural generated mesh.
Returns
void
AttachProceduralMesh ( CutHoleLabels , GenerateCollision , ProceduralMaterial )
Attach a procedural mesh to the anchor. The mesh will match the size, position and shape of the volume and/or plane.
Signature
void AMRUKAnchor::AttachProceduralMesh(const TArray< FString > &CutHoleLabels={}, bool GenerateCollision=true, UMaterialInterface *ProceduralMaterial=nullptr)
Parameters
CutHoleLabels: const TArray< FString > &  Labels for which the generated mesh should have holes. Only works with planes. Example values: "WindowFrame", "DoorFrame".
GenerateCollision: bool  Whether to generate collision geometry or not.
ProceduralMaterial: UMaterialInterface *  Material to use on the procedural generated mesh.
Returns
void
GenerateProceduralAnchorMesh ( ProceduralMesh , PlaneUVAdjustments , CutHoleLabels , PreferVolume , GenerateCollision , Offset )
Generate a procedural mesh for the anchor. The mesh will match the size, position and shape of the volume and/or plane if they are set.
Signature
void AMRUKAnchor::GenerateProceduralAnchorMesh(UProceduralMeshComponent *ProceduralMesh, const TArray< FMRUKPlaneUV > &PlaneUVAdjustments, const TArray< FString > &CutHoleLabels, bool PreferVolume=false, bool GenerateCollision=true, double Offset=0.0)
Parameters
ProceduralMesh: UProceduralMeshComponent *  The procedural mesh component that should be used to store the generated mesh.
PlaneUVAdjustments: const TArray< FMRUKPlaneUV > &  Scale and offset to apply to the UV texture coordinates. If more than one is specified then multiple UV texture coordinates are created (up to 4) and adjustments applied to each. This can be left empty in which case a single set of UV texture coordinates are created in the range 0 to 1 for the plane.
CutHoleLabels: const TArray< FString > &  Labels for which the generated mesh should have holes. Only works with planes.
PreferVolume: bool
GenerateCollision: bool  Whether to generate collision geometry or not
Offset: double  A offset to make the procedural mesh slightly bigger or smaller than the anchors volume/plane.
Returns
void
GenerateRandomPositionOnPlane ()
Generate a uniform random position within the boundary of the plane.
Signature
FVector AMRUKAnchor::GenerateRandomPositionOnPlane()
Returns
FVector  The random position in local coordinate space.
GenerateRandomPositionOnPlaneFromStream ( RandomStream )
Generate a uniform random position within the boundary of the plane from a random stream.
Signature
FVector AMRUKAnchor::GenerateRandomPositionOnPlaneFromStream(const FRandomStream &RandomStream)
Parameters
RandomStream: const FRandomStream &  A random generator used to generate the position on the plane.
Returns
FVector  The random position in local coordinate space.
GetClosestSurfacePosition ( TestPosition , OutSurfacePosition )
Calculate the closest surface position on this anchor.
Signature
double AMRUKAnchor::GetClosestSurfacePosition(const FVector &TestPosition, FVector &OutSurfacePosition)
Parameters
TestPosition: const FVector &  The position in world space for which the closes surface position should be obtained.
OutSurfacePosition: FVector &  The closest surface position
Returns
double  The distance between TestPosition and OutSurfacePosition
GetFacingDirection ()
Gets a natural “forward” direction for anchors; for planes, this is always Z-forward. For volumes, it’s the X/Y cardinal axis that aligns best with the normal of the closest wall.
Signature
FVector AMRUKAnchor::GetFacingDirection() const
Returns
FVector  The forward facing direction.
HasAnyLabel ( Labels )
Check if the anchor has any of the given labels.
Signature
bool AMRUKAnchor::HasAnyLabel(const TArray< FString > &Labels) const
Parameters
Labels: const TArray< FString > &  The labels to check.
Returns
bool  Whether the anchor has any of the given labels.
HasLabel ( Label )
Check if the anchor has the given label.
Signature
bool AMRUKAnchor::HasLabel(const FString &Label) const
Parameters
Label: const FString &  The label to check.
Returns
bool  Whether the anchor has the given label.
IsPositionInBoundary ( Position )
Check if a 2D position is within the boundary of the plane. The position should be in the local coordinate system NOT world coordinates.
Signature
bool AMRUKAnchor::IsPositionInBoundary(const FVector2D &Position)
Parameters
Position: const FVector2D &
Returns
bool
IsPositionInVolumeBounds ( Position , TestVerticalBounds , Tolerance )
Checks if the given position is on or inside the volume bounds. Floor, ceiling and wall anchors will be excluded from the search.
Signature
bool AMRUKAnchor::IsPositionInVolumeBounds(const FVector &Position, bool TestVerticalBounds=true, double Tolerance=0.0)
Parameters
Position: const FVector &  The position in world space to check
TestVerticalBounds: bool  Whether the vertical bounds should be checked or not
Tolerance: double  Tolerance
Returns
bool  The anchor the WorldPosition is in. A null pointer otherwise.
PassesLabelFilter ( LabelFilter )
Check if the anchor passes the given label filter
Signature
bool AMRUKAnchor::PassesLabelFilter(const FMRUKLabelFilter &LabelFilter) const
Parameters
LabelFilter: const FMRUKLabelFilter &  The labels to check.
Returns
bool  Whether the anchor has any of the given labels.
Raycast ( Origin , Direction , MaxDist , OutHit , ComponentTypes )
Cast a ray and return the closest hit against the volume and plane bounds.
Signature
bool AMRUKAnchor::Raycast(const FVector &Origin, const FVector &Direction, float MaxDist, FMRUKHit &OutHit, UPARAM(meta=(Bitmask, BitmaskEnum="EMRUKComponentType")) int32 ComponentTypes=7)
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.
OutHit: FMRUKHit &  The closest hit.
ComponentTypes: UPARAM(meta=(Bitmask, BitmaskEnum="EMRUKComponentType")) int32  The component types to include in the raycast.
Returns
bool  Whether the ray hit anything
RaycastAll ( Origin , Direction , MaxDist , OutHits , ComponentTypes )
Cast a ray and collect hits against the volume and plane bounds. The order of the hits in the array is not specified.
Signature
bool AMRUKAnchor::RaycastAll(const FVector &Origin, const FVector &Direction, float MaxDist, TArray< FMRUKHit > &OutHits, UPARAM(meta=(Bitmask, BitmaskEnum="EMRUKComponentType")) int32 ComponentTypes=7)
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.
OutHits: TArray< FMRUKHit > &  The hits the ray collected.
ComponentTypes: UPARAM(meta=(Bitmask, BitmaskEnum="EMRUKComponentType")) int32  The component types to include in the raycast.
Returns
bool  Whether the ray hit anything
Setup ( Uuid , Space , Transform , Labels , Plane , Boundary2D , Volume , MeshPositions , MeshIndices )
Signature
void AMRUKAnchor::Setup(const FOculusXRUUID &Uuid, FOculusXRUInt64 Space, const FTransform &Transform, const TArray< FString > &Labels, const FBox2d &Plane, const TArray< FVector2D > &Boundary2D, const FBox3d &Volume, TArray< FVector > MeshPositions, TArray< int > MeshIndices)
Parameters
Uuid: const FOculusXRUUID &
Transform: const FTransform &
Labels: const TArray< FString > &
Plane: const FBox2d &
Boundary2D: const TArray< FVector2D > &
Volume: const FBox3d &
MeshPositions: TArray< FVector >
MeshIndices: TArray< int >
Returns
void
SpawnInterior ( ActorClass , MatchAspectRatio , CalculateFacingDirection , ScalingMode )
Spawn a mesh on the position of this anchor. The actor should have Z as up, Y as right and X as forward.
Signature
AActor * AMRUKAnchor::SpawnInterior(const TSubclassOf< class AActor > &ActorClass, bool MatchAspectRatio=false, bool CalculateFacingDirection=false, EMRUKSpawnerScalingMode ScalingMode=EMRUKSpawnerScalingMode::Stretch)
Parameters
ActorClass: const TSubclassOf< class AActor > &  The Class to spawn at the anchors position.
MatchAspectRatio: bool  If true the actor will be rotated to best match the aspect ratio of the volume (applies to volumes only).
CalculateFacingDirection: bool  If true then actor will be rotated to face away from the closest wall (applies to volumes only).
ScalingMode: EMRUKSpawnerScalingMode  Sets how to scale the actor to fit the size of the volume/plane.
Returns
AActor *  The spawned actor or null if nothing was spawned.