【问题标题】:How can I simulate hand rays on HoloLens 1?如何在 HoloLens 1 上模拟手部光线?
【发布时间】:2019-06-19 18:03:46
【问题描述】:

我正在设置一个新项目,该项目旨在同时部署到 HoloLens 1 和 2,我想在两者中都使用手部光线,或者至少能够在 HoloLens 1 上模拟它们,为 HoloLens 2 做准备.

据我所知:

  1. 将 InputSimulationService 自定义为仅手势(以便我可以在编辑器中进行测试)
  2. 将 GGVHand 控制器类型添加到 MRTK/Pointers 部分中的 DefaultControllerPointer 选项。

这让它显示并响应编辑器和设备中的点击,但它不使用手部坐标,而是从 0,0,0 向前投射,这表明 GGV 手部控制器正在提供 GripPosition (当然由于 HL1 没有旋转)但不提供指针姿势。

我想最简洁的方法是向 GGV 手控制器添加一个指针姿势,或者向 GripPosition 添加(估计的)旋转并将其用作 ShellHandRayPointer 中的姿势动作。我无法立即看到在 MRTK 中自定义/插入的位置。

或者,我可以自定义 DefaultControllerPointer 预制件,但我很犹豫,因为 MRTK 似乎仍在频繁更改,这可能会导致升级问题。

【问题讨论】:

    标签: mrtk


    【解决方案1】:

    您可以创建一个自定义指针,将指针的旋转设置为根据手的位置进行推断,然后像您建议的那样使用 Grip Pose 而不是 Pointer Pose 进行姿势动作。

    自定义指针的代码如下所示:

    // Note you could extend ShellHandRayPointer if you wanted the beam bending, 
    // however configuring that pointer requires careful setup of asset.
    public class HL1HandRay : LinePointer
    {
        public override Quaternion Rotation  
        {
            get
            {
                // Set rotation to be line from head to head, rotated a bit
                float sign = Controller.ControllerHandedness == Handedness.Right ? -1f : 1f;
                return Quaternion.Euler(0, sign * 35, 0) * Quaternion.LookRotation(Position - CameraCache.Main.transform.position, Vector3.up);
            }
        }
    
        // We cannot use the base IsInteractionEnabled
        // Because  HL1 hands are always set to have their "IsInPointing pose" field as false
        // You may want to do more thorough checks here, following BaseControllerPointer implementation
        public override bool IsInteractionEnabled => IsFocusLocked || IsTracked;
    }
    

    然后创建一个新的指针预制件并配置您的指针配置文件以使用新的指针预制件。创建您自己的预制件而不是修改 MRTK 预制件具有确保 MRTK 更新不会覆盖您的预制件的优势。

    以下是我为测试它而制作的简单指针预制件的一些捕获,并突出显示了相关更改:

    然后是我使用的组件:

    【讨论】:

    • 谢谢!这完美地工作。基于这个例子,我还通过重写 OnInputChanged 来设置旋转,让它与抛物线/外壳指针一起工作。它在 HoloLens 1 上运行得非常好 - 我预计手部定位延迟会产生更大的影响,但这是一种非常舒适的交互方法。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-16
    • 2021-09-16
    • 1970-01-01
    • 2020-03-14
    相关资源
    最近更新 更多