XR_EXT_spatial_plane_tracking

Name String

XR_EXT_spatial_plane_tracking

拡張機能のタイプ

インスタンス拡張機能

Registered Extension Number

742

リビジョン

1

Ratification Status(批准ステータス)

批准

拡張機能とバージョンの依存関係

XR_EXT_spatial_entity

寄与者

Nihav Jain(Google)
Natalie Fleury(Meta)
Yuichi Taguchi(Meta)
Ron Bessems(Meta)
Yin Li(Microsoft)
Jimmy Alamparambil(ByteDance)
Zhipeng Liu(ByteDance)
Jun Yan(ByteDance)

概要

この拡張機能は XR_EXT_spatial_entity をベースに構築されており、空間エンティティ フレームワークの平面トラッキング空間機能を定義します。

ランタイム サポート

ランタイムが平面トラッキングをサポートしている場合、xrEnumerateSpatialCapabilitiesEXTXR_SPATIAL_CAPABILITY_PLANE_TRACKING_EXT を列挙して、サポートしていることを示さなければなりません。

構成

XrSpatialCapabilityConfigurationPlaneTrackingEXT 構造体は次のように定義されます。

typedef struct XrSpatialCapabilityConfigurationPlaneTrackingEXT {
    XrStructureType                     type;
    const void*                         next;
    XrSpatialCapabilityEXT              capability;
    uint32_t                            enabledComponentCount;
    const XrSpatialComponentTypeEXT*    enabledComponents;
} XrSpatialCapabilityConfigurationPlaneTrackingEXT;

メンバーの説明

  • type は、この構造の XrStructureType です。
  • next は、NULL または構造体チェーン内の次の構造体へのポインタです。
  • capabilityXrSpatialCapabilityEXT であり、XR_SPATIAL_CAPABILITY_PLANE_TRACKING_EXT でなければなりません。
  • enabledComponentCount は、enabledComponents 配列内の要素の数を記述する uint32_t です。
  • enabledComponentsXrSpatialComponentTypeEXT の配列へのポインタです。

アプリは、XrSpatialContextCreateInfoEXT :: capabilityConfigsXrSpatialCapabilityConfigurationPlaneTrackingEXT 構造体へのポインタを含めることで、XR_SPATIAL_CAPABILITY_PLANE_TRACKING_EXT 空間機能を有効にできます

capabilityXR_SPATIAL_CAPABILITY_PLANE_TRACKING_EXT でない場合、ランタイムは XR_ERROR_VALIDATION_FAILURE を返さなければなりません。

有効な使用方法(暗黙的)

保証対象コンポーネント

XR_SPATIAL_CAPABILITY_PLANE_TRACKING_EXT をサポートするランタイムは、この機能で検出されたすべてのエンティティの保証されたコンポーネントとして次の空間コンポーネントを提供し、xrEnumerateSpatialCapabilityComponentTypesEXT で列挙しなければなりません。

  • XR_SPATIAL_COMPONENT_TYPE_BOUNDED_2D_EXT
  • XR_SPATIAL_COMPONENT_TYPE_PLANE_ALIGNMENT_EXT

境界付き 2D コンポーネント

境界付き 2D コンポーネントは、それが配置されているエンティティで表される平面の中心と範囲を提供します。詳しくは、境界付き 2D をご覧ください。

Plane Alignment コンポーネント

コンポーネント データ

typedef enum XrSpatialPlaneAlignmentEXT {
    XR_SPATIAL_PLANE_ALIGNMENT_HORIZONTAL_UPWARD_EXT = 0,
    XR_SPATIAL_PLANE_ALIGNMENT_HORIZONTAL_DOWNWARD_EXT = 1,
    XR_SPATIAL_PLANE_ALIGNMENT_VERTICAL_EXT = 2,
    XR_SPATIAL_PLANE_ALIGNMENT_ARBITRARY_EXT = 3,
    XR_SPATIAL_PLANE_ALIGNMENT_MAX_ENUM_EXT = 0x7FFFFFFF
} XrSpatialPlaneAlignmentEXT;

