【问题标题】:Transfer LeapMotion coordinates into Unity coordinates将 LeapMotion 坐标转换为 Unity 坐标
【发布时间】:2019-10-21 20:45:12
【问题描述】:

我正在使用 Unity 和 LeapMotionController。对于我的项目,我想在我的手掌上显示一个对象。

我认为它会以这样的方式工作(参见代码部分)。但是坐标却很不一样……

在 LeapMotion V2 中,SDK 中有一种方法可以转换此坐标。但是在 4.4 中不再有这样的东西了

  • 试图以这种方式缩放这些坐标,但这不是我想要的结果
...

void Update()
{
    Frame frame = controller.Frame ();
    for (int h = 0; h < frame.Hands.Count; h++) {
       Hand leapHand = frame.Hands [h];
       Vector3 handPostition = new Vector3(leapHand.PalmPosition.x, leapHand.PalmPosition.y, leapHand.PalmPosition.z)  
    }
}

...

我需要手掌的精确坐标来显示相对于手掌的 3D 对象。

【问题讨论】:

    标签: c# unity3d coordinates leap-motion


    【解决方案1】:

    获取手掌位置的最简单方法是使用leapHand 上的ToVector3() 函数。

    Vector3 handPostition = leapHand.PalmPosition.ToVector3();
    

    如果您也在寻找轮换,请致电

    Quaternion handRotation = leapHand.Rotation.ToQuaternion();
    

    如果您正在寻找一种方法来一次完成所有这些操作,请致电

    Leap.Unity.Pose pose = leapHand.GetPalmPose();
    Vector3 handPosition = pose.position;
    Quaternion handRotation = pose.rotation;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-05-25
      • 1970-01-01
      • 1970-01-01
      • 2020-08-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多