Unity Hololens 光标跟随用户视线偏离中心?



我本质上是尝试使用自己的代码来完成 BasicCursor 及其相应的脚本 Cursor.cs 使用 Microsoft 工具包对注视跟踪所做的工作。我相信它的 UpdateCursorTransform(( 方法是我试图模拟的,但我很困惑。

目前,我的光标跟随用户的目光,但它似乎偏离了中心。光标位于用户实际凝视位置的下方和左侧。什么给?

这是我的代码。

// Do a raycast into the world based on the user's
// head position and orientation.
var headPosition = Camera.main.transform.position;
var gazeDirection = Camera.main.transform.forward;
RaycastHit hitInfo;
Ray ray;
Camera c = Camera.main;
ray = c.ScreenPointToRay(headPosition);
if (Physics.Raycast(headPosition, gazeDirection, out hitInfo))
{

// If the raycast hit a hologram...
objHit = hitInfo.transform;
// Move the cursor to the point where the raycast hit.
this.transform.position = hitInfo.point;
// Rotate the cursor to hug the surface of the hologram.
this.transform.rotation = Quaternion.FromToRotation(Vector3.up, hitInfo.normal);
}

Unity 单位应该是 1 米。

请注意,如果你的Hololens相机的视野非常宽或非常窄,这将人为地影响你所看到的(事情看起来会更近/更远(。 在我正在从事的一个项目中,我的同事将全息影像的对象放在距离相机 500 个单位的地方,然后将 FOV 设置为 10,这使得它们不会坐在现实世界墙壁和地板所在的空间中。 如果你试图绕过这个物体,你就做不到。

将视野设置为 60 度以获得最佳体验,我相信预制全息镜头相机的视野为 51。

我不确定为什么尝试从米转换为英寸会给你一个 10 次方的值(应该是 ~39.37 的乘数(

最新更新