XrSpatialPlaneAlignmentEXT 列挙型は、空間エンティティに関連付けられた平面と XR_SPATIAL_COMPONENT_TYPE_PLANE_ALIGNMENT_EXT コンポーネントの向きを表します。

列挙値の意味は次のとおりです。

列挙型の説明

XR_SPATIAL_PLANE_ALIGNMENT_HORIZONTAL_UPWARD_EXT

エンティティが水平で上を向いている(床など)。

XR_SPATIAL_PLANE_ALIGNMENT_HORIZONTAL_DOWNWARD_EXT

エンティティが水平で、下向き(天井など)である。

XR_SPATIAL_PLANE_ALIGNMENT_VERTICAL_EXT

エンティティが垂直(壁など)である。

XR_SPATIAL_PLANE_ALIGNMENT_ARBITRARY_EXT

エンティティの向きが、垂直でも水平でもない任意のものになっています。

データをクエリするコンポーネント リストの構造

XrSpatialComponentPlaneAlignmentListEXT 構造体は次のように定義されます。

typedef struct XrSpatialComponentPlaneAlignmentListEXT {
    XrStructureType                type;
    void*                          next;
    uint32_t                       planeAlignmentCount;
    XrSpatialPlaneAlignmentEXT*    planeAlignments;
} XrSpatialComponentPlaneAlignmentListEXT;

メンバーの説明

  • type は、この構造の XrStructureType です。
  • next は、NULL または構造体チェーン内の次の構造体へのポインタです。
  • planeAlignmentCount は、planeAlignments 配列内の要素の数を記述する uint32_t です。
  • planeAlignmentsXrSpatialPlaneAlignmentEXT の配列です。

XrSpatialSnapshotEXT の空間エンティティの平面アライメント コンポーネントをクエリするには、XrSpatialComponentDataQueryConditionEXT :: componentTypesXR_SPATIAL_COMPONENT_TYPE_PLANE_ALIGNMENT_EXT を含め、XrSpatialComponentDataQueryResultEXT :: next チェーンに XrSpatialComponentPlaneAlignmentListEXT を追加します。

ランタイムは、XrSpatialComponentPlaneAlignmentListEXTXrSpatialComponentDataQueryResultEXT :: next チェーンに含まれているが、XR_SPATIAL_COMPONENT_TYPE_PLANE_ALIGNMENT_EXTXrSpatialComponentDataQueryConditionEXT :: componentTypes に含まれていない場合、xrQuerySpatialComponentDataEXT から XR_ERROR_VALIDATION_FAILURE を返さなければなりません

planeAlignmentCountXrSpatialComponentDataQueryResultEXT :: entityIdCountOutput より小さい場合、ランタイムは xrQuerySpatialComponentDataEXT から XR_ERROR_SIZE_INSUFFICIENT を返さなければなりません。

有効な使用方法(暗黙的)

構成

XR_SPATIAL_COMPONENT_TYPE_PLANE_ALIGNMENT_EXTXrSpatialCapabilityComponentTypesEXT :: componentTypes で列挙されている場合、アプリは、このコンポーネントをサポートするケーパビリティの XrSpatialCapabilityConfigurationBaseHeaderEXT 派生構造の XrSpatialCapabilityConfigurationBaseHeaderEXT :: enabledComponents リストに列挙子を含めることで、このコンポーネントを有効にできます。

このコンポーネントを XrSpatialCapabilityConfigurationBaseHeaderEXT :: next チェーンに含めるために、特別な構成は必要ありません。

オプション コンポーネント

XR_SPATIAL_CAPABILITY_PLANE_TRACKING_EXT をサポートするランタイムは、保証されるコンポーネントに記載されているものに加えて、他の空間コンポーネントをサポートする場合があります。アプリケーションは xrEnumerateSpatialCapabilityComponentTypesEXT を使用して、ランタイムがサポートするコンポーネントの完全なリストを取得し、空間コンテキストの作成時に必要なコンポーネントを構成します。

Mesh 2D コンポーネント

コンポーネント データ

XR_SPATIAL_COMPONENT_TYPE_MESH_2D_EXT は、データに XrSpatialMeshDataEXT 構造体を使用します。

