public Pose GetAnchorPose(UInt64 anchor_handle) { NativeMat4f nativePose = NativeMat4f.identity; NativeApi.NRAnchorGetPose(m_NativeInterface.TrackingHandle, anchor_handle, ref nativePose); Pose unitypose; ConversionUtility.ApiPoseToUnityPose(nativePose, out unitypose); return(unitypose); }
public Pose GetPose(int controllerIndex) { Pose controllerPos = Pose.identity; NativeMat4f mat4f = new NativeMat4f(Matrix4x4.identity); NativeResult result = NativeApi.NRControllerStateGetPose(m_StateHandles[controllerIndex], ref mat4f); if (result == NativeResult.Success) { ConversionUtility.ApiPoseToUnityPose(mat4f, out controllerPos); } return(controllerPos); }
public Pose GetEyePoseFromHead(NativeEye eye) { Pose outEyePoseFromHead = Pose.identity; NativeMat4f mat4f = new NativeMat4f(Matrix4x4.identity); NativeResult result = NativeApi.NRHMDGetEyePoseFromHead(m_HmdHandle, (int)eye, ref mat4f); if (result == NativeResult.Success) { ConversionUtility.ApiPoseToUnityPose(mat4f, out outEyePoseFromHead); } return(outEyePoseFromHead); }
public UInt64 AddAnchor(Pose pose) { Debug.Log("Start to add anchor..."); UInt64 anchorHandle = 0; NativeMat4f nativePose; ConversionUtility.UnityPoseToApiPose(pose, out nativePose); var result = NativeApi.NRTrackingAcquireNewAnchor(m_NativeInterface.TrackingHandle, nativePose, ref anchorHandle); Debug.Log("End to add anchor :" + result); return(anchorHandle); }
public bool GetProjectionMatrix(ref EyeProjectMatrixData outEyesProjectionMatrix, float znear, float zfar) { NativeFov4f fov = new NativeFov4f(); NativeResult result_left = NativeApi.NRHMDGetEyeFov(m_HmdHandle, (int)NativeEye.LEFT, ref fov); outEyesProjectionMatrix.LEyeMatrix = ConversionUtility.GetProjectionMatrixFromFov(fov, znear, zfar).ToUnityMat4f(); NativeResult result_right = NativeApi.NRHMDGetEyeFov(m_HmdHandle, (int)NativeEye.RIGHT, ref fov); outEyesProjectionMatrix.REyeMatrix = ConversionUtility.GetProjectionMatrixFromFov(fov, znear, zfar).ToUnityMat4f(); NativeResult result_RGB = NativeApi.NRHMDGetEyeFov(m_HmdHandle, (int)NativeEye.RGB, ref fov); outEyesProjectionMatrix.RGBEyeMatrix = ConversionUtility.GetProjectionMatrixFromFov(fov, znear, zfar).ToUnityMat4f(); return(result_left == NativeResult.Success && result_right == NativeResult.Success && result_RGB == NativeResult.Success); }
public NativeResult GetEyePose(ref Pose outLeftEyePose, ref Pose outRightEyePose) { NativeMat4f lefteyepos = new NativeMat4f(Matrix4x4.identity); NativeMat4f righteyepos = new NativeMat4f(Matrix4x4.identity); NativeResult result = NativeApi.NRHeadTrackingGetEyePose(m_NativeInterface.TrackingHandle, headTrackingHandle, ref lefteyepos, ref righteyepos); if (result == NativeResult.Success) { ConversionUtility.ApiPoseToUnityPose(lefteyepos, out outLeftEyePose); ConversionUtility.ApiPoseToUnityPose(righteyepos, out outRightEyePose); } NRDebugger.Log("[NativeHeadTracking] GetEyePose :" + result); return(result); }
public bool GetHeadPose(ref Pose pose, UInt64 timestamp = 0, UInt64 predict = 0) { if (headTrackingHandle == 0) { pose = Pose.identity; return(false); } UInt64 headPoseHandle = 0; UInt64 hmd_nanos = 0; var result = NativeApi.NRTrackingGetHMDTimeNanos(m_NativeInterface.TrackingHandle, ref hmd_nanos); if (result != NativeResult.Success) { return(false); } if (timestamp != 0) { hmd_nanos = timestamp; } else if (predict != 0) { hmd_nanos -= predict; } else { UInt64 predict_time = 0; NativeApi.NRHeadTrackingGetRecommendPredictTime(m_NativeInterface.TrackingHandle, headTrackingHandle, ref predict_time); hmd_nanos += predict_time; } var acquireTrackingPoseResult = NativeApi.NRHeadTrackingAcquireTrackingPose(m_NativeInterface.TrackingHandle, headTrackingHandle, hmd_nanos, ref headPoseHandle); if (acquireTrackingPoseResult != NativeResult.Success) { return(false); } NativeMat4f headpos_native = new NativeMat4f(Matrix4x4.identity); var getPoseResult = NativeApi.NRTrackingPoseGetPose(m_NativeInterface.TrackingHandle, headPoseHandle, ref headpos_native); if (getPoseResult != NativeResult.Success) { return(false); } ConversionUtility.ApiPoseToUnityPose(headpos_native, out pose); NativeApi.NRTrackingPoseDestroy(m_NativeInterface.TrackingHandle, headPoseHandle); return((acquireTrackingPoseResult == NativeResult.Success) && (getPoseResult == NativeResult.Success)); }
public Pose GetHeadPose() { UInt64 headPoseHandle = 0; UInt64 hmd_nanos = 0; var result = NativeApi.NRTrackingGetHMDTimeNanos(m_NativeInterface.TrackingHandle, ref hmd_nanos); UInt64 predict_time = 0; NativeApi.NRHeadTrackingGetRecommendPredictTime(m_NativeInterface.TrackingHandle, headTrackingHandle, ref predict_time); hmd_nanos += predict_time; result = NativeApi.NRHeadTrackingAcquireTrackingPose(m_NativeInterface.TrackingHandle, headTrackingHandle, hmd_nanos, ref headPoseHandle); //NRDebug.Log("[NativeHeadTracking Create :]" + m_NativeInterface.TrackingHandle + " head tracking handle:" + headTrackingHandle.ToString()); NativeMat4f headpos_native = new NativeMat4f(Matrix4x4.identity); result = NativeApi.NRTrackingPoseGetPose(m_NativeInterface.TrackingHandle, headPoseHandle, ref headpos_native); Pose head_pose = Pose.identity; if (result == NativeResult.Success) { ConversionUtility.ApiPoseToUnityPose(headpos_native, out head_pose); } NativeApi.NRTrackingPoseDestroy(m_NativeInterface.TrackingHandle, headPoseHandle); return(head_pose); }