// Compute new head pose. private void UpdateHead() { if (updated) { // Only one update per frame, please. return; } updated = true; GvrViewer.Instance.UpdateState(); if (trackRotation) { orientation = GvrViewer.Instance.HeadPose.Orientation; if (target == null) { transform.localRotation = orientation; } else { transform.rotation = target.rotation * orientation; } } if (trackPosition) { //Vector3 pos = GvrViewer.Instance.HeadPose.Position; Vector3 pos = GvrControllerInput.GetPosition(SvrControllerState.NoloHead); //#if NOLOSDK // pos = NoloVR_Controller.GetDevice(NoloDeviceType.Hmd).GetPose().pos; //#endif if (target == null) { transform.localPosition = pos; } else { transform.position = target.position + target.rotation * pos; } } else { transform.localPosition = Vector3.zero; } if (OnHeadUpdated != null) { OnHeadUpdated(gameObject); } }
void UpdatePose() { var pose = GvrControllerInput.GetPosition(deviceType); var roation = GvrControllerInput.GetOrientation(deviceType); if (!GvrHead.TrackPosition) { Vector3 headPos = GvrControllerInput.GetPosition(SvrControllerState.NoloHead); transform.localPosition = pose + new Vector3(-headPos.x, -headPos.y, -headPos.z); } else { transform.localPosition = pose; } transform.localRotation = roation; }
// Compute new head pose. private void UpdateHead() { if (updated) { // Only one update per frame, please. return; } updated = true; //if (m_Recentering) //{ // if (!readCount) // { // GvrViewer.Instance.UpdateState(); // m_TargetRotation = GvrViewer.Instance.HeadPose.Orientation; // readCount = true; // } // else // { // GvrViewer.Instance.UpdateState(); // } // m_PreviousRotation = Quaternion.Lerp(m_TargetRotation, m_PreviousRotation, Time.deltaTime * 50.0f); // if (target == null) // { // transform.localRotation = m_PreviousRotation; // } // else // { // transform.rotation = target.rotation * m_PreviousRotation; // } // if (m_PreviousRotation == m_TargetRotation) // { // m_Recentering = false; // trackRotation = true; // } //} //else //{ // GvrViewer.Instance.UpdateState(); //} //if (GvrControllerInput.Recentered) //{ // //mYaw = 0; // m_PreviousRotation = GvrViewer.Instance.HeadPose.Orientation; // GvrViewer.Instance.Recenter(); // m_Recentering = true; // trackRotation = false; //} GvrViewer.Instance.UpdateState(); if (trackRotation) { orientation = GvrViewer.Instance.HeadPose.Orientation; if (target == null) { transform.localRotation = orientation; } else { transform.rotation = target.rotation * orientation; } } if (trackPosition) { //Vector3 pos = GvrViewer.Instance.HeadPose.Position; Vector3 pos = GvrControllerInput.GetPosition(SvrControllerState.NoloHead); //#if NOLOSDK // pos = NoloVR_Controller.GetDevice(NoloDeviceType.Hmd).GetPose().pos; //#endif if (target == null) { transform.localPosition = pos; } else { transform.position = target.position + target.rotation * pos; } } else { transform.localPosition = Vector3.zero; } if (OnHeadUpdated != null) { OnHeadUpdated(gameObject); } }