Ejemplo n.º 1
0
        public bool GetHeadPose(ref Pose pose, UInt64 timestamp = 0, UInt64 predict = 0)
        {
            UInt64 headPoseHandle = 0;
            UInt64 hmd_nanos      = 0;

            NativeApi.NRTrackingGetHMDTimeNanos(m_NativeInterface.TrackingHandle, ref hmd_nanos);
            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);

            NativeMat4f headpos_native = new NativeMat4f(Matrix4x4.identity);
            var         getPoseResult  = NativeApi.NRTrackingPoseGetPose(m_NativeInterface.TrackingHandle, headPoseHandle, ref headpos_native);

            ConversionUtility.ApiPoseToUnityPose(headpos_native, out pose);
            NativeApi.NRTrackingPoseDestroy(m_NativeInterface.TrackingHandle, headPoseHandle);
            return((acquireTrackingPoseResult == NativeResult.Success) && (getPoseResult == NativeResult.Success));
        }
Ejemplo n.º 2
0
        public Pose GetCenterPose(UInt64 trackble_handle)
        {
            Pose        pose = Pose.identity;
            NativeMat4f center_native_pos = NativeMat4f.identity;

            NativeApi.NRTrackablePlaneGetCenterPose(m_NativeInterface.TrackingHandle, trackble_handle, ref center_native_pos);
            ConversionUtility.ApiPoseToUnityPose(center_native_pos, out pose);
            return(pose);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        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);
        }