データをクエリするコンポーネント リストの構造

XrSpatialComponentMesh2DListEXT 構造体は次のように定義されます。

typedef struct XrSpatialComponentMesh2DListEXT {
    XrStructureType          type;
    void*                    next;
    uint32_t                 meshCount;
    XrSpatialMeshDataEXT*    meshes;
} XrSpatialComponentMesh2DListEXT;

メンバーの説明

  • type は、この構造の XrStructureType です。
  • next は、NULL または構造体チェーン内の次の構造体へのポインタです。
  • meshCount は、meshes 配列内の要素の数を記述する uint32_t です。
  • meshesXrSpatialMeshDataEXT の配列です。

XrSpatialSnapshotEXT の空間エンティティのメッシュ 2D コンポーネントをクエリするには、XrSpatialComponentDataQueryConditionEXT :: componentTypesXR_SPATIAL_COMPONENT_TYPE_MESH_2D_EXT を含め、XrSpatialComponentMesh2DListEXTXrSpatialComponentDataQueryResultEXT :: next チェーンに追加します。

ランタイムは、XrSpatialComponentMesh2DListEXTXrSpatialComponentDataQueryResultEXT :: next チェーンに含まれているが、XR_SPATIAL_COMPONENT_TYPE_MESH_2D_EXTXrSpatialComponentDataQueryConditionEXT :: componentTypes に含まれていない場合、xrQuerySpatialComponentDataEXT から XR_ERROR_VALIDATION_FAILURE を返さなければなりません。

meshCountXrSpatialComponentDataQueryResultEXT :: entityIdCountOutput より小さい場合、ランタイムは xrQuerySpatialComponentDataEXT から XR_ERROR_SIZE_INSUFFICIENT を返さなければなりません。

ランタイムが meshes 配列に設定する XrSpatialMeshDataEXT の場合、XrSpatialMeshDataEXT :: vertexBufferXrSpatialBufferEXT :: bufferTypeXR_SPATIAL_BUFFER_TYPE_VECTOR2F_EXT でなければならず、XrSpatialMeshDataEXT :: indexBufferXrSpatialBufferEXT :: bufferTypeXR_SPATIAL_BUFFER_TYPE_UINT16_EXT でなければなりません。

有効な使用方法(暗黙的)

構成

XR_SPATIAL_COMPONENT_TYPE_MESH_2D_EXTXrSpatialCapabilityComponentTypesEXT :: componentTypes で列挙されている場合、アプリは、このコンポーネントをサポートするケーパビリティの XrSpatialCapabilityConfigurationBaseHeaderEXT 派生構造の XrSpatialCapabilityConfigurationBaseHeaderEXT :: enabledComponents リストに列挙子を含めることで、このコンポーネントを有効にできます。

このコンポーネントを XrSpatialCapabilityConfigurationBaseHeaderEXT :: next チェーンに含めるために、特別な構成は必要ありません。

Polygon 2D コンポーネント

コンポーネント データ

XrSpatialPolygon2DDataEXT 構造体は次のように定義されます。

typedef struct XrSpatialPolygon2DDataEXT {
    XrPosef               origin;
    XrSpatialBufferEXT    vertexBuffer;
} XrSpatialPolygon2DDataEXT;

メンバーの説明

  • origin は、ポリゴンの原点を定義する XrPosef です。ポリゴンのすべての頂点は、X-Y 平面内のこの原点を基準にしています。
  • vertexBuffer は、タイプ XR_SPATIAL_BUFFER_TYPE_VECTOR2F_EXT のバッファの ID を提供し、このコンポーネントが配置されているエンティティの頂点バッファを表す XrSpatialBufferEXT です。頂点は反時計回りの順で返す必要があります。これらの頂点で表されるポリゴンは自己交差してはならず、凹面であってもかまいません。

XrSpatialBufferEXT :: vertexBufferbufferTypeXR_SPATIAL_BUFFER_TYPE_VECTOR2F_EXT でなければなりません。

