OpenXRSpatialEntityExtension
OpenXR extension that handles spatial entities.
OpenXR extension that handles spatial entities.
OpenXR extension that handles spatial entities and, when enabled, allows querying those spatial entities. This extension will also automatically manage XRTracker objects for static entities.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
OpenXRSpatialEntityExtensionConstructor
public OpenXRSpatialEntityExtension();Methods29
AddSpatialEntityRid
public Rid AddSpatialEntity(Rid spatialContext, ulong entityId, ulong entity);Registers an entity that was created directly on the OpenXR runtime.
| Name | Type | Default |
|---|---|---|
spatialContext | Rid | — |
entityId | ulong | — |
entity | ulong | — |
RidCreateSpatialContext2 overloads
public OpenXRFutureResult CreateSpatialContext(Reckfell.Collections.Array<OpenXRSpatialCapabilityConfigurationBaseHeader> capabilityConfigurations, OpenXRStructureBase next, Callable userCallback);Creates a new spatial context that handles entities for the provided capability configurations. capability_configurations is an array of OpenXRSpatialCapabilityConfigurationBaseHeader with the needed capability configuration data.
next is an optional parameter that can contain additional information for creating our spatial context.
Note: This is an asynchronous method and returns an OpenXRFutureResult object with which to track the status, discarding this object will not cancel the creation process.
On success user_callback will be called if specified. The result data for this function is the Rid for our spatial context - the argument will be the OpenXR result code (as an integer).
On failure failed_callback will be called if specified. The OpenXR result code will be supplied as an integer - the arguments will be the OpenXR result code (as an integer) and a boolean indicating whether requesting the result failed, or the execution failed.
| Name | Type | Default |
|---|---|---|
capabilityConfigurations | Reckfell.Collections.Array<OpenXRSpatialCapabilityConfigurationBaseHeader> | — |
next | OpenXRStructureBase | — |
userCallback | Callable | — |
OpenXRFutureResultpublic OpenXRFutureResult CreateSpatialContext(Reckfell.Collections.Array<OpenXRSpatialCapabilityConfigurationBaseHeader> capabilityConfigurations, OpenXRStructureBase next = null, Callable userCallback = default, Callable failedCallback = default);Creates a new spatial context that handles entities for the provided capability configurations. capability_configurations is an array of OpenXRSpatialCapabilityConfigurationBaseHeader with the needed capability configuration data.
next is an optional parameter that can contain additional information for creating our spatial context.
Note: This is an asynchronous method and returns an OpenXRFutureResult object with which to track the status, discarding this object will not cancel the creation process.
On success user_callback will be called if specified. The result data for this function is the Rid for our spatial context - the argument will be the OpenXR result code (as an integer).
On failure failed_callback will be called if specified. The OpenXR result code will be supplied as an integer - the arguments will be the OpenXR result code (as an integer) and a boolean indicating whether requesting the result failed, or the execution failed.
| Name | Type | Default |
|---|---|---|
capabilityConfigurations | Reckfell.Collections.Array<OpenXRSpatialCapabilityConfigurationBaseHeader> | — |
next | OpenXRStructureBase | null |
userCallback | Callable | default |
failedCallback | Callable | default |
OpenXRFutureResultDiscoverSpatialEntities2 overloads
public OpenXRFutureResult DiscoverSpatialEntities(Rid spatialContext, long[] componentTypes, OpenXRStructureBase next = null, Callable userCallback = default);Starts a new discovery query, this will gather all objects tracked by the spatial_context that have at least one of the component types specified in component_types.
next is an optional parameter that can contain additional information for executing the discovery query.
Note: This is an asynchronous method and returns an OpenXRFutureResult object with which to track the status, discarding this object will not cancel the discovery process. On success user_callback will be called if specified. The result data for this function is the Rid for our snapshot.
| Name | Type | Default |
|---|---|---|
spatialContext | Rid | — |
componentTypes | long[] | — |
next | OpenXRStructureBase | null |
userCallback | Callable | default |
OpenXRFutureResultpublic OpenXRFutureResult DiscoverSpatialEntities(Rid spatialContext, ReadOnlySpan<long> componentTypes, OpenXRStructureBase next, Callable userCallback);Starts a new discovery query, this will gather all objects tracked by the spatial_context that have at least one of the component types specified in component_types.
next is an optional parameter that can contain additional information for executing the discovery query.
Note: This is an asynchronous method and returns an OpenXRFutureResult object with which to track the status, discarding this object will not cancel the discovery process. On success user_callback will be called if specified. The result data for this function is the Rid for our snapshot.
| Name | Type | Default |
|---|---|---|
spatialContext | Rid | — |
componentTypes | ReadOnlySpan<long> | — |
next | OpenXRStructureBase | — |
userCallback | Callable | — |
OpenXRFutureResultDiscoverSpatialEntitiesWithComponentDataOpenXRFutureResult
public OpenXRFutureResult DiscoverSpatialEntitiesWithComponentData(Rid spatialContext, Reckfell.Collections.Array<OpenXRSpatialComponentData> componentData, OpenXRStructureBase next = null, Callable userCallback = default);Convenience method when the caller only has an Reckfell.Collections.Array of OpenXRSpatialComponentData and needs to discover spatial entities.
| Name | Type | Default |
|---|---|---|
spatialContext | Rid | — |
componentData | Reckfell.Collections.Array<OpenXRSpatialComponentData> | — |
next | OpenXRStructureBase | null |
userCallback | Callable | default |
OpenXRFutureResultFindSpatialEntityRid
public Rid FindSpatialEntity(ulong entityId);Returns the Rid for the specified spatial entity ID.
| Name | Type | Default |
|---|---|---|
entityId | ulong | — |
RidFreeSpatialContextvoid
public void FreeSpatialContext(Rid spatialContext);Frees a spatial context previously created when calling OpenXRSpatialEntityExtension.CreateSpatialContext. If the spatial context creation is still ongoing, the asynchronous process is cancelled.
| Name | Type | Default |
|---|---|---|
spatialContext | Rid | — |
FreeSpatialEntityvoid
public void FreeSpatialEntity(Rid entity);Frees an entity previously created when calling OpenXRSpatialEntityExtension.AddSpatialEntity or OpenXRSpatialEntityExtension.MakeSpatialEntity.
| Name | Type | Default |
|---|---|---|
entity | Rid | — |
FreeSpatialSnapshotvoid
public void FreeSpatialSnapshot(Rid spatialSnapshot);Frees a spatial snapshot previously created when calling OpenXRSpatialEntityExtension.DiscoverSpatialEntities. If the spatial snapshot creation is still ongoing, the asynchronous process is cancelled.
| Name | Type | Default |
|---|---|---|
spatialSnapshot | Rid | — |
GetFloatBufferfloat[]
public float[] GetFloatBuffer(Rid spatialSnapshot, ulong bufferId);Returns a buffer with floats from a buffer that was retrieved when taking a snapshot.
| Name | Type | Default |
|---|---|---|
spatialSnapshot | Rid | — |
bufferId | ulong | — |
float[]GetSpatialContextHandleulong
public ulong GetSpatialContextHandle(Rid spatialContext);Returns the OpenXR spatial context handle for this snapshot. Note: This method is intended to be used from ReckfellExtensions that implement spatial entity capability handlers.
| Name | Type | Default |
|---|---|---|
spatialContext | Rid | — |
ulongGetSpatialContextReadybool
public bool GetSpatialContextReady(Rid spatialContext);Returns true if the spatial context finished its creation and is ready to be used.
| Name | Type | Default |
|---|---|---|
spatialContext | Rid | — |
boolGetSpatialEntityContextRid
public Rid GetSpatialEntityContext(Rid entity);Returns the spatial context for this entity.
| Name | Type | Default |
|---|---|---|
entity | Rid | — |
RidGetSpatialEntityIdulong
public ulong GetSpatialEntityId(Rid entity);Returns the internal XrSpatialEntityIdEXT associated with the entity.
| Name | Type | Default |
|---|---|---|
entity | Rid | — |
ulongGetSpatialSnapshotContextRid
public Rid GetSpatialSnapshotContext(Rid spatialSnapshot);Returns the spatial context related to this spatial snapshot.
| Name | Type | Default |
|---|---|---|
spatialSnapshot | Rid | — |
RidGetSpatialSnapshotHandleulong
public ulong GetSpatialSnapshotHandle(Rid spatialSnapshot);Returns the OpenXR spatial snapshot handle for this snapshot. Note: This method is intended to be used from ReckfellExtensions that implement spatial entity capability handlers.
| Name | Type | Default |
|---|---|---|
spatialSnapshot | Rid | — |
ulongGetStringstring
public string GetString(Rid spatialSnapshot, ulong bufferId);Returns a string from a buffer that was retrieved when taking a snapshot.
| Name | Type | Default |
|---|---|---|
spatialSnapshot | Rid | — |
bufferId | ulong | — |
stringGetUint16Bufferint[]
public int[] GetUint16Buffer(Rid spatialSnapshot, ulong bufferId);Returns a buffer with 16 bit ints from a buffer that was retrieved when taking a snapshot.
| Name | Type | Default |
|---|---|---|
spatialSnapshot | Rid | — |
bufferId | ulong | — |
int[]GetUint32Bufferint[]
public int[] GetUint32Buffer(Rid spatialSnapshot, ulong bufferId);Returns a buffer with 32 bit ints from a buffer that was retrieved when taking a snapshot.
| Name | Type | Default |
|---|---|---|
spatialSnapshot | Rid | — |
bufferId | ulong | — |
int[]GetUint8Bufferbyte[]
public byte[] GetUint8Buffer(Rid spatialSnapshot, ulong bufferId);Returns a buffer with 8 bit ints from a buffer that was retrieved when taking a snapshot.
| Name | Type | Default |
|---|---|---|
spatialSnapshot | Rid | — |
bufferId | ulong | — |
byte[]GetVector2BufferVector2[]
public Vector2[] GetVector2Buffer(Rid spatialSnapshot, ulong bufferId);Returns a buffer with Vector2 entries from a buffer that was retrieved when taking a snapshot.
| Name | Type | Default |
|---|---|---|
spatialSnapshot | Rid | — |
bufferId | ulong | — |
Vector2[]GetVector3BufferVector3[]
public Vector3[] GetVector3Buffer(Rid spatialSnapshot, ulong bufferId);Returns a buffer with Vector3 entries from a buffer that was retrieved when taking a snapshot.
| Name | Type | Default |
|---|---|---|
spatialSnapshot | Rid | — |
bufferId | ulong | — |
Vector3[]MakeSpatialEntityRid
public Rid MakeSpatialEntity(Rid spatialContext, ulong entityId);Creates a new entity for this entity_id. The spatial_context should match the context that discovered the entity.
| Name | Type | Default |
|---|---|---|
spatialContext | Rid | — |
entityId | ulong | — |
RidQuerySnapshotbool
public bool QuerySnapshot(Rid spatialSnapshot, Reckfell.Collections.Array<OpenXRSpatialComponentData> componentData, OpenXRStructureBase next = null);Queries the snapshot data. This will find all entities in the snapshot that contain all requested components in component_data. The objects held within component_data will then be populated with the queried data. component_data must always have an object of OpenXRSpatialQueryResultData as the first entry.
next is an optional parameter that can contain additional information passed when setting our query conditions.
| Name | Type | Default |
|---|---|---|
spatialSnapshot | Rid | — |
componentData | Reckfell.Collections.Array<OpenXRSpatialComponentData> | — |
next | OpenXRStructureBase | null |
boolSupportsCapabilitybool
public bool SupportsCapability(OpenXRSpatialEntityExtension.Capability capability);Returns true if this spatial entity capability is supported by the hardware used.
| Name | Type | Default |
|---|---|---|
capability | OpenXRSpatialEntityExtension.Capability | — |
boolSupportsComponentTypebool
public bool SupportsComponentType(OpenXRSpatialEntityExtension.Capability capability, OpenXRSpatialEntityExtension.ComponentType componentType);Returns true if this capability supports the component_type.
| Name | Type | Default |
|---|---|---|
capability | OpenXRSpatialEntityExtension.Capability | — |
componentType | OpenXRSpatialEntityExtension.ComponentType | — |
boolUpdateSpatialEntities2 overloads
public Rid UpdateSpatialEntities(Rid spatialContext, Reckfell.Collections.Array<Rid> entities, long[] componentTypes, OpenXRStructureBase next = null);Performs a snapshot for a limited number of entities. This is NOT an asynchronous method and will return the snapshot immediately.
| Name | Type | Default |
|---|---|---|
spatialContext | Rid | — |
entities | Reckfell.Collections.Array<Rid> | — |
componentTypes | long[] | — |
next | OpenXRStructureBase | null |
Ridpublic Rid UpdateSpatialEntities(Rid spatialContext, Reckfell.Collections.Array<Rid> entities, ReadOnlySpan<long> componentTypes, OpenXRStructureBase next);Performs a snapshot for a limited number of entities. This is NOT an asynchronous method and will return the snapshot immediately.
| Name | Type | Default |
|---|---|---|
spatialContext | Rid | — |
entities | Reckfell.Collections.Array<Rid> | — |
componentTypes | ReadOnlySpan<long> | — |
next | OpenXRStructureBase | — |
RidSignals and events1
SpatialDiscoveryRecommendedEvent
public event OpenXRSpatialEntityExtension.SpatialDiscoveryRecommendedEventHandler SpatialDiscoveryRecommended;Emitted when OpenXR recommends running a discovery query because entities managed by this spatial context have (likely) changed.
| Name | Type | Default |
|---|---|---|
spatialContext | Rid | — |
OpenXRSpatialEntityExtension.Capability
| Value | Description |
|---|---|
Anchor = 1000762000 | Anchor capability. |
MarkerTrackingAprilTag = 1000743003 | April tag based marker tracking capability. |
MarkerTrackingArucoMarker = 1000743002 | ArUco marker based marker tracking capability. |
MarkerTrackingMicroQrCode = 1000743001 | Micro QR code based marker tracking capability. |
MarkerTrackingQrCode = 1000743000 | QR code based marker tracking capability. |
PlaneTracking = 1000741000 | Plane tracking capability. |
OpenXRSpatialEntityExtension.ComponentType
| Value | Description |
|---|---|
Anchor = 1000762000 | Component that provides the location for an anchor. The corresponding list structure is |
Bounded2D = 1 | Component that provides the 2D bounds for a spatial entity. The corresponding list structure is |
Bounded3D = 2 | Component that provides the 3D bounds for a spatial entity. The corresponding list structure is |
Marker = 1000743000 | A component describing the marker type, ID and location. The corresponding list structure is |
Mesh2D = 1000741001 | Component that provides a 2D mesh for a spatial entity. The corresponding list structure is |
Mesh3D = 4 | Component that provides a 3D mesh for a spatial entity. The corresponding list structure is |
Parent = 3 | Component that provides the XrSpatialEntityIdEXT of the parent for a spatial entity. The corresponding list structure is |
Persistence = 1000763000 | Component that provides the persisted UUID for a spatial entity. The corresponding list structure is |
PlaneAlignment = 1000741000 | Component that provides the plane alignment enum for a spatial entity. The corresponding list structure is |
PlaneSemanticLabel = 1000741003 | Component that provides a semantic label for a plane. The corresponding list structure is |
Polygon2D = 1000741002 | Component that provides a 2D boundary polygon for a spatial entity. The corresponding list structure is |
OpenXRSpatialEntityExtension.TrackingState
| Value | Description |
|---|---|
Enabled = 2 | Tracking is enabled and running. |
NoPermission = -2 | A permission required by the tracking logic is missing. |
NotActive = 0 | Tracking is currently not active. |
SettingUp = 1 | Tracking is being set up. |
SetupFailed = -1 | Setup of the tracking logic failed, consult the logs for more details. |
UnsupportedCapability = -3 | A capability supplied when creating the spatial context for tracking is unsupported. |