public static extern NpHmdResult NpHmd_MeasurementUpdate(IntPtr hmdHandle, ref NpHmdQuaternion opticalOrientation, ref NpHmdQuaternion inertialOrientation, float deltaTimeSec);
public static extern NpHmdResult NpHmd_GetOrientationCorrection(IntPtr hmdHandle, out NpHmdQuaternion correction);
void UpdatePose() { OptitrackRigidBodyState rbState = StreamingClient.GetLatestRigidBodyState(RigidBodyId); if (rbState != null && rbState.DeliveryTimestamp.AgeSeconds < 1.0f) { this.transform.localPosition = rbState.Pose.Position; if (m_nphmdHandle != IntPtr.Zero && m_deviceInitialized) { NpHmdQuaternion inertialOri = new NpHmdQuaternion(m_hmdCameraObject.transform.localRotation); NpHmdQuaternion opticalOri; switch (RigidBodyOrientation) { case OptitrackHmdRbOrientation.NegativeZForward: opticalOri = new NpHmdQuaternion(rbState.Pose.Orientation * Quaternion.Euler(0.0f, 180.0f, 0.0f)); break; case OptitrackHmdRbOrientation.PositiveZForward: opticalOri = new NpHmdQuaternion(rbState.Pose.Orientation); break; case OptitrackHmdRbOrientation.PositiveXForward: opticalOri = new NpHmdQuaternion(rbState.Pose.Orientation * Quaternion.Euler(0.0f, -90.0f, 0.0f)); break; default: return; } NpHmdResult result = NativeMethods.NpHmd_MeasurementUpdate( m_nphmdHandle, ref opticalOri, // const ref inertialOri, // const Time.deltaTime ); if (result == NpHmdResult.OK) { NpHmdQuaternion newCorrection; result = NativeMethods.NpHmd_GetOrientationCorrection(m_nphmdHandle, out newCorrection); if (result == NpHmdResult.OK) { this.transform.localRotation = newCorrection; } else { Debug.LogError(GetType().FullName + ": NpHmd_GetOrientationCorrection failed.", this); this.enabled = false; return; } } else { Debug.LogError(GetType().FullName + ": NpHmd_MeasurementUpdate failed.", this); this.enabled = false; return; } } } }