如何改变纸板VR的角移速度

时间:2016-06-21 13:42:35

标签: c# unity3d google-cardboard virtual-reality

我想在Unity上的Google纸板实现中更改角度移动速度。这意味着,如果我旋转40度,渲染的视图最终会转动45度(或35度,具体取决于我可以指定的因素)。

我相信我在这里玩var rot。任何人都可以帮我弄清楚如何在这里操纵四元数读数 - 比如对于每个Euler 1度头部旋转,渲染最终旋转1.25度?

// Compute new head pose.
private void UpdateHead() {
    if (updated) {  // Only one update per frame, please.
      return;
    }
    updated = true;
    GvrViewer.Instance.UpdateState();

    if (trackRotation) {
      var rot = GvrViewer.Instance.HeadPose.Orientation ;
      if (target == null) {
        transform.localRotation = rot;
      } else {
        transform.rotation = target.rotation * rot;
      }
    }

    if (trackPosition) {
      Vector3 pos = GvrViewer.Instance.HeadPose.Position;
      if (target == null) {
        transform.localPosition = pos;
      } else {
        transform.position = target.position + target.rotation * pos;
      }
    }

    if (OnHeadUpdated != null) {
      OnHeadUpdated(gameObject);
    }
  }
}

1 个答案:

答案 0 :(得分:0)

我想7个月之后你可能不再需要这个了。 我会说这应该有效。

private void UpdateHead() {
    if (updated) {  // Only one update per frame, please.
      return;
    }
    updated = true;
    GvrViewer.Instance.UpdateState();

    if (trackRotation) {
      var rot = GvrViewer.Instance.HeadPose.Orientation ;


      var rotx = rot.x;
      var roty = rot.y;
      var rotz = rot.z;
      var rotFinal = Quaternion.Euler(rotx*1.15f, roty*1.15f, rotz*1.15f);


      if (target == null) {
        transform.localRotation = rotFinal;
      } else {
        transform.rotation = target.rotation * rotFinal;
      }
    }

    if (trackPosition) {
      Vector3 pos = GvrViewer.Instance.HeadPose.Position;
      if (target == null) {
        transform.localPosition = pos;
      } else {
        transform.position = target.position + target.rotation * pos;
      }
    }

    if (OnHeadUpdated != null) {
      OnHeadUpdated(gameObject);
    }