有効な使用方法(暗黙的)

  • XrSpatialPolygon2DDataEXT を使用する前に、XR_EXT_spatial_plane_tracking 拡張機能を有効にしなければなりません。
  • vertexBuffer は、有効な XrSpatialBufferEXT 構造体でなければなりません。
データをクエリするコンポーネント リストの構造

XrSpatialComponentPolygon2DListEXT 構造体は次のように定義されます。

typedef struct XrSpatialComponentPolygon2DListEXT {
    XrStructureType               type;
    void*                         next;
    uint32_t                      polygonCount;
    XrSpatialPolygon2DDataEXT*    polygons;
} XrSpatialComponentPolygon2DListEXT;

メンバーの説明

  • type は、この構造の XrStructureType です。
  • next は、NULL または構造体チェーン内の次の構造体へのポインタです。
  • polygonCount は、polygons 配列内の要素の数を記述する uint32_t です。
  • polygonsXrSpatialPolygon2DDataEXT の配列です。

XrSpatialSnapshotEXT の空間エンティティのポリゴン 2D コンポーネントをクエリするには、XrSpatialComponentDataQueryConditionEXT :: componentTypesXR_SPATIAL_COMPONENT_TYPE_POLYGON_2D_EXT を含め、XrSpatialComponentDataQueryResultEXT :: next チェーンに XrSpatialComponentPolygon2DListEXT を追加します。

ランタイムは、XrSpatialComponentPolygon2DListEXTXrSpatialComponentDataQueryResultEXT :: next チェーンに含まれているが、XR_SPATIAL_COMPONENT_TYPE_POLYGON_2D_EXTXrSpatialComponentDataQueryConditionEXT :: componentTypes に含まれていない場合、xrQuerySpatialComponentDataEXT から XR_ERROR_VALIDATION_FAILURE を返さなければなりません

polygonCountXrSpatialComponentDataQueryResultEXT :: entityIdCountOutput より小さい場合、ランタイムは xrQuerySpatialComponentDataEXT から XR_ERROR_SIZE_INSUFFICIENT を返さなければなりません。

有効な使用方法(暗黙的)

構成

XR_SPATIAL_COMPONENT_TYPE_POLYGON_2D_EXTXrSpatialCapabilityComponentTypesEXT :: componentTypes で列挙されている場合、アプリは、このコンポーネントをサポートするケーパビリティの XrSpatialCapabilityConfigurationBaseHeaderEXT 派生構造の XrSpatialCapabilityConfigurationBaseHeaderEXT :: enabledComponents リストに列挙子を含めることで、このコンポーネントを有効にできます。

このコンポーネントを XrSpatialCapabilityConfigurationBaseHeaderEXT :: next チェーンに含めるために、特別な構成は必要ありません。

飛行機のセマンティック ラベル

コンポーネント データ

typedef enum XrSpatialPlaneSemanticLabelEXT {
    XR_SPATIAL_PLANE_SEMANTIC_LABEL_UNCATEGORIZED_EXT = 1,
    XR_SPATIAL_PLANE_SEMANTIC_LABEL_FLOOR_EXT = 2,
    XR_SPATIAL_PLANE_SEMANTIC_LABEL_WALL_EXT = 3,
    XR_SPATIAL_PLANE_SEMANTIC_LABEL_CEILING_EXT = 4,
    XR_SPATIAL_PLANE_SEMANTIC_LABEL_TABLE_EXT = 5,
    XR_SPATIAL_PLANE_SEMANTIC_LABEL_MAX_ENUM_EXT = 0x7FFFFFFF
} XrSpatialPlaneSemanticLabelEXT;

XrSpatialPlaneSemanticLabelEXT 列挙型は、平面のセマンティック ラベルのセットを表します。

列挙型の説明

XR_SPATIAL_PLANE_SEMANTIC_LABEL_UNCATEGORIZED_EXT

ランタイムはこのエンティティを分類できませんでした。

XR_SPATIAL_PLANE_SEMANTIC_LABEL_FLOOR_EXT

エンティティはフロアです。

XR_SPATIAL_PLANE_SEMANTIC_LABEL_WALL_EXT

エンティティは壁です。

XR_SPATIAL_PLANE_SEMANTIC_LABEL_CEILING_EXT

