简体   繁体   English

如何获得从对象到空间映射的距离

[英]How to get distance from object to spatial mapping

I'm working with Unity 2017.4, the HoloToolKit 2017.4.3, Vuforia and the Hololens.我正在使用 Unity 2017.4、HoloToolKit 2017.4.3、Vuforia 和 Hololens。 How can I calculate the distance of a virtual object to the spatial mapping of the Hololens?如何计算虚拟对象到 Hololens 空间映射的距离? I only need the distance in the Z coordinate, like in "how many meters above the floor is my object".我只需要 Z 坐标中的距离,例如“我的物体离地面多少米”。

As u didnt provide much information, here my first idea.由于你没有提供太多信息,这里是我的第一个想法。 Raycast from the object down to ground/ceiling and take the distance.从物体向下投射到地面/天花板并测量距离。

     RaycastHit hit = new RaycastHit();
     if (Physics.Raycast (transform.position, -Vector3.up, out hit)) {
         var distanceToGround = hit.distance;
     }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 Hololens 2 在空间映射网格上生成一个对象 - Spawn an object on Spatial Mapping Mesh with Hololens 2 从对象类型System.Data.Spatial.DbGeography到已知的托管提供程序本机类型不存在映射 - No mapping exists from object type System.Data.Spatial.DbGeography to a known managed provider native type 异常:不存在从对象类型System.Data.Spatial.DbGeography到已知托管提供程序本机类型的映射 - Exception : No mapping exists from object type System.Data.Spatial.DbGeography to a known managed provider native type 如何设置相机与缩放对象的距离? - How to set the distance of the camera from a scaling object? 如何从谷歌,每个国家获得距离 - how to get the distance from google, per country Hololens空间映射问题 - Hololens Spatial mapping issue 空间映射在设备上不起作用 - Spatial Mapping not working on device 如何获取列表中每个游戏对象的距离,碰撞和方向? - How to get the Distance, Collision and Direction for each game object in my list? 使用 distance() 方法进行空间 Linq 查询 - Spatial Linq query with distance() method 如何从 EF Core 的 FromSqlRaw 获取空间值 - How do I get a spatial value from EF Core's FromSqlRaw
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM