XR_EXT_spatial_plane_tracking
Name String
XR_EXT_spatial_plane_tracking
Extension Type
Instance extension
Registered Extension Number
742
Revision
1
Ratification Status
อนุมัติ
Extension and Version Dependencies
XR_EXT_spatial_entity
Contributors
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 และกำหนดความสามารถเชิงพื้นที่ในการติดตามระนาบสำหรับเฟรมเวิร์กเอนทิตีเชิงพื้นที่
Runtime Support
หากรันไทม์รองรับการติดตามระนาบ รันไทม์ต้อง ระบุสิ่งนี้โดยการแจกแจง XR_SPATIAL_CAPABILITY_PLANE_TRACKING_EXT ใน xrEnumerateSpatialCapabilitiesEXT
การกำหนดค่า
โครงสร้าง XrSpatialCapabilityConfigurationPlaneTrackingEXT มีการกำหนดไว้ดังนี้
typedef struct XrSpatialCapabilityConfigurationPlaneTrackingEXT {
XrStructureType type;
const void* next;
XrSpatialCapabilityEXT capability;
uint32_t enabledComponentCount;
const XrSpatialComponentTypeEXT* enabledComponents;
} XrSpatialCapabilityConfigurationPlaneTrackingEXT;
คำอธิบายสมาชิก
typeคือ XrStructureType ของโครงสร้างนี้nextคือNULLหรือ Pointer ไปยังโครงสร้างถัดไปในเชนโครงสร้างcapabilityคือ XrSpatialCapabilityEXT และ ต้อง เป็นXR_SPATIAL_CAPABILITY_PLANE_TRACKING_EXTenabledComponentCountคือuint32_tที่อธิบายจำนวนองค์ประกอบในอาร์เรย์enabledComponentsenabledComponentsคือพอยน์เตอร์ไปยังอาร์เรย์ของ XrSpatialComponentTypeEXT
แอปพลิเคชันสามารถ เปิดใช้ความสามารถเชิงพื้นที่ XR_SPATIAL_CAPABILITY_PLANE_TRACKING_EXT ได้โดยใส่พอยน์เตอร์ไปยังโครงสร้าง XrSpatialCapabilityConfigurationPlaneTrackingEXT ใน XrSpatialContextCreateInfoEXT :: capabilityConfigs
รันไทม์ต้อง แสดงผล XR_ERROR_VALIDATION_FAILURE หาก capability ไม่ใช่ XR_SPATIAL_CAPABILITY_PLANE_TRACKING_EXT
การใช้งานที่ถูกต้อง (โดยนัย)
- ต้องเปิดใช้ส่วนขยาย
XR_EXT_spatial_plane_trackingก่อน ใช้ XrSpatialCapabilityConfigurationPlaneTrackingEXT -
typeต้อง เป็นXR_TYPE_SPATIAL_CAPABILITY_CONFIGURATION_PLANE_TRACKING_EXT -
nextต้อง เป็นNULLหรือพอยน์เตอร์ที่ถูกต้องไปยังโครงสร้างถัดไปในเชนโครงสร้าง -
capabilityต้อง เป็นค่า XrSpatialCapabilityEXT ที่ถูกต้อง -
enabledComponentsต้อง เป็น Pointer ไปยัง อาร์เรย์ ของค่าenabledComponentCountที่ถูกต้อง XrSpatialComponentTypeEXT - พารามิเตอร์
enabledComponentCountต้อง มากกว่า0
คอมโพเนนต์ที่รับประกัน
รันไทม์ที่รองรับ XR_SPATIAL_CAPABILITY_PLANE_TRACKING_EXT ต้อง จัดหาคอมโพเนนต์เชิงพื้นที่ต่อไปนี้เป็นคอมโพเนนต์ที่รับประกันของเอนทิตีทั้งหมดที่ค้นพบโดยความสามารถนี้ และต้อง แจกแจงคอมโพเนนต์เหล่านี้ใน xrEnumerateSpatialCapabilityComponentTypesEXT :
XR_SPATIAL_COMPONENT_TYPE_BOUNDED_2D_EXTXR_SPATIAL_COMPONENT_TYPE_PLANE_ALIGNMENT_EXT
คอมโพเนนต์ 2 มิติแบบมีขอบเขต
คอมโพเนนต์ 2 มิติแบบมีขอบเขตจะระบุจุดกึ่งกลางและขอบเขตของระนาบที่แสดงโดยเอนทิตีที่คอมโพเนนต์อยู่ ดูรายละเอียดเพิ่มเติมได้ที่ 2 มิติแบบมีขอบเขต
คอมโพเนนต์การจัดแนวระนาบ
ข้อมูลคอมโพเนนต์
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
ค่าการแจกแจงมีความหมายดังนี้
คำอธิบาย Enum
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หรือ Pointer ไปยังโครงสร้างถัดไปในเชนโครงสร้างplaneAlignmentCountคือuint32_tที่อธิบายจำนวนองค์ประกอบในอาร์เรย์planeAlignmentsplaneAlignmentsคืออาร์เรย์ของ XrSpatialPlaneAlignmentEXT
หากต้องการค้นหาคอมโพเนนต์การจัดแนวระนาบของเอนทิตีเชิงพื้นที่ใน XrSpatialSnapshotEXT ให้ใส่ XR_SPATIAL_COMPONENT_TYPE_PLANE_ALIGNMENT_EXT ใน XrSpatialComponentDataQueryConditionEXT :: componentTypes และเพิ่ม XrSpatialComponentPlaneAlignmentListEXT ลงในเชน XrSpatialComponentDataQueryResultEXT :: next
รันไทม์ต้อง แสดงผล XR_ERROR_VALIDATION_FAILURE จาก xrQuerySpatialComponentDataEXT หาก XrSpatialComponentPlaneAlignmentListEXT อยู่ในเชน XrSpatialComponentDataQueryResultEXT :: next แต่ XR_SPATIAL_COMPONENT_TYPE_PLANE_ALIGNMENT_EXT ไม่ได้รวมอยู่ใน XrSpatialComponentDataQueryConditionEXT :: componentTypes
รันไทม์ต้อง แสดงผล XR_ERROR_SIZE_INSUFFICIENT จาก xrQuerySpatialComponentDataEXT หาก planeAlignmentCount น้อยกว่า XrSpatialComponentDataQueryResultEXT :: entityIdCountOutput
การใช้งานที่ถูกต้อง (โดยนัย)
- ต้องเปิดใช้ส่วนขยาย
XR_EXT_spatial_plane_trackingก่อน ใช้ XrSpatialComponentPlaneAlignmentListEXT -
typeต้อง เป็นXR_TYPE_SPATIAL_COMPONENT_PLANE_ALIGNMENT_LIST_EXT -
nextต้อง เป็นNULLหรือพอยน์เตอร์ที่ถูกต้องไปยังโครงสร้างถัดไปในเชนโครงสร้าง -
planeAlignmentsต้อง เป็น Pointer ไปยัง อาร์เรย์ ของplaneAlignmentCountค่า XrSpatialPlaneAlignmentEXT - พารามิเตอร์
planeAlignmentCountต้อง มากกว่า0
การกำหนดค่า
หากมีการแจกแจง XR_SPATIAL_COMPONENT_TYPE_PLANE_ALIGNMENT_EXT ใน XrSpatialCapabilityComponentTypesEXT :: componentTypes สำหรับความสามารถบางอย่าง แอปพลิเคชันสามารถ เปิดใช้ได้โดยใส่การแจกแจงในรายการ XrSpatialCapabilityConfigurationBaseHeaderEXT :: enabledComponents ของโครงสร้างที่ได้จาก XrSpatialCapabilityConfigurationBaseHeaderEXT ของความสามารถที่รองรับคอมโพเนนต์นี้
คอมโพเนนต์นี้ไม่จำเป็นต้องมีการกำหนดค่าพิเศษใดๆ เพื่อรวมไว้ในเชน XrSpatialCapabilityConfigurationBaseHeaderEXT :: next
คอมโพเนนต์ที่ไม่บังคับ
รันไทม์ที่รองรับ XR_SPATIAL_CAPABILITY_PLANE_TRACKING_EXT อาจ รองรับคอมโพเนนต์เชิงพื้นที่อื่นๆ นอกเหนือจากที่ระบุไว้ในส่วน คอมโพเนนต์ที่รับประกัน แอปพลิเคชันใช้ xrEnumerateSpatialCapabilityComponentTypesEXT เพื่อรับรายการคอมโพเนนต์ทั้งหมดที่รันไทม์รองรับ จากนั้นกำหนดค่าคอมโพเนนต์ที่สนใจเมื่อสร้างบริบทเชิงพื้นที่
คอมโพเนนต์ Mesh 2 มิติ
ข้อมูลคอมโพเนนต์
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หรือ Pointer ไปยังโครงสร้างถัดไปในเชนโครงสร้างmeshCountคือuint32_tที่อธิบายจำนวนองค์ประกอบในอาร์เรย์meshesmeshesคืออาร์เรย์ของ XrSpatialMeshDataEXT
หากต้องการค้นหาคอมโพเนนต์ Mesh 2 มิติของเอนทิตีเชิงพื้นที่ใน XrSpatialSnapshotEXT ให้ใส่ XR_SPATIAL_COMPONENT_TYPE_MESH_2D_EXT ใน XrSpatialComponentDataQueryConditionEXT :: componentTypes และเพิ่ม XrSpatialComponentMesh2DListEXT ลงในเชน XrSpatialComponentDataQueryResultEXT :: next
รันไทม์ต้อง แสดงผล XR_ERROR_VALIDATION_FAILURE จาก xrQuerySpatialComponentDataEXT หาก XrSpatialComponentMesh2DListEXT อยู่ในเชน XrSpatialComponentDataQueryResultEXT :: next แต่ XR_SPATIAL_COMPONENT_TYPE_MESH_2D_EXT ไม่ได้รวมอยู่ใน XrSpatialComponentDataQueryConditionEXT :: componentTypes
รันไทม์ต้อง แสดงผล XR_ERROR_SIZE_INSUFFICIENT จาก xrQuerySpatialComponentDataEXT หาก meshCount น้อยกว่า XrSpatialComponentDataQueryResultEXT :: entityIdCountOutput
สำหรับ XrSpatialMeshDataEXT ที่รันไทม์ป้อนข้อมูลในอาร์เรย์ meshes นั้น XrSpatialBufferEXT :: bufferType สำหรับ XrSpatialMeshDataEXT :: vertexBuffer ต้อง เป็น XR_SPATIAL_BUFFER_TYPE_VECTOR2F_EXT และ XrSpatialBufferEXT :: bufferType สำหรับ XrSpatialMeshDataEXT :: indexBuffer ต้อง เป็น XR_SPATIAL_BUFFER_TYPE_UINT16_EXT
การใช้งานที่ถูกต้อง (โดยนัย)
- ต้องเปิดใช้ส่วนขยาย
XR_EXT_spatial_plane_trackingก่อน ใช้ XrSpatialComponentMesh2DListEXT -
typeต้อง เป็นXR_TYPE_SPATIAL_COMPONENT_MESH_2D_LIST_EXT -
nextต้อง เป็นNULLหรือพอยน์เตอร์ที่ถูกต้องไปยังโครงสร้างถัดไปในเชนโครงสร้าง -
meshesต้อง เป็น Pointer ไปยัง อาร์เรย์ ของโครงสร้างmeshCountXrSpatialMeshDataEXT - พารามิเตอร์
meshCountต้อง มากกว่า0
การกำหนดค่า
หากมีการแจกแจง XR_SPATIAL_COMPONENT_TYPE_MESH_2D_EXT ใน XrSpatialCapabilityComponentTypesEXT :: componentTypes สำหรับความสามารถบางอย่าง แอปพลิเคชันสามารถ เปิดใช้ได้โดยใส่การแจกแจงในรายการ XrSpatialCapabilityConfigurationBaseHeaderEXT :: enabledComponents ของโครงสร้างที่ได้จาก XrSpatialCapabilityConfigurationBaseHeaderEXT ของความสามารถที่รองรับคอมโพเนนต์นี้
คอมโพเนนต์นี้ไม่จำเป็นต้องมีการกำหนดค่าพิเศษใดๆ เพื่อรวมไว้ในเชน XrSpatialCapabilityConfigurationBaseHeaderEXT :: next
คอมโพเนนต์รูปหลายเหลี่ยม 2 มิติ
ข้อมูลคอมโพเนนต์
โครงสร้าง XrSpatialPolygon2DDataEXT มีการกำหนดไว้ดังนี้
typedef struct XrSpatialPolygon2DDataEXT {
XrPosef origin;
XrSpatialBufferEXT vertexBuffer;
} XrSpatialPolygon2DDataEXT;
คำอธิบายสมาชิก
originคือ XrPosef ที่กำหนดจุดเริ่มต้นของรูปหลายเหลี่ยม จุดยอดทั้งหมดของรูปหลายเหลี่ยมจะสัมพันธ์กับจุดเริ่มต้นนี้ในระนาบ X-YvertexBufferคือ XrSpatialBufferEXT ที่ระบุรหัสสำหรับบัฟเฟอร์ประเภทXR_SPATIAL_BUFFER_TYPE_VECTOR2F_EXTและแสดงถึงบัฟเฟอร์จุดยอดของเอนทิตีที่คอมโพเนนต์นี้อยู่ ระบบต้อง แสดงผลจุดยอดตามลำดับทวนเข็มนาฬิกา รูปหลายเหลี่ยมที่แสดงโดยจุดยอดเหล่านี้ต้อง ไม่ตัดกันเองและอาจ เป็นรูปเว้า
XrSpatialBufferEXT :: bufferType สำหรับ vertexBuffer ต้อง เป็น XR_SPATIAL_BUFFER_TYPE_VECTOR2F_EXT .
การใช้งานที่ถูกต้อง (โดยนัย)
- ต้องเปิดใช้ส่วนขยาย
XR_EXT_spatial_plane_trackingก่อน ใช้ XrSpatialPolygon2DDataEXT -
vertexBufferต้อง เป็นโครงสร้าง XrSpatialBufferEXT ที่ถูกต้อง
โครงสร้างรายการคอมโพเนนต์เพื่อค้นหาข้อมูล
โครงสร้าง XrSpatialComponentPolygon2DListEXT มีการกำหนดไว้ดังนี้
typedef struct XrSpatialComponentPolygon2DListEXT {
XrStructureType type;
void* next;
uint32_t polygonCount;
XrSpatialPolygon2DDataEXT* polygons;
} XrSpatialComponentPolygon2DListEXT;
คำอธิบายสมาชิก
typeคือ XrStructureType ของโครงสร้างนี้nextคือNULLหรือ Pointer ไปยังโครงสร้างถัดไปในเชนโครงสร้างpolygonCountคือuint32_tที่อธิบายจำนวนองค์ประกอบในอาร์เรย์polygonspolygonsคืออาร์เรย์ของ XrSpatialPolygon2DDataEXT
หากต้องการค้นหาคอมโพเนนต์รูปหลายเหลี่ยม 2 มิติของเอนทิตีเชิงพื้นที่ใน XrSpatialSnapshotEXT ให้ใส่ XR_SPATIAL_COMPONENT_TYPE_POLYGON_2D_EXT ใน XrSpatialComponentDataQueryConditionEXT :: componentTypes และเพิ่ม XrSpatialComponentPolygon2DListEXT ลงในเชน XrSpatialComponentDataQueryResultEXT :: next
รันไทม์ต้อง แสดงผล XR_ERROR_VALIDATION_FAILURE จาก xrQuerySpatialComponentDataEXT หาก XrSpatialComponentPolygon2DListEXT อยู่ในเชน XrSpatialComponentDataQueryResultEXT :: next แต่ XR_SPATIAL_COMPONENT_TYPE_POLYGON_2D_EXT ไม่ได้รวมอยู่ใน XrSpatialComponentDataQueryConditionEXT :: componentTypes
รันไทม์ต้อง แสดงผล XR_ERROR_SIZE_INSUFFICIENT จาก xrQuerySpatialComponentDataEXT หาก polygonCount น้อยกว่า XrSpatialComponentDataQueryResultEXT :: entityIdCountOutput
การใช้งานที่ถูกต้อง (โดยนัย)
- ต้องเปิดใช้ส่วนขยาย
XR_EXT_spatial_plane_trackingก่อน ใช้ XrSpatialComponentPolygon2DListEXT -
typeต้อง เป็นXR_TYPE_SPATIAL_COMPONENT_POLYGON_2D_LIST_EXT -
nextต้อง เป็นNULLหรือพอยน์เตอร์ที่ถูกต้องไปยังโครงสร้างถัดไปในเชนโครงสร้าง -
polygonsต้อง เป็นพอยน์เตอร์ไปยังอาร์เรย์ของpolygonCountXrSpatialPolygon2DDataEXT โครงสร้าง - พารามิเตอร์
polygonCountต้อง มากกว่า0
การกำหนดค่า
หากมีการแจกแจง XR_SPATIAL_COMPONENT_TYPE_POLYGON_2D_EXT ใน XrSpatialCapabilityComponentTypesEXT :: componentTypes สำหรับความสามารถบางอย่าง แอปพลิเคชันสามารถ เปิดใช้ได้โดยใส่การแจกแจงในรายการ XrSpatialCapabilityConfigurationBaseHeaderEXT :: enabledComponents ของโครงสร้างที่ได้จาก XrSpatialCapabilityConfigurationBaseHeaderEXT ของความสามารถที่รองรับคอมโพเนนต์นี้
คอมโพเนนต์นี้ไม่จำเป็นต้องมีการกำหนดค่าพิเศษใดๆ เพื่อรวมไว้ในเชน 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 อธิบายชุดป้ายกำกับความหมายสำหรับระนาบ
คำอธิบาย Enum
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หรือ Pointer ไปยังโครงสร้างถัดไปในเชนโครงสร้างsemanticLabelCountคือuint32_tที่อธิบายจำนวนองค์ประกอบในอาร์เรย์semanticLabelssemanticLabelsคืออาร์เรย์ของ XrSpatialPlaneSemanticLabelEXT
หากต้องการค้นหาคอมโพเนนต์ป้ายกำกับความหมายของระนาบของเอนทิตีเชิงพื้นที่ใน XrSpatialSnapshotEXT ให้ใส่ XR_SPATIAL_COMPONENT_TYPE_PLANE_SEMANTIC_LABEL_EXT ใน XrSpatialComponentDataQueryConditionEXT :: componentTypes และเพิ่ม XrSpatialComponentPlaneSemanticLabelListEXT ลงในเชน XrSpatialComponentDataQueryResultEXT :: next
รันไทม์ต้อง แสดงผล XR_ERROR_VALIDATION_FAILURE จาก xrQuerySpatialComponentDataEXT หาก XrSpatialComponentPlaneSemanticLabelListEXT อยู่ในเชนถัดไปของ XrSpatialComponentDataQueryResultEXT :: next แต่ XR_SPATIAL_COMPONENT_TYPE_PLANE_SEMANTIC_LABEL_EXT ไม่ได้รวมอยู่ใน XrSpatialComponentDataQueryConditionEXT :: componentTypes
รันไทม์ต้อง แสดงผล XR_ERROR_SIZE_INSUFFICIENT จาก xrQuerySpatialComponentDataEXT หาก semanticLabelCount น้อยกว่า XrSpatialComponentDataQueryResultEXT :: entityIdCountOutput
การใช้งานที่ถูกต้อง (โดยนัย)
- ต้องเปิดใช้ส่วนขยาย
XR_EXT_spatial_plane_trackingก่อน ใช้ XrSpatialComponentPlaneSemanticLabelListEXT -
typeต้อง เป็นXR_TYPE_SPATIAL_COMPONENT_PLANE_SEMANTIC_LABEL_LIST_EXT -
nextต้อง เป็นNULLหรือพอยน์เตอร์ที่ถูกต้องไปยังโครงสร้างถัดไปในเชนโครงสร้าง -
semanticLabelsต้อง เป็น Pointer ไปยัง อาร์เรย์ ของค่าsemanticLabelCountXrSpatialPlaneSemanticLabelEXT - พารามิเตอร์
semanticLabelCountต้อง มากกว่า0
การกำหนดค่า
หากมีการแจกแจง XR_SPATIAL_COMPONENT_TYPE_PLANE_SEMANTIC_LABEL_EXT ใน XrSpatialCapabilityComponentTypesEXT :: componentTypes สำหรับความสามารถบางอย่าง แอปพลิเคชันสามารถ เปิดใช้ได้โดยใส่การแจกแจงในรายการ XrSpatialCapabilityConfigurationBaseHeaderEXT :: enabledComponents ของโครงสร้างที่ได้จาก XrSpatialCapabilityConfigurationBaseHeaderEXT ของความสามารถที่รองรับคอมโพเนนต์นี้
คอมโพเนนต์นี้ไม่จำเป็นต้องมีการกำหนดค่าพิเศษใดๆ เพื่อรวมไว้ในเชน XrSpatialCapabilityConfigurationBaseHeaderEXT :: next
โค้ดตัวอย่าง
กำหนดค่าความสามารถในการติดตามระนาบ
โค้ดตัวอย่างต่อไปนี้แสดงวิธีกำหนดค่าความสามารถในการติดตามระนาบเมื่อสร้างบริบทเชิงพื้นที่
// 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
// ...
}
โครงสร้างใหม่
- XrSpatialCapabilityConfigurationPlaneTrackingEXT
- XrSpatialPolygon2DDataEXT
การขยาย XrSpatialComponentDataQueryResultEXT :
Enum ใหม่
ค่าคงที่ Enum ใหม่
XR_EXT_SPATIAL_PLANE_TRACKING_EXTENSION_NAMEXR_EXT_spatial_plane_tracking_SPEC_VERSIONการขยาย XrSpatialCapabilityEXT :
XR_SPATIAL_CAPABILITY_PLANE_TRACKING_EXT
การขยาย XrSpatialComponentTypeEXT :
XR_SPATIAL_COMPONENT_TYPE_MESH_2D_EXTXR_SPATIAL_COMPONENT_TYPE_PLANE_ALIGNMENT_EXTXR_SPATIAL_COMPONENT_TYPE_PLANE_SEMANTIC_LABEL_EXTXR_SPATIAL_COMPONENT_TYPE_POLYGON_2D_EXT
การขยาย XrStructureType :
XR_TYPE_SPATIAL_CAPABILITY_CONFIGURATION_PLANE_TRACKING_EXTXR_TYPE_SPATIAL_COMPONENT_MESH_2D_LIST_EXTXR_TYPE_SPATIAL_COMPONENT_PLANE_ALIGNMENT_LIST_EXTXR_TYPE_SPATIAL_COMPONENT_PLANE_SEMANTIC_LABEL_LIST_EXTXR_TYPE_SPATIAL_COMPONENT_POLYGON_2D_LIST_EXT
ปัญหา
ประวัติเวอร์ชัน
เวอร์ชัน 1, 02-07-2024 (Nihav Jain, Google)
- คำอธิบายส่วนขยายเริ่มต้น