【问题标题】:Oculus Hand Tracking: Getting the correct velocity of the hand?Oculus 手部追踪:获得正确的手部速度?
【发布时间】:2020-07-06 04:11:30
【问题描述】:

编辑:在进行了更多调试之后。由于某种原因,速度矢量似乎读数为零(对于这两种方法)。有什么建议吗?

我正在尝试在 Unity 中为 Oculus Quest 制作一个简单的手部追踪演示。我成功地实现了一个抓取和释放机制,类似于本教程here。 Oculus 插件的状态有点过时,但整体逻辑保持不变。

我遇到的唯一问题是实现 Drop 功能。当我放下一个物体时,我想将我手的线速度和角速度添加到物体上。我尝试通过以下方式做到这一点:

抓取脚本:

protected override void GrabEnd()
{
    if (m_grabbedObj)
    {
        Debug.Log("Grabbed object found");
        Rigidbody rigid = GetComponent<Rigidbody>();
        if (rigid)
        {
            GrabbableRelease(rigid.velocity, rigid.angularVelocity);
        }
        else
        {
            Vector3 linearVelocity = (transform.position - lastPointerPos) / Time.fixedDeltaTime;
            Vector3 angularVelocity = (transform.eulerAngles - lastPointerRot.eulerAngles) / Time.fixedDeltaTime;

            GrabbableRelease(linearVelocity, angularVelocity);
        }
    }

    GrabVolumeEnable(true);
}

在 Grabbable 内部:

virtual public void GrabEnd(Vector3 linearVelocity, Vector3 angularVelocity)
{
    Rigidbody rb = gameObject.GetComponent<Rigidbody>();

    rb.velocity = linearVelocity;
    rb.angularVelocity = angularVelocity;
}

在这两者之间还有一个函数,但本质上它只是在传递速度的对象上调用 GrabEnd。

我还确保抓取器(手)和可抓取物体上都有刚体。

lastPointerPos & lastPointerRot 是在 FixedUpdate 结束时保存的 Vector3。我还在检查是否需要根据食指的 PinchStrength 和 Confidence 在 FixedUpdate 内调用 GrabEnd。

我有两种方法的原因只是因为我尝试了两种不同的方法来解决这个问题。两者似乎都不起作用。不管我在客厅里如何像傻瓜一样挥舞双臂,物体都会直接掉到地板上,哈哈

任何帮助将不胜感激!

【问题讨论】:

  • 试试 Oculus 原生功能Vector3 velocity = OVRInput.GetLocalControllerVelocity(controller)。另见their docs。您可能想通过velocity = rig.TransformDirection(velocity); 将其绝对化。此外,angularVelocity 也有类似的功能。
  • 您的链接似乎已损坏,但在该函数的 cmets 中,它表示仅适用于 Touch 控制器,因此我只能弄清楚如何在没有该函数的情况下计算它。
  • 链接有效,但它很不稳定——我有时不得不重新加载。 Gotcha on the Hand vs Controller!
  • 我能够从transform.parent 计算出一个非常不稳定的速度,但是它似乎并不完全准确并且尺寸很小

标签: unity3d oculusquest


【解决方案1】:

Oculus sdk 将来应该支持 OVRInput.GetLocalControllerVelocity((OVRInput.Controller.RTouch)) 返回手的速度。目前他们没有。

一个简单的解决方案可能是这样的:

public GameObject RightHandAnchor;
private Vector3 lastPosition;

private void FixedUpdate()
{   
    float speed = Vector3.Distance( lastPosition, RightHandAnchor.transform.position) / Time.deltaTime;
    //update previous positions
    lastPosition = middlePositionVelocity;              
    Debug.log("Speed: " + String.Format("{0:0.00}", speed);

}

`

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-05-27
    • 1970-01-01
    • 1970-01-01
    • 2014-02-26
    • 1970-01-01
    • 2020-06-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多