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...
See Also
https://developer.oculus.com/documentation/unreal/unreal-spatial-anchors/ for more information about anchors in the Mixed Reality Utility Kit.

Fields

The space handle of this anchor
The anchors UUID
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...
If the anchor has a plane attached to it, this represents the bounds of that plane in local coordinate space.
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.
If the anchor has a volume attached to it, this represents the bounds of that volume in local coordinate space.
Procedural mesh that is generated from the anchor geometry.
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.
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.
The room this anchor is placed in.
Positions of the global mesh. Only populated if the anchor is has the label GLOABL_MESH and the option UseSharedLibraryForAnchorLoading is set to true.
Indices of the global mesh. Only populated if the anchor is has the label GLOABL_MESH and the option UseSharedLibraryForAnchorLoading is set to true.

Member Functions

Check if a 2D position is within the boundary of the plane. The position should be in the local coordinate system NOT world coordinates.
Generate a uniform random position within the boundary of the plane.
Returns
The random position in local coordinate space.
Generate a uniform random position within the boundary of the plane from a random stream.
Parameters
RandomStream
A random generator used to generate the position on the plane.
Returns
The random position in local coordinate space.
Cast a ray and return the closest hit against the volume and plane bounds.
Parameters
Origin
Origin The origin of the ray.
Direction
Direction The direction of the ray.
MaxDist
The maximum distance the ray should travel.
OutHit
The closest hit.
ComponentTypes
The component types to include in the raycast.
Returns
Whether the ray hit anything
Cast a ray and collect hits against the volume and plane bounds. The order of the hits in the array is not specified.
Parameters
Origin
Origin The origin of the ray.
Direction
Direction The direction of the ray.
MaxDist
The maximum distance the ray should travel.
OutHits
The hits the ray collected.
ComponentTypes
The component types to include in the raycast.
Returns
Whether the ray hit anything
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.
Parameters
PlaneUVAdjustments
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
Labels for which the generated mesh should have holes. Only works with planes.
GenerateCollision
Whether to generate collision geometry or not
ProceduralMaterial
Material to use on the procedural generated mesh.
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.
Parameters
ProceduralMesh
The procedural mesh component that should be used to store the generated mesh.
PlaneUVAdjustments
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
Labels for which the generated mesh should have holes. Only works with planes.
GenerateCollision
Whether to generate collision geometry or not
Offset
A offset to make the procedural mesh slightly bigger or smaller than the anchors volume/plane.
Check if the anchor has the given label.
Parameters
Label
The label to check.
Returns
Whether the anchor has the given label.
Check if the anchor has any of the given labels.
Parameters
Labels
The labels to check.
Returns
Whether the anchor has any of the given labels.
Check if the anchor passes the given label filter
Parameters
LabelFilter
The labels to check.
Returns
Whether the anchor has any of the given labels.
Calculate the closest surface position on this anchor.
Parameters
TestPosition
The position in world space for which the closes surface position should be obtained.
OutSurfacePosition
The closest surface position
Returns
The distance between TestPosition and OutSurfacePosition
Checks if the given position is on or inside the volume bounds. Floor, ceiling and wall anchors will be excluded from the search.
Parameters
Position
The position in world space to check
TestVerticalBounds
Whether the vertical bounds should be checked or not
Tolerance
Tolerance
Returns
The anchor the WorldPosition is in. A null pointer otherwise.
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.
Returns
The forward facing direction.
Spawn a mesh on the position of this anchor. The actor should have Z as up, Y as right and X as forward.
Parameters
ActorClass
The Class to spawn at the anchors position.
MatchAspectRatio
If true the actor will be rotated to best match the aspect ratio of the volume (applies to volumes only).
CalculateFacingDirection
If true then actor will be rotated to face away from the closest wall (applies to volumes only).
ScalingMode
Sets how to scale the actor to fit the size of the volume/plane.
Returns
The spawned actor or null if nothing was spawned.
AMRUKAnchor
( const FObjectInitializer & ObjectInitializer )
void Setup
( const FOculusXRUUID & Uuid,
const FTransform & Transform,
const TArray< FString > & Labels,
const FBox2d & Plane,
const TArray< FVector2D > & Boundary2D,
const FBox3d & Volume,
TArray< FVector > MeshPositions,
TArray< int > MeshIndices )
Attach a procedural mesh to the anchor. The mesh will match the size, position and shape of the volume and/or plane.
Parameters
CutHoleLabels
Labels for which the generated mesh should have holes. Only works with planes. Example values: "WindowFrame", "DoorFrame".
GenerateCollision
Whether to generate collision geometry or not.
ProceduralMaterial
Material to use on the procedural generated mesh.

Protected Functions

void EndPlay
( EEndPlayReason::Type Reason )
Did you find this page helpful?
Thumbs up icon
Thumbs down icon