HoloLens 具有内置摄像机,可连续扫描环境,因此能够为真实世界的物体构建虚拟世界几何体。这种能力可让 HoloLens 在虚拟内容和真实世界之间创建令人信服的交互(例如遮挡以及与现实世界物体进行物理交互)。将真实世界表面映射到虚拟世界的过程称为__空间映射 (Spatial Mapping)__。
Unity Editor 有一个低级脚本 API 用于在项目环境中收集有关表面的信息。此 API 可用于最大限度控制何时查询设备的表面更改,以及何时创建或更新相应的表面游戏对象。Unity 的空间映射 (Spatial Mapping) 组件可用于快速设置并运行 Windows Mixed Reality,而无需直接使用低级脚本 API。
__空间映射__是为 HoloLens 应用程序添加更出色的真实世界交互体验的好方法。
HoloLens 设备不断扫描周围环境,并根据传入的传感器数据优化对世界的理解。该设备频繁更新这些数据以便捕捉到环境变化,例如有人出入房间或开关门。空间映射将世界映射数据集保存到 HoloLens 设备,而这些数据将在多个应用程序之间以及设备重新启动后持续保留。
HoloLens 的空间映射不适用于透明、黑色和反射表面。如果设备无法检测到真实世界物体,则空间映射数据中会出现一个空洞。对于设备尚未看到或未能看到的世界部分,也是如此。例如,HoloLens 未观察到的房间不存在任何数据。
该设备的世界映射分为均匀的块,称为“表面”。空间映射系统以一种对系统本身而言非常方便的方式定位世界中的表面。无法保证系统会以任何特定方向排列表面,而表面也可能与给定的真实世界空间(例如房间)不正确地相交。当空间映射生成某个表面的数据时,该数据会与相邻的表面轻微重叠。
注意:空间映射不存在与任何表面数据相关联的语义或解释。空间映射不知道也无法报告表面上实际是什么。例如,无法分辨出在桌子上检测到的斑点实际上是一个杯子,也不能判断房间中间的椅子状物体到底是什么。空间映射仅根据自身对世界的理解(使用传感输入数据构建对世界的认知)报告该区域中几何体的配置。
为了在使用空间映射开发应用程序时避免性能问题,请考虑以下事项:
空间映射数据量可能非常庞大,因此可能会在可扩展性方面带来挑战。
在房间内快速移动的物体或人可能会使空间映射数据非常不规则,因此应该尽可能避免这种情况。
数据中的空洞有时会导致问题,特别是出于设计原因需要连续数据时。这些空洞通常由透明或黑色表面引起。
请参阅 Microsoft 关于空间映射 (Spatial Mapping) 的文档以进一步了解空间映射概念。
2018–05–01 页面已发布并进行了编辑审查
在 2017.3 版中更新了 Hololens 空间映射文档
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.