[英]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.