XR_ANDROID_scene_meshing
Name String
XR_ANDROID_scene_meshing
Extension Type
Instance extension
Registered Extension Number
719
Revision
3
Ratification Status
Not ratified
Extension and Version Dependencies
Last Modified Date
2025-05-15
IP Status
No known IP claims.
Contributors
Spencer Quin, Google
Jared Finder, Google
Antonio Fontan, Google
Cairn Overturf, Google
Nihav Jain, Google
Salar Khan, Google
Sebastian Klose, Google
Jürgen Sturm, Google
Vinny DaSilva, Google
Ricardo Campbell, Google
Overview
This extension is intended to provide meshes that approximately represent the physical objects in the user’s environment.
Applications can use this extension to visualize the scene and to let virtual objects interact with physical objects such as collisions.
The scene mesh data is generated by the runtime and shared with the application using XrSceneMeshingTrackerANDROID and XrSceneMeshSnapshotANDROID . Applications can access the values in scene submesh information through XrSceneSubmeshStateANDROID returned from xrGetAllSubmeshStatesANDROID . Applications can access the values in scene submesh data through XrSceneSubmeshDataANDROID returned from xrGetSubmeshDataANDROID .
Scene meshing data is sensitive personal information and is closely linked to personal privacy and integrity. It is strongly recommended that applications that store or transfer scene meshing data always ask the user for active and specific acceptance to do so.
Permissions
Android applications must have the android.permission.SCENE_UNDERSTANDING_FINE permission listed in their manifest. The android.permission.SCENE_UNDERSTANDING_FINE permission is considered a sensitive permission as it allows the runtime to study the user environment.
The application must request the permission at runtime to use these functions:
- xrCreateSceneMeshingTrackerANDROID
- xrDestroySceneMeshingTrackerANDROID
- xrCreateSceneMeshSnapshotANDROID
- xrDestroySceneMeshSnapshotANDROID
- xrGetAllSubmeshStatesANDROID
- xrGetSubmeshDataANDROID
(protection level: dangerous)
Inspect system capability
The XrSystemSceneMeshingPropertiesANDROID structure is defined as:
typedef struct XrSystemSceneMeshingPropertiesANDROID {
XrStructureType type;
void* next;
XrBool32 supportsSceneMeshing;
} XrSystemSceneMeshingPropertiesANDROID;
Member Descriptions
typeis the XrStructureType of this structure.nextisNULLor a pointer to the next structure in a structure chain. No such structures are defined in core OpenXR or this extension.supportsSceneMeshingis anXrBool32, indicating if the system supports scene meshing.
An application can inspect whether the system is capable of scene meshing by chaining an XrSystemSceneMeshingPropertiesANDROID structure to the XrSystemProperties when calling xrGetSystemProperties .
If a runtime returns XR_FALSE for supportsSceneMeshing , the system does not support scene meshing, and therefore must return XR_ERROR_FEATURE_UNSUPPORTED from xrCreateSceneMeshingTrackerANDROID . The application should avoid using scene meshing functionality when supportsSceneMeshing is XR_FALSE .
If a runtime returns XR_TRUE for supportsSceneMeshing , the system supports scene meshing.
Valid Usage (Implicit)
- The
XR_ANDROID_scene_meshingextension must be enabled prior to using XrSystemSceneMeshingPropertiesANDROID -
typemust beXR_TYPE_SYSTEM_SCENE_MESHING_PROPERTIES_ANDROID -
nextmust beNULLor a valid pointer to the next structure in a structure chain
The XrSceneMeshSemanticLabelSetANDROID enumeration describes the semantic label sets for scene meshing. Each value in this enum represents another enum that contains the semantic labels. For example, the XR_SCENE_MESH_SEMANTIC_LABEL_SET_DEFAULT_ANDROID value represents the set XrSceneMeshSemanticLabelANDROID .
typedef enum XrSceneMeshSemanticLabelSetANDROID {
XR_SCENE_MESH_SEMANTIC_LABEL_SET_NONE_ANDROID = 0,
XR_SCENE_MESH_SEMANTIC_LABEL_SET_DEFAULT_ANDROID = 1,
XR_SCENE_MESH_SEMANTIC_LABEL_SET_MAX_ENUM_ANDROID = 0x7FFFFFFF
} XrSceneMeshSemanticLabelSetANDROID;
The enumeration values have the following meanings:
Enum Description
XR_SCENE_MESH_SEMANTIC_LABEL_SET_NONE_ANDROID
This semantic label set represents absence of semantic labels.
XR_SCENE_MESH_SEMANTIC_LABEL_SET_DEFAULT_ANDROID
This semantic label set represents XrSceneMeshSemanticLabelANDROID.
The xrEnumerateSupportedSemanticLabelSetsANDROID function is defined as:
XrResult xrEnumerateSupportedSemanticLabelSetsANDROID(
XrInstance instance,
XrSystemId systemId,
uint32_t supportedSemanticLabelSetsInputCapacity,
uint32_t* supportedSemanticLabelSetsOutputCount,
XrSceneMeshSemanticLabelSetANDROID* supportedSemanticLabelSets);
Parameter Descriptions
instanceis an XrInstance created by the application.systemIdis anXrSystemIdretried from xrGetSystem .supportedSemanticLabelSetsInputCapacityis the capacity ofsupportedSemanticLabelSets, or 0 to retrieve the required capacity.supportedSemanticLabelSetsOutputCountis a pointer to the count ofsupportedSemanticLabelSetswritten, or a pointer to the required capacity in the case thatsupportedSemanticLabelSetsInputCapacityis insufficient.supportedSemanticLabelSetsis a pointer to an array of XrSceneMeshSemanticLabelSetANDROID . It can beNULLifsupportedSemanticLabelSetsInputCapacityis 0.- See Buffer Size Parameters chapter for a detailed description of retrieving the required
supportedSemanticLabelSetssize.
The application can enumerate semantic label sets supported by the system using xrEnumerateSupportedSemanticLabelSetsANDROID function.
Every system must at least support XR_SCENE_MESH_SEMANTIC_LABEL_SET_NONE_ANDROID because this enum value represents no semantic label set and can be used in the case the application does not need vertex semantics.
Valid Usage (Implicit)
- The
XR_ANDROID_scene_meshingextension must be enabled prior to calling xrEnumerateSupportedSemanticLabelSetsANDROID -
instancemust be a valid XrInstance handle -
supportedSemanticLabelSetsOutputCountmust be a pointer to auint32_tvalue - If
supportedSemanticLabelSetsInputCapacityis not0,supportedSemanticLabelSetsmust be a pointer to an array ofsupportedSemanticLabelSetsInputCapacityXrSceneMeshSemanticLabelSetANDROID values
Return Codes
XR_SUCCESS
XR_ERROR_FUNCTION_UNSUPPORTEDXR_ERROR_HANDLE_INVALIDXR_ERROR_INSTANCE_LOSTXR_ERROR_RUNTIME_FAILUREXR_ERROR_SIZE_INSUFFICIENTXR_ERROR_SYSTEM_INVALIDXR_ERROR_VALIDATION_FAILURE
Create a scene meshing tracker handle
XR_DEFINE_HANDLE(XrSceneMeshingTrackerANDROID)
The XrSceneMeshingTrackerANDROID handle represents a scene meshing tracker for scene meshing and managing the related resources.
This handle can be used to create a scene mesh snapshot using xrCreateSceneMeshSnapshotANDROID in this extension.
The xrCreateSceneMeshingTrackerANDROID function is defined as:
XrResult xrCreateSceneMeshingTrackerANDROID(
XrSession session,
const XrSceneMeshingTrackerCreateInfoANDROID* createInfo,
XrSceneMeshingTrackerANDROID* tracker);
Parameter Descriptions
sessionis an XrSession in which the scene meshing tracker will be active.createInfois a pointer to an XrSceneMeshingTrackerCreateInfoANDROID structure used to describe the scene meshing tracker to be created.trackeris the returned XrSceneMeshingTrackerANDROID handle.
An application can create an XrSceneMeshingTrackerANDROID handle using the xrCreateSceneMeshingTrackerANDROID function.
If the system does not support scene meshing, the runtime must return XR_ERROR_FEATURE_UNSUPPORTED from xrCreateSceneMeshingTrackerANDROID . In this case, the runtime must return XR_FALSE for XrSystemSceneMeshingPropertiesANDROID :: supportsSceneMeshing when the xrGetSystemProperties function is called, so that the application can avoid creating a scene meshing tracker.
The application must only use the semantic label sets that are supported by the system in XrSceneMeshingTrackerCreateInfoANDROID :: semanticLabelSet when creating a scene meshing tracker. If the application uses an unsupported scene mesh vertex semantic label set, the runtime must return XR_ERROR_FEATURE_UNSUPPORTED from xrCreateSceneMeshingTrackerANDROID .
The application can enumerate the list of supported semantic label sets with the xrEnumerateSupportedSemanticLabelSetsANDROID function.
The xrCreateSceneMeshingTrackerANDROID handle owns all the resources for scene meshing. Once finished with scene meshing experience, the application must destroy the handle via the xrDestroySceneMeshingTrackerANDROID function.
Valid Usage (Implicit)
- The
XR_ANDROID_scene_meshingextension must be enabled prior to calling xrCreateSceneMeshingTrackerANDROID -
sessionmust be a valid XrSession handle -
createInfomust be a pointer to a valid XrSceneMeshingTrackerCreateInfoANDROID structure -
trackermust be a pointer to an XrSceneMeshingTrackerANDROID handle
Return Codes
XR_SUCCESSXR_SESSION_LOSS_PENDING
XR_ERROR_FEATURE_UNSUPPORTEDXR_ERROR_FUNCTION_UNSUPPORTEDXR_ERROR_HANDLE_INVALIDXR_ERROR_INSTANCE_LOSTXR_ERROR_LIMIT_REACHEDXR_ERROR_OUT_OF_MEMORYXR_ERROR_RUNTIME_FAILUREXR_ERROR_SESSION_LOSTXR_ERROR_VALIDATION_FAILURE
The XrSceneMeshingTrackerCreateInfoANDROID structure is defined as:
typedef struct XrSceneMeshingTrackerCreateInfoANDROID {
XrStructureType type;
const void* next;
XrSceneMeshSemanticLabelSetANDROID semanticLabelSet;
XrBool32 enableNormals;
} XrSceneMeshingTrackerCreateInfoANDROID;
Member Descriptions
typeis the XrStructureType of this structure.nextisNULLor a pointer to the next structure in a structure chain. No such structures are defined in core OpenXR or this extension.semanticLabelSetis an XrSceneMeshSemanticLabelSetANDROID used to specify the semantic label set to be used for the scene meshing. If this is set toXR_SCENE_MESH_SEMANTIC_LABEL_SET_NONE_ANDROID, the runtime will ignore the XrSceneSubmeshDataANDROID ::vertexSemanticsbuffer field.enableNormalsis anXrBool32used to specify whether to include vertex normals for the mesh vertices in the scene mesh buffer when getting the scene mesh data.
The XrSceneMeshingTrackerCreateInfoANDROID structure describes the information to create an XrSceneMeshingTrackerANDROID handle.
Valid Usage (Implicit)
- The
XR_ANDROID_scene_meshingextension must be enabled prior to using XrSceneMeshingTrackerCreateInfoANDROID -
typemust beXR_TYPE_SCENE_MESHING_TRACKER_CREATE_INFO_ANDROID -
nextmust beNULLor a valid pointer to the next structure in a structure chain -
semanticLabelSetmust be a valid XrSceneMeshSemanticLabelSetANDROID value
The xrDestroySceneMeshingTrackerANDROID function is defined as:
XrResult xrDestroySceneMeshingTrackerANDROID(
XrSceneMeshingTrackerANDROID tracker);
Parameter Descriptions
trackeris an XrSceneMeshingTrackerANDROID previously created by xrCreateSceneMeshingTrackerANDROID .
The xrDestroySceneMeshingTrackerANDROID function releases the tracker and the underlying resources when finished with scene meshing experiences.
Valid Usage (Implicit)
- The
XR_ANDROID_scene_meshingextension must be enabled prior to calling xrDestroySceneMeshingTrackerANDROID -
trackermust be a valid XrSceneMeshingTrackerANDROID handle
Thread Safety
- Access to
tracker, and any child handles, must be externally synchronized
Return Codes
XR_SUCCESS
XR_ERROR_FUNCTION_UNSUPPORTEDXR_ERROR_HANDLE_INVALIDXR_ERROR_RUNTIME_FAILURE
Create a scene mesh snapshot handle
XR_DEFINE_HANDLE(XrSceneMeshSnapshotANDROID)
The XrSceneMeshSnapshotANDROID handle represents a scene mesh snapshot. This snapshot is created by using xrCreateSceneMeshSnapshotANDROID which takes a snapshot of the scene mesh data at the time of the function call.
This handle can be used to retrieve submesh information and data using xrGetAllSubmeshStatesANDROID and xrGetSubmeshDataANDROID .
The xrCreateSceneMeshSnapshotANDROID function is defined as:
XrResult xrCreateSceneMeshSnapshotANDROID(
XrSceneMeshingTrackerANDROID tracker,
const XrSceneMeshSnapshotCreateInfoANDROID* createInfo,
XrSceneMeshSnapshotCreationResultANDROID* outSnapshotCreationResult);
Parameter Descriptions
trackeris an XrSceneMeshingTrackerANDROID handle previously created with xrCreateSceneMeshingTrackerANDROID .createInfois pointer to an XrSceneMeshSnapshotCreateInfoANDROID structure which contains necessary information required to create the scene mesh snapshot.outSnapshotCreationResultis a pointer to an XrSceneMeshSnapshotCreationResultANDROID object which is populated by the runtime with the snapshot creation result.
The application can use the xrCreateSceneMeshSnapshotANDROID function to create a scene mesh snapshot from the scene meshing tracker. This function returns an XrSceneMeshSnapshotANDROID handle along with XrSceneMeshTrackingStateANDROID wrapped in an XrSceneMeshSnapshotCreationResultANDROID structure. The handle is technically a snapshot of the scene mesh data at the time of creation. This handle can be used to query the scene mesh info and data using xrGetAllSubmeshStatesANDROID and xrGetSubmeshDataANDROID respectively.
Valid Usage (Implicit)
- The
XR_ANDROID_scene_meshingextension must be enabled prior to calling xrCreateSceneMeshSnapshotANDROID -
trackermust be a valid XrSceneMeshingTrackerANDROID handle -
createInfomust be a pointer to a valid XrSceneMeshSnapshotCreateInfoANDROID structure -
outSnapshotCreationResultmust be a pointer to an XrSceneMeshSnapshotCreationResultANDROID structure
Return Codes
XR_SUCCESSXR_SESSION_LOSS_PENDING
XR_ERROR_FUNCTION_UNSUPPORTEDXR_ERROR_HANDLE_INVALIDXR_ERROR_INSTANCE_LOSTXR_ERROR_LIMIT_REACHEDXR_ERROR_OUT_OF_MEMORYXR_ERROR_POSE_INVALIDXR_ERROR_RUNTIME_FAILUREXR_ERROR_SESSION_LOSTXR_ERROR_TIME_INVALID
The XrSceneMeshSnapshotCreateInfoANDROID structure is defined as:
typedef struct XrSceneMeshSnapshotCreateInfoANDROID {
XrStructureType type;
const void* next;
XrSpace baseSpace;
XrTime time;
XrBoxf boundingBox;
} XrSceneMeshSnapshotCreateInfoANDROID;
Member Descriptions
typeis the XrStructureType of this structure.nextisNULLor a pointer to the next structure in a structure chain. No such structures are defined in core OpenXR or this extension.baseSpaceis an XrSpace within which the scene submesh pose info is represented.timeis theXrTimethat describes the time when the scene mesh will be processed or displayed, typically XrFrameState ::predictedDisplayTime.boundingBoxis an XrBoxf describing the bounding box within which to acquire the scene mesh.
The XrSceneMeshSnapshotCreateInfoANDROID structure describes the information to create an XrSceneMeshSnapshotANDROID handle
Valid Usage (Implicit)
- The
XR_ANDROID_scene_meshingextension must be enabled prior to using XrSceneMeshSnapshotCreateInfoANDROID -
typemust beXR_TYPE_SCENE_MESH_SNAPSHOT_CREATE_INFO_ANDROID -
nextmust beNULLor a valid pointer to the next structure in a structure chain -
baseSpacemust be a valid XrSpace handle
The XrSceneMeshSnapshotCreationResultANDROID structure is defined as:
typedef struct XrSceneMeshSnapshotCreationResultANDROID {
XrStructureType type;
const void* next;
XrSceneMeshSnapshotANDROID snapshot;
XrSceneMeshTrackingStateANDROID trackingState;
} XrSceneMeshSnapshotCreationResultANDROID;
Member Descriptions
typeis the XrStructureType of this structure.nextisNULLor a pointer to the next structure in a structure chain. No such structures are defined in core OpenXR or this extension.snapshotis an XrSceneMeshSnapshotANDROID handle created by the runtime.trackingStateis an XrSceneMeshTrackingStateANDROID that describes the state of the scene meshing tracker at the time of the snapshot creation.
The XrSceneMeshSnapshotCreationResultANDROID structure stores the result of a scene mesh snapshot creation returned from xrCreateSceneMeshSnapshotANDROID .
Valid Usage (Implicit)
- The
XR_ANDROID_scene_meshingextension must be enabled prior to using XrSceneMeshSnapshotCreationResultANDROID -
typemust beXR_TYPE_SCENE_MESH_SNAPSHOT_CREATION_RESULT_ANDROID -
nextmust beNULLor a valid pointer to the next structure in a structure chain -
snapshotmust be a valid XrSceneMeshSnapshotANDROID handle -
trackingStatemust be a valid XrSceneMeshTrackingStateANDROID value
The XrSceneMeshTrackingStateANDROID enumeration describes the tracking state for a scene meshing tracker. Each value in this enum represents a state of the scene meshing tracker.
typedef enum XrSceneMeshTrackingStateANDROID {
XR_SCENE_MESH_TRACKING_STATE_INITIALIZING_ANDROID = 0,
XR_SCENE_MESH_TRACKING_STATE_TRACKING_ANDROID = 1,
XR_SCENE_MESH_TRACKING_STATE_WAITING_ANDROID = 2,
XR_SCENE_MESH_TRACKING_STATE_ERROR_ANDROID = 3,
XR_SCENE_MESH_TRACKING_STATE_MAX_ENUM_ANDROID = 0x7FFFFFFF
} XrSceneMeshTrackingStateANDROID;
The enumeration values have the following meanings:
Enum Description
XR_SCENE_MESH_TRACKING_STATE_INITIALIZING_ANDROID
The tracker is not yet ready to provide mesh data.
XR_SCENE_MESH_TRACKING_STATE_TRACKING_ANDROID
The tracker is actively tracking.
XR_SCENE_MESH_TRACKING_STATE_WAITING_ANDROID
The tracker is waiting for valid measurements to integrate since the last mesh update.
XR_SCENE_MESH_TRACKING_STATE_ERROR_ANDROID
The tracker has not received valid measurements for multiple cycles and is in an error state.
This state serves only as additional information to the application. In the absence of other sources of errors, the runtime must continue to allow the application to create snapshots and retrieve data from them regardless of the current XrSceneMeshTrackingStateANDROID of the tracker. If the state is not XR_SCENE_MESH_TRACKING_STATE_TRACKING_ANDROID , the snapshots may not be up to date or empty.
Acquiring scene mesh data from the scene mesh snapshot
The xrGetAllSubmeshStatesANDROID function is defined as:
XrResult xrGetAllSubmeshStatesANDROID(
XrSceneMeshSnapshotANDROID snapshot,
uint32_t submeshStateCapacityInput,
uint32_t* submeshStateCountOutput,
XrSceneSubmeshStateANDROID* submeshStates);
Parameter Descriptions
snapshotis an XrSceneMeshSnapshotANDROID handle previously created with xrCreateSceneMeshSnapshotANDROID .submeshStateCapacityInputis the capacity ofsubmeshStates, or 0 to retrieve the required capacity.submeshStateCountOutputis a pointer to the count ofsubmeshStateswritten, or a pointer to the required capacity in the case thatsubmeshStateCapacityInputis insufficient.submeshStatesis a pointer to an array of XrSceneSubmeshStateANDROID structures to which the runtime will output the state of all submeshes in the scene mesh. It can beNULLifsubmeshStateCapacityInputis 0.- See Buffer Size Parameters chapter for a detailed description of retrieving the required
submeshStatessize.
The application can use the xrGetAllSubmeshStatesANDROID function to get the state of all submeshes in the scene mesh. This contains basic information information to allow the application to select submeshes for which the application wants data for.
Valid Usage (Implicit)
- The
XR_ANDROID_scene_meshingextension must be enabled prior to calling xrGetAllSubmeshStatesANDROID -
snapshotmust be a valid XrSceneMeshSnapshotANDROID handle -
submeshStateCountOutputmust be a pointer to auint32_tvalue - If
submeshStateCapacityInputis not0,submeshStatesmust be a pointer to an array ofsubmeshStateCapacityInputXrSceneSubmeshStateANDROID structures
Return Codes
XR_SUCCESSXR_SESSION_LOSS_PENDING
XR_ERROR_FUNCTION_UNSUPPORTEDXR_ERROR_HANDLE_INVALIDXR_ERROR_INSTANCE_LOSTXR_ERROR_RUNTIME_FAILUREXR_ERROR_SESSION_LOSTXR_ERROR_SIZE_INSUFFICIENTXR_ERROR_VALIDATION_FAILURE
The XrSceneSubmeshStateANDROID structure is defined as:
typedef struct XrSceneSubmeshStateANDROID {
XrStructureType type;
void* next;
XrUuid submeshId;
XrTime lastUpdatedTime;
XrPosef submeshPoseInBaseSpace;
XrExtent3Df bounds;
} XrSceneSubmeshStateANDROID;
Member Descriptions
typeis the XrStructureType of this structure.nextisNULLor a pointer to the next structure in a structure chain. No such structures are defined in core OpenXR or this extension.submeshIdis an XrUuid identifying the submesh.lastUpdatedTimeis anXrTimerepresenting the time when the submesh was last updated.submeshPoseInBaseSpaceis an XrPosef representing the pose of the submesh in the base space used to create the scene mesh snapshot. The pose is also the center of the submesh bounding box.boundsis an XrExtent3Df describing the dimensions of the bounding box that encloses the submesh. This bounds is defined in the base space that was used to create the scene mesh handle.
The runtime makes best effort to map submeshId with the region of the physical space occupied by the submesh. The Runtimes may at any time lose this mapping and assign a new UUID to any subset of the detected submeshes. In particular runtimes are not required to reuse the same UUIDs for the same meshes in subsequent application instances.
Valid Usage (Implicit)
- The
XR_ANDROID_scene_meshingextension must be enabled prior to using XrSceneSubmeshStateANDROID -
typemust beXR_TYPE_SCENE_SUBMESH_STATE_ANDROID -
nextmust beNULLor a valid pointer to the next structure in a structure chain
The xrGetSubmeshDataANDROID function is defined as:
XrResult xrGetSubmeshDataANDROID(
XrSceneMeshSnapshotANDROID snapshot,
uint32_t submeshDataCount,
XrSceneSubmeshDataANDROID* inoutSubmeshData);
Parameter Descriptions
snapshotis an XrSceneMeshSnapshotANDROID handle previously created with xrCreateSceneMeshSnapshotANDROID .submeshDataCountis the length ofinoutSubmeshData.inoutSubmeshDatais an application allocated array of XrSceneSubmeshDataANDROID in which the runtime populates each element with the mesh data associated with the submesh id passed in XrSceneSubmeshDataANDROID ::submeshId.
The application can use the xrGetSubmeshDataANDROID function to get batches of submeshes, or all submeshes at once, by passing a list of XrSceneSubmeshDataANDROID with each XrSceneSubmeshDataANDROID :: submeshId set to the respective id of the submesh to retrieve.
The XrSceneSubmeshDataANDROID :: submeshId must be unique for every element in inoutSubmeshData and retrievable by xrGetAllSubmeshStatesANDROID for the same snapshot . If the submesh Id is invalid or more than one elements in inoutSubmeshData have the same submesh id, then the runtime must return XR_ERROR_VALIDATION_FAILURE .
submeshDataCount must be equal or less than the value returned by xrGetAllSubmeshStatesANDROID :: submeshStateCountOutput , otherwise the runtime must return XR_ERROR_VALIDATION_FAILURE .
This can be used in a 2-call idiom to query the vertex and index count for all of the selected submeshes.
Valid Usage (Implicit)
- The
XR_ANDROID_scene_meshingextension must be enabled prior to calling xrGetSubmeshDataANDROID -
snapshotmust be a valid XrSceneMeshSnapshotANDROID handle -
inoutSubmeshDatamust be a pointer to an array ofsubmeshDataCountXrSceneSubmeshDataANDROID structures - The
submeshDataCountparameter must be greater than0
Return Codes
XR_SUCCESSXR_SESSION_LOSS_PENDING
XR_ERROR_FUNCTION_UNSUPPORTEDXR_ERROR_HANDLE_INVALIDXR_ERROR_INSTANCE_LOSTXR_ERROR_RUNTIME_FAILUREXR_ERROR_SESSION_LOSTXR_ERROR_SIZE_INSUFFICIENTXR_ERROR_VALIDATION_FAILURE
The XrSceneSubmeshDataANDROID structure is defined as:
typedef struct XrSceneSubmeshDataANDROID {
XrStructureType type;
const void* next;
XrUuid submeshId;
uint32_t vertexCapacityInput;
uint32_t vertexCountOutput;
XrVector3f* vertexPositions;
XrVector3f* vertexNormals;
uint8_t* vertexSemantics;
uint32_t indexCapacityInput;
uint32_t indexCountOutput;
uint32_t* indices;
} XrSceneSubmeshDataANDROID;
Member Descriptions
typeis the XrStructureType of this structure.nextisNULLor a pointer to the next structure in a structure chain. No such structures are defined in core OpenXR or this extension.submeshIdis an XrUuid identifying the submesh.vertexCapacityInputis the capacity ofvertexPositions,vertexNormalsandvertexSemantics, or 0 to retrieve the required capacity.vertexCountOutputis a pointer to the count ofvertexPositions,vertexNormals, andvertexSemanticswritten, or a pointer to the required capacity in the case thatvertexCapacityInputis insufficient.vertexPositionsis an array of XrVector3f to which the runtime will output the vertex positions of the submesh.vertexNormalsis an array of XrVector3f to which the runtime will output the vertex normals of the submesh. This field can be leftNULLif the application created a tracker with normals disabled.vertexSemanticsis an array ofuint8_tto which the runtime will output the vertex semantics of the submesh. This field can be leftNULLif the application created a tracker withXR_SCENE_MESH_SEMANTIC_LABEL_SET_NONE_ANDROIDsemantic label set.indexCapacityInputis the capacity ofindices, or 0 to retrieve the required capacity.indexCountOutputis a pointer to the count ofindiceswritten, or a pointer to the required capacity in the case thatvertexCapacityInputis insufficient.indicesis an array ofuint32_tto which the runtime will output the indices of the submesh.- See Buffer Size Parameters chapter for a detailed description of retrieving the required
vertexPositions,vertexNormals,vertexSemantics, andindicessize.
Valid Usage (Implicit)
- The
XR_ANDROID_scene_meshingextension must be enabled prior to using XrSceneSubmeshDataANDROID -
typemust beXR_TYPE_SCENE_SUBMESH_DATA_ANDROID -
nextmust beNULLor a valid pointer to the next structure in a structure chain - If
vertexCapacityInputis not0,vertexPositionsmust be a pointer to an array ofvertexCapacityInputXrVector3f structures - If
vertexCapacityInputis not0,vertexNormalsmust be a pointer to an array ofvertexCapacityInputXrVector3f structures - If
vertexCapacityInputis not0,vertexSemanticsmust be a pointer to an array ofvertexCapacityInputuint8_tvalues - If
indexCapacityInputis not0,indicesmust be a pointer to an array ofindexCapacityInputuint32_tvalues
The XrSceneMeshSemanticLabelANDROID enumeration is the default set of semantic labels that can be used to label mesh vertices to describe which physical environment surface the mesh vertex is on. This enum set is represented by the XR_SCENE_MESH_SEMANTIC_LABEL_SET_DEFAULT_ANDROID value in XrSceneMeshSemanticLabelSetANDROID .
typedef enum XrSceneMeshSemanticLabelANDROID {
XR_SCENE_MESH_SEMANTIC_LABEL_OTHER_ANDROID = 0,
XR_SCENE_MESH_SEMANTIC_LABEL_FLOOR_ANDROID = 1,
XR_SCENE_MESH_SEMANTIC_LABEL_CEILING_ANDROID = 2,
XR_SCENE_MESH_SEMANTIC_LABEL_WALL_ANDROID = 3,
XR_SCENE_MESH_SEMANTIC_LABEL_TABLE_ANDROID = 4,
XR_SCENE_MESH_SEMANTIC_LABEL_MAX_ENUM_ANDROID = 0x7FFFFFFF
} XrSceneMeshSemanticLabelANDROID;
The enums have the following meanings:
Enum Description
XR_SCENE_MESH_SEMANTIC_LABEL_OTHER_ANDROID
This semantic label indicates that the corresponding mesh element represents an unknown object.
XR_SCENE_MESH_SEMANTIC_LABEL_FLOOR_ANDROID
This semantic label indicates that the corresponding mesh element represents a floor.
XR_SCENE_MESH_SEMANTIC_LABEL_CEILING_ANDROID
This semantic label indicates that the corresponding mesh element represents a ceiling.
XR_SCENE_MESH_SEMANTIC_LABEL_WALL_ANDROID
This semantic label indicates that the corresponding mesh element represents a wall.
XR_SCENE_MESH_SEMANTIC_LABEL_TABLE_ANDROID
This semantic label indicates that the corresponding mesh element represents a table.
Destroy a scene mesh snapshot
The xrDestroySceneMeshSnapshotANDROID function is defined as:
XrResult xrDestroySceneMeshSnapshotANDROID(
XrSceneMeshSnapshotANDROID snapshot);
Parameter Descriptions
snapshotis an XrSceneMeshSnapshotANDROID handle previously created with xrCreateSceneMeshSnapshotANDROID that will be destroyed by this function.
The application can use the xrDestroySceneMeshSnapshotANDROID function to destroy a scene mesh snapshot. Once the handle is destroyed, the application can no longer use it to get the submesh info or data. The handle is automatically destroyed when the tracker is destroyed because the tracker handle is the parent of the scene mesh snapshot handle.
Valid Usage (Implicit)
- The
XR_ANDROID_scene_meshingextension must be enabled prior to calling xrDestroySceneMeshSnapshotANDROID -
snapshotmust be a valid XrSceneMeshSnapshotANDROID handle
Thread Safety
- Access to
snapshot, and any child handles, must be externally synchronized
Return Codes
XR_SUCCESS
XR_ERROR_FUNCTION_UNSUPPORTEDXR_ERROR_HANDLE_INVALIDXR_ERROR_RUNTIME_FAILURE
Example code for scene meshing
Following example code demonstrates how to access scene mesh data for rendering.
XrInstance instance; // Created at app startup
XrSystemId systemId; // Received from xrGetSystem() at app startup
XrSession session; // Created at app startup
XrSpace appPlaySpace; // Created at app startup
// The function pointers are previously initialized using xrGetInstanceProcAddr.
PFN_xrCreateSceneMeshingTrackerANDROID xrCreateSceneMeshingTrackerANDROID;
PFN_xrDestroySceneMeshingTrackerANDROID xrDestroySceneMeshingTrackerANDROID;
PFN_xrEnumerateSupportedSemanticLabelSetsANDROID xrEnumerateSupportedSemanticLabelSetsANDROID;
PFN_xrCreateSceneMeshSnapshotANDROID xrCreateSceneMeshSnapshotANDROID;
PFN_xrDestroySceneMeshSnapshotANDROID xrDestroySceneMeshSnapshotANDROID;
PFN_xrGetAllSubmeshStatesANDROID xrGetAllSubmeshStatesANDROID;
PFN_xrGetSubmeshDataANDROID xrGetSubmeshDataANDROID;
// Inspect system capability
XrSystemSceneMeshingPropertiesANDROID sceneMeshingProps = {
.type = XR_TYPE_SYSTEM_SCENE_MESHING_PROPERTIES_ANDROID,
};
XrSystemProperties sysProps = {
.type = XR_TYPE_SYSTEM_PROPERTIES,
.next = &sceneMeshingProps
};
CHK_XR(xrGetSystemProperties(instance, systemId, &sysProps));
if (!sceneMeshingProps.supportsSceneMeshing) {
// scene meshing is not supported.
return;
}
uint32_t supportedsemanticLabelSetsCount = 0;
xrEnumerateSupportedSemanticLabelSetsANDROID(
instance, systemId, 0, &supportedsemanticLabelSetsCount, nullptr);
std::vector<XrSceneMeshSemanticLabelSetANDROID> supportedSemanticLabelSets(
supportedsemanticLabelSetsCount);
xrEnumerateSupportedSemanticLabelSetsANDROID(
instance, systemId, supportedsemanticLabelSetsCount,
&supportedsemanticLabelSetsCount, supportedSemanticLabelSets.data());
XrSceneMeshSemanticLabelSetANDROID semanticLabelSet = XR_SCENE_MESH_SEMANTIC_LABEL_SET_NONE_ANDROID;
// Check if system supports XR_SCENE_MESH_SEMANTIC_LABEL_SET_DEFAULT_ANDROID
if (std::find(supportedSemanticLabelSets.begin(), supportedSemanticLabelSets.end(),
XR_SCENE_MESH_SEMANTIC_LABEL_SET_DEFAULT_ANDROID) !=
supportedSemanticLabelSets.end()) {
semanticLabelSet = XR_SCENE_MESH_SEMANTIC_LABEL_SET_DEFAULT_ANDROID;
}
XrSceneMeshingTrackerCreateInfoANDROID trackerCreateInfo = {
.type = XR_TYPE_SCENE_MESHING_TRACKER_CREATE_INFO_ANDROID,
.semanticLabelSet = semanticLabelSet,
.enableNormals = XR_TRUE
};
XrSceneMeshingTrackerANDROID tracker = XR_NULL_HANDLE;
CHK_XR(xrCreateSceneMeshingTrackerANDROID(session, &trackerCreateInfo, &tracker));
XrSceneMeshSnapshotCreationResultANDROID snapshotResult {
.type = XR_TYPE_SCENE_MESH_SNAPSHOT_CREATION_RESULT_ANDROID,
.snapshot = XR_NULL_HANDLE
};
XrSceneMeshSnapshotANDROID& snapshot = snapshotResult.snapshot;
XrSceneMeshSnapshotCreateInfoANDROID createInfo {
.type = XR_TYPE_SCENE_MESH_SNAPSHOT_CREATE_INFO_ANDROID
};
// app update loop
while (true) {
// ...
// For every frame in frame loop
// ...
XrFrameState frameState; // previously returned from xrWaitFrame
const XrTime time = frameState.predictedDisplayTime;
XrBoxf box; // populated with the bounding box of the camera frustum
// ...
createInfo.baseSpace = appPlaySpace;
createInfo.time = time;
createInfo.boundingBox = box;
// Grab the scene mesh snapshot. This way the app can: know all of the submesh infos,
// choose the appropriate submeshes for which to get data, allocate the necessary
// buffer for those submeshes, and then get the data.
CHK_XR(xrCreateSceneMeshSnapshotANDROID(tracker, &createInfo, &snapshotResult));
// check the tracking state
if (snapshotResult.trackingState == XR_SCENE_MESH_TRACKING_STATE_ERROR_ANDROID) {
// unrecoverable error. Exit the app.
if (snapshot != XR_NULL_HANDLE) {
CHK_XR(xrDestroySceneMeshSnapshotANDROID(snapshot));
snapshot = XR_NULL_HANDLE;
}
break;
} else if (snapshotResult.trackingState != XR_SCENE_MESH_TRACKING_STATE_TRACKING_ANDROID) {
// The tracker is not tracking. Try again later.
if (snapshot != XR_NULL_HANDLE) {
CHK_XR(xrDestroySceneMeshSnapshotANDROID(snapshot));
snapshot = XR_NULL_HANDLE;
}
continue;
}
// 2-call idiom for getting submesh states
uint32_t submeshCount = 0;
CHK_XR(xrGetAllSubmeshStatesANDROID(snapshot, 0, &submeshCount, nullptr));
std::vector<XrSceneSubmeshStateANDROID> states(submeshCount, {
.type = XR_TYPE_SCENE_SUBMESH_STATE_ANDROID,
});
CHK_XR(xrGetAllSubmeshStatesANDROID(snapshot, submeshCount, &submeshCount, states.data()));
// To store the poses for the selected submeshes
std::vector<XrPosef> submeshesPoses;
submeshesPoses.reserve(submeshCount);
std::vector<XrSceneSubmeshDataANDROID> submeshes;
submeshes.reserve(submeshCount);
// Iterate the states and determine which submeshes the app wants data for
for (XrSceneSubmeshStateANDROID& state : states) {
// Modify this bool as necessary by looking at states. Maybe state.lastUpdatedTime
// is below a threshold or maybe the bounding box does not intersect with camera view
// frustum (The submesh will be culled).
bool needed;
if (needed) {
// Add the selected submesh to the submeshes list. Set the capacity
// zero for now since the size of the buffer will be determined later.
XrSceneSubmeshDataANDROID submesh {
.type = XR_TYPE_SCENE_SUBMESH_DATA_ANDROID,
.submeshId = state.submeshId,
.vertexCapacityInput = 0,
.vertexCountOutput = 0,
.vertexPositions = nullptr,
.vertexNormals = nullptr,
.vertexSemantics = nullptr,
.indexCapacityInput = 0,
.indexCountOutput = 0,
.indices = nullptr,
};
submeshes.push_back(submesh);
submeshesPoses.push_back(state.submeshPoseInBaseSpace);
}
}
// Grab the data for the selected submeshes using the 2-call idiom.
CHK_XR(xrGetSubmeshDataANDROID(snapshot, submeshes.size(), submeshes.data()));
for (XrSceneSubmeshDataANDROID& submesh : submeshes) {
submesh.vertexCapacityInput = submesh.vertexCountOutput;
submesh.vertexCountOutput = 0;
submesh.vertexPositions = new XrVector3f[submesh.vertexCapacityInput];
submesh.vertexNormals = new XrVector3f[submesh.vertexCapacityInput];
submesh.vertexSemantics = new uint8_t[submesh.vertexCapacityInput];
submesh.indexCapacityInput = submesh.indexCountOutput;
submesh.indexCountOutput = 0;
submesh.indices = new uint32_t[submesh.indexCapacityInput];
}
CHK_XR(xrGetSubmeshDataANDROID(snapshot, submeshes.size(), submeshes.data()));
// Destroy the scene mesh snapshot since we have finally grabbed the submeshes data. In
// next iteration app can: create a new one to get latest mesh data
CHK_XR(xrDestroySceneMeshSnapshotANDROID(snapshot));
snapshot = XR_NULL_HANDLE;
// Iterate the submeshes and get the vertex positions, vertex normals and
// vertex semantics data for the selected submeshes
for (uint32_t i = 0; i < submeshes.size(); i++) {
XrSceneSubmeshDataANDROID& data = submeshes[i];
XrVector3f* vertexPositions = data.vertexPositions;
XrVector3f* vertexNormals = data.vertexNormals;
XrSceneMeshSemanticLabelANDROID* vertexSemantics =
new XrSceneMeshSemanticLabelANDROID[data.vertexCountOutput];
for (uint32_t j = 0; j < data.vertexCountOutput; j++) {
vertexSemantics[j] =
static_cast<XrSceneMeshSemanticLabelANDROID>(data.vertexSemantics[j]);
}
XrPosef pose = submeshesPoses[i];
// *** Use the data as per needs ***
// Release the allocated memory for the data buffers when done using
delete [] vertexSemantics;
delete [] data.vertexPositions;
delete [] data.vertexNormals;
delete [] data.vertexSemantics;
delete [] data.indices;
}
// ...
// Finish frame loop
// ...
}
CHK_XR(xrDestroySceneMeshingTrackerANDROID(tracker));
New Object Types
New Commands
- xrCreateSceneMeshSnapshotANDROID
- xrCreateSceneMeshingTrackerANDROID
- xrDestroySceneMeshSnapshotANDROID
- xrDestroySceneMeshingTrackerANDROID
- xrEnumerateSupportedSemanticLabelSetsANDROID
- xrGetAllSubmeshStatesANDROID
- xrGetSubmeshDataANDROID
New Structures
- XrSceneMeshSnapshotCreateInfoANDROID
- XrSceneMeshSnapshotCreationResultANDROID
- XrSceneMeshingTrackerCreateInfoANDROID
- XrSceneSubmeshDataANDROID
- XrSceneSubmeshStateANDROID
Extending XrSystemProperties :
New Enums
New Enum Constants
XR_ANDROID_SCENE_MESHING_EXTENSION_NAMEXR_ANDROID_scene_meshing_SPEC_VERSIONExtending XrObjectType :
XR_OBJECT_TYPE_SCENE_MESHING_TRACKER_ANDROIDXR_OBJECT_TYPE_SCENE_MESH_SNAPSHOT_ANDROID
Extending XrStructureType :
XR_TYPE_SCENE_MESHING_TRACKER_CREATE_INFO_ANDROIDXR_TYPE_SCENE_MESH_SNAPSHOT_CREATE_INFO_ANDROIDXR_TYPE_SCENE_MESH_SNAPSHOT_CREATION_RESULT_ANDROIDXR_TYPE_SCENE_SUBMESH_DATA_ANDROIDXR_TYPE_SCENE_SUBMESH_STATE_ANDROIDXR_TYPE_SYSTEM_SCENE_MESHING_PROPERTIES_ANDROID
Issues
Version History
Revision 3, 2025-05-15 (Salar Khan)
- Initial extension description