【发布时间】:2017-07-21 18:46:02
【问题描述】:
我实际上是在尝试使用我自己的代码来完成 BasicCursor 及其对应的脚本 Cursor.cs 使用 Microsoft Toolkit 进行凝视跟踪的功能。我相信它的 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);
}
【问题讨论】:
-
如果射线没有击中某物(即凝视太空),你会怎么做?
-
嗯
ray.direction是一个.... direction 你可能不想将它设置为一个 position...跨度> -
headPosition + gazeDirection * some_distance -
统一单位应该是 1 米。请注意,如果您的全息相机的视野非常宽或非常窄,则会人为地影响您所看到的(事物看起来更近/更远)。将视野设置为 60 度以获得最佳体验。
-
很快发布答案。至于使用设备,我有!它现在在我的办公桌抽屉里。不能等到技术变得更小、更轻、更强大、更大的全息视图区域。尝试使用
NavigationRails_如果不起作用,请检查哪个轴的值较大(不要忘记Abs()是)并将另一个值设置为零。