エンティティは天井です。

XR_SPATIAL_PLANE_SEMANTIC_LABEL_TABLE_EXT

エンティティはテーブルです。

データをクエリするコンポーネント リストの構造

XrSpatialComponentPlaneSemanticLabelListEXT 構造体は次のように定義されます。

typedef struct XrSpatialComponentPlaneSemanticLabelListEXT {
    XrStructureType                    type;
    void*                              next;
    uint32_t                           semanticLabelCount;
    XrSpatialPlaneSemanticLabelEXT*    semanticLabels;
} XrSpatialComponentPlaneSemanticLabelListEXT;

メンバーの説明

  • type は、この構造の XrStructureType です。
  • next は、NULL または構造体チェーン内の次の構造体へのポインタです。
  • semanticLabelCount は、semanticLabels 配列内の要素の数を記述する uint32_t です。
  • semanticLabelsXrSpatialPlaneSemanticLabelEXT の配列です。

XrSpatialSnapshotEXT の空間エンティティの平面セマンティック ラベル コンポーネントをクエリするには、XrSpatialComponentDataQueryConditionEXT :: componentTypesXR_SPATIAL_COMPONENT_TYPE_PLANE_SEMANTIC_LABEL_EXT を含め、XrSpatialComponentDataQueryResultEXT :: next チェーンに XrSpatialComponentPlaneSemanticLabelListEXT を追加します。

ランタイムは、XrSpatialComponentPlaneSemanticLabelListEXTXrSpatialComponentDataQueryResultEXT :: next の次のチェーンにあるが、XR_SPATIAL_COMPONENT_TYPE_PLANE_SEMANTIC_LABEL_EXTXrSpatialComponentDataQueryConditionEXT :: componentTypes に含まれていない場合、xrQuerySpatialComponentDataEXT から XR_ERROR_VALIDATION_FAILURE を返さなければなりません

semanticLabelCountXrSpatialComponentDataQueryResultEXT :: entityIdCountOutput より小さい場合、ランタイムは xrQuerySpatialComponentDataEXT から XR_ERROR_SIZE_INSUFFICIENT を返さなければなりません。

有効な使用方法(暗黙的)

構成

XR_SPATIAL_COMPONENT_TYPE_PLANE_SEMANTIC_LABEL_EXTXrSpatialCapabilityComponentTypesEXT :: componentTypes で列挙されている場合、アプリは、このコンポーネントをサポートするケーパビリティの XrSpatialCapabilityConfigurationBaseHeaderEXT 派生構造の XrSpatialCapabilityConfigurationBaseHeaderEXT :: enabledComponents リストに列挙子を含めることで、このコンポーネントを有効にできます。

このコンポーネントを XrSpatialCapabilityConfigurationBaseHeaderEXT :: next チェーンに含めるために、特別な構成は必要ありません。

コード例

Plane Tracking Capability を構成する

次のサンプルコードは、空間コンテキストの作成時に平面トラッキング機能を構成する方法を示しています。

// Check if plane tracking capability is supported
uint32_t capabilityCount;
CHK_XR(xrEnumerateSpatialCapabilitiesEXT(instance, systemId, 0, &capabilityCount, nullptr));
std::vector<XrSpatialCapabilityEXT> capabilities(capabilityCount);
CHK_XR(xrEnumerateSpatialCapabilitiesEXT(instance, systemId, capabilityCount, &capabilityCount, capabilities.data()));

if (std::find(capabilities.begin(), capabilities.end(), XR_SPATIAL_CAPABILITY_PLANE_TRACKING_EXT) == capabilities.end()) {
  return;
}

// Enumerate supported components for plane tracking capability
XrSpatialCapabilityComponentTypesEXT planeComponents{XR_TYPE_SPATIAL_CAPABILITY_COMPONENT_TYPES_EXT};
CHK_XR(xrEnumerateSpatialCapabilityComponentTypesEXT(instance, systemId, XR_SPATIAL_CAPABILITY_PLANE_TRACKING_EXT, &planeComponents));
std::vector<XrSpatialComponentTypeEXT> planeCapabilityComponents(planeComponents.componentTypeCountOutput);
planeComponents.componentTypeCapacityInput = planeCapabilityComponents.size();
planeComponents.componentTypes = planeCapabilityComponents.data();
CHK_XR(xrEnumerateSpatialCapabilityComponentTypesEXT(instance, systemId, XR_SPATIAL_CAPABILITY_PLANE_TRACKING_EXT, &planeComponents));

// Check if polygon 2D and plane semantic labels optional components are supported
const auto supportsComponent = [&planeCapabilityComponents](XrSpatialComponentTypeEXT component) {
  return std::find(planeCapabilityComponents.begin(), planeCapabilityComponents.end(), component) != planeCapabilityComponents.end();
};

const bool supportsPolygon2DComponent = supportsComponent(XR_SPATIAL_COMPONENT_TYPE_POLYGON_2D_EXT);
const bool supportsSemanticLabelComponent = supportsComponent(XR_SPATIAL_COMPONENT_TYPE_PLANE_SEMANTIC_LABEL_EXT);

// Create a spatial context
XrSpatialContextEXT spatialContext{};

// Enable the 2 guaranteed components of the plane tracking capability
std::vector<XrSpatialComponentTypeEXT> enabledComponents = {
  XR_SPATIAL_COMPONENT_TYPE_BOUNDED_2D_EXT,
  XR_SPATIAL_COMPONENT_TYPE_PLANE_ALIGNMENT_EXT,
};
// Optionally enable polygon2D if it is supported
if (supportsPolygon2DComponent) {
  enabledComponents.push_back(XR_SPATIAL_COMPONENT_TYPE_POLYGON_2D_EXT);
}
// Optionally enable semantic labels if it is supported
if (supportsSemanticLabelComponent) {
  enabledComponents.push_back(XR_SPATIAL_COMPONENT_TYPE_PLANE_SEMANTIC_LABEL_EXT);
}

XrSpatialCapabilityConfigurationPlaneTrackingEXT planeConfig{XR_TYPE_SPATIAL_CAPABILITY_CONFIGURATION_PLANE_TRACKING_EXT};
planeConfig.capability = XR_SPATIAL_CAPABILITY_PLANE_TRACKING_EXT;
planeConfig.enabledComponentCount = enabledComponents.size();
planeConfig.enabledComponents = enabledComponents.data();

std::array<XrSpatialCapabilityConfigurationBaseHeaderEXT*, 1> capabilityConfigs = {
  reinterpret_cast<XrSpatialCapabilityConfigurationBaseHeaderEXT*>(&planeConfig),
};

XrSpatialContextCreateInfoEXT spatialContextCreateInfo{XR_TYPE_SPATIAL_CONTEXT_CREATE_INFO_EXT};
spatialContextCreateInfo.capabilityConfigCount = capabilityConfigs.size();
spatialContextCreateInfo.capabilityConfigs = capabilityConfigs.data();
XrFutureEXT createContextFuture;
CHK_XR(xrCreateSpatialContextAsyncEXT(session, &spatialContextCreateInfo, &createContextFuture));

waitUntilReady(createContextFuture);

XrCreateSpatialContextCompletionEXT completion{XR_TYPE_CREATE_SPATIAL_CONTEXT_COMPLETION_EXT};
CHK_XR(xrCreateSpatialContextCompleteEXT(session, createContextFuture, &completion));
if (completion.futureResult != XR_SUCCESS) {
  return;
}

spatialContext = completion.spatialContext;

// ...
// Discover entities with the spatial context
// ...

CHK_XR(xrDestroySpatialContextEXT(spatialContext));

空間エンティティを検出してコンポーネント データをクエリする

次のサンプルコードは、XR_SPATIAL_CAPABILITY_PLANE_TRACKING_EXT で構成されたコンテキストの空間エンティティを検出し、そのコンポーネント データをクエリする方法を示しています。

XrFutureEXT future = XR_NULL_FUTURE_EXT;

// We want to look for entities that have the following components.
std::vector<XrSpatialComponentTypeEXT> snapshotComponents = {
  XR_SPATIAL_COMPONENT_TYPE_BOUNDED_2D_EXT,
  XR_SPATIAL_COMPONENT_TYPE_PLANE_ALIGNMENT_EXT,
};
if (supportsPolygon2DComponent) {
  snapshotComponents.push_back(XR_SPATIAL_COMPONENT_TYPE_POLYGON_2D_EXT);
}
if (supportsSemanticLabelComponent) {
  snapshotComponents.push_back(XR_SPATIAL_COMPONENT_TYPE_PLANE_SEMANTIC_LABEL_EXT);
}

auto discoverSpatialEntities = [&](XrSpatialContextEXT spatialContext, XrTime time) {
  XrSpatialDiscoverySnapshotCreateInfoEXT snapshotCreateInfo{XR_TYPE_SPATIAL_DISCOVERY_SNAPSHOT_CREATE_INFO_EXT};
  snapshotCreateInfo.componentTypeCount = snapshotComponents.size();
  snapshotCreateInfo.componentTypes = snapshotComponents.data();
  CHK_XR(xrCreateSpatialDiscoverySnapshotAsyncEXT(spatialContext, &snapshotCreateInfo, &future));

  waitUntilReady(future);

  XrCreateSpatialDiscoverySnapshotCompletionInfoEXT completionInfo{XR_TYPE_CREATE_SPATIAL_DISCOVERY_SNAPSHOT_COMPLETION_INFO_EXT};
  completionInfo.baseSpace = localSpace;
  completionInfo.time = time;
  completionInfo.future = future;

  XrCreateSpatialDiscoverySnapshotCompletionEXT completion{XR_TYPE_CREATE_SPATIAL_DISCOVERY_SNAPSHOT_COMPLETION_EXT};
  CHK_XR(xrCreateSpatialDiscoverySnapshotCompleteEXT(spatialContext, &completionInfo, &completion));
  if (completion.futureResult == XR_SUCCESS) {

    // Query for the semantic label component data
    XrSpatialComponentDataQueryConditionEXT queryCond{XR_TYPE_SPATIAL_COMPONENT_DATA_QUERY_CONDITION_EXT};
    queryCond.componentTypeCount = snapshotComponents.size();
    queryCond.componentTypes = snapshotComponents.data();

    XrSpatialComponentDataQueryResultEXT queryResult{XR_TYPE_SPATIAL_COMPONENT_DATA_QUERY_RESULT_EXT};
    CHK_XR(xrQuerySpatialComponentDataEXT(completion.snapshot, &queryCond, &queryResult));

    std::vector<XrSpatialEntityIdEXT> entityIds(queryResult.entityIdCountOutput);
    std::vector<XrSpatialEntityTrackingStateEXT> entityStates(queryResult.entityIdCountOutput);
    queryResult.entityIdCapacityInput = entityIds.size();
    queryResult.entityIds = entityIds.data();
    queryResult.entityStateCapacityInput = entityStates.size();
    queryResult.entityStates = entityStates.data();

    std::vector<XrSpatialBounded2DDataEXT> bounded2D(queryResult.entityIdCountOutput);
    XrSpatialComponentBounded2DListEXT bounded2DList{XR_TYPE_SPATIAL_COMPONENT_BOUNDED_2D_LIST_EXT};
    bounded2DList.boundCount = bounded2D.size();
    bounded2DList.bounds = bounded2D.data();
    queryResult.next = &bounded2DList;

    std::vector<XrSpatialPolygon2DDataEXT> polygons;
    XrSpatialComponentPolygon2DListEXT polygonList{XR_TYPE_SPATIAL_COMPONENT_POLYGON_2D_LIST_EXT};
    if (supportsPolygon2DComponent) {
      polygons.resize(queryResult.entityIdCountOutput);
      polygonList.polygonCount = polygons.size();
      polygonList.polygons = polygons.data();
      polygonList.next = queryResult.next;
      queryResult.next = &polygonList;
    }

    std::vector<XrSpatialPlaneSemanticLabelEXT> semanticLabels;
    XrSpatialComponentPlaneSemanticLabelListEXT semanticLabelsList{XR_TYPE_SPATIAL_COMPONENT_PLANE_SEMANTIC_LABEL_LIST_EXT};
    if (supportsSemanticLabelComponent) {
      semanticLabels.resize(queryResult.entityIdCountOutput);
      semanticLabelsList.semanticLabelCount = semanticLabels.size();
      semanticLabelsList.semanticLabels = semanticLabels.data();
      semanticLabelsList.next = queryResult.next;
      queryResult.next = &semanticLabelsList;
    }

    CHK_XR(xrQuerySpatialComponentDataEXT(completion.snapshot, &queryCond, &queryResult));

    for (int32_t i = 0; i < queryResult.entityIdCountOutput; ++i) {
      if (entityStates[i] != XR_SPATIAL_ENTITY_TRACKING_STATE_TRACKING_EXT) {
        continue;
      }

      // 2D bounds for entity entityIds[i] is bounded2D[i].extents centered on bounded2D[i].center.

      if (supportsPolygon2DComponent) {
        // 2D polygon for entity entityIds[i] is the buffer represented by polygons[i].bufferId.
        // Application uses flink:xrGetSpatialBufferVector2fEXT to get the buffer data.
      }

      if (supportsSemanticLabelComponent) {
        // semantic label for entity entityIds[i] is semanticLabels[i].
      }
    }

    CHK_XR(xrDestroySpatialSnapshotEXT(completion.snapshot));
  }
};

while (1) {
  // ...
  // For every frame in frame loop
  // ...

  XrFrameState frameState;  // previously returned from xrWaitFrame
  const XrTime time = frameState.predictedDisplayTime;

  // Poll for the XR_TYPE_EVENT_DATA_SPATIAL_DISCOVERY_RECOMMENDED_EXT event
  XrEventDataBuffer event = {XR_TYPE_EVENT_DATA_BUFFER};
  XrResult result = xrPollEvent(instance, &event);
  if (result == XR_SUCCESS) {
      switch (event.type) {
          case XR_TYPE_EVENT_DATA_SPATIAL_DISCOVERY_RECOMMENDED_EXT: {
              const XrEventDataSpatialDiscoveryRecommendedEXT& eventdata =
                  *reinterpret_cast<XrEventDataSpatialDiscoveryRecommendedEXT*>(&event);
              // Discover spatial entities for the context that we received the "discovery
              // recommended" event for.
              discoverSpatialEntities(eventdata.spatialContext, time);
              break;
          }
      }
  }

  // ...
  // Finish frame loop
  // ...
}

新しい構造体

新しい列挙型

新しい列挙型定数

  • XR_EXT_SPATIAL_PLANE_TRACKING_EXTENSION_NAME
  • XR_EXT_spatial_plane_tracking_SPEC_VERSION
  • XrSpatialCapabilityEXT を拡張する :

    • XR_SPATIAL_CAPABILITY_PLANE_TRACKING_EXT
  • XrSpatialComponentTypeEXT を拡張する :

    • XR_SPATIAL_COMPONENT_TYPE_MESH_2D_EXT
    • XR_SPATIAL_COMPONENT_TYPE_PLANE_ALIGNMENT_EXT
    • XR_SPATIAL_COMPONENT_TYPE_PLANE_SEMANTIC_LABEL_EXT
    • XR_SPATIAL_COMPONENT_TYPE_POLYGON_2D_EXT
  • XrStructureType を拡張する :

    • XR_TYPE_SPATIAL_CAPABILITY_CONFIGURATION_PLANE_TRACKING_EXT
    • XR_TYPE_SPATIAL_COMPONENT_MESH_2D_LIST_EXT
    • XR_TYPE_SPATIAL_COMPONENT_PLANE_ALIGNMENT_LIST_EXT
    • XR_TYPE_SPATIAL_COMPONENT_PLANE_SEMANTIC_LABEL_LIST_EXT
    • XR_TYPE_SPATIAL_COMPONENT_POLYGON_2D_LIST_EXT

問題

変更履歴

  • 改訂 1、2024 年 7 月 2 日(Google、Nihav Jain)

    • 拡張機能の最初の説明