Ejemplo n.º 1
0
        protected override void OnUpdate()
        {
            // Save the current pose for the current time.
            _eyeTrackerOriginPoses.Add(_eyeTrackerOrigin.GetPose(EyeTrackingOperations.GetSystemTimeStamp()));

            base.OnUpdate();
        }
Ejemplo n.º 2
0
        protected override void OnUpdate()
        {
#if !USE_OPENVR_BINDINGS
            // Save the current pose for the current time adding estimated pose prediction time offset.
            _eyeTrackerOriginPoses.Add(_eyeTrackerOrigin.GetPose(EyeTrackingOperations.GetSystemTimeStamp() + Mathf.RoundToInt(_hmdPosePredictionOffset * 1000f)));
#endif
            base.OnUpdate();
        }
Ejemplo n.º 3
0
        private void Update()
        {
            // Save the current pose for the current time.
            _eyeTrackerOriginPoses.Add(_eyeTrackerOrigin.GetPose(EyeTrackingOperations.GetSystemTimeStamp()));

            // Check for state transitions to or from subscribing.
            UpdateSubscriptions();

            if (_subscribeToGaze)
            {
                ProcessGazeEvents();
            }
        }
Ejemplo n.º 4
0
        protected override void ProcessGazeEvents()
        {
            const int maxIterations = 20;

            var gazeData = _latestGazeData;

            for (int i = 0; i < maxIterations; i++)
            {
                var originalGaze = _originalGazeData.Next;

                // Queue empty
                if (originalGaze == null)
                {
                    break;
                }

#if USE_OPENVR_BINDINGS
                var now        = EyeTrackingOperations.GetSystemTimeStamp();
                var backInTime = (originalGaze.SystemTimeStamp - now) / 1000000.0f;

                // Look up OpenVR pose back when the eyetracker looked at the eyes.
                OpenVR.System.GetDeviceToAbsoluteTrackingPose(OpenVR.Compositor.GetTrackingSpace(), backInTime, poseArray);
                if (!poseArray[OpenVR.k_unTrackedDeviceIndex_Hmd].bPoseIsValid)
                {
                    Debug.Log("Failed to get historical pose");
                    continue;
                }

                var bestMatchingPose = HMDPoseToETPose(poseArray[OpenVR.k_unTrackedDeviceIndex_Hmd].mDeviceToAbsoluteTracking, now);
#else
                var bestMatchingPose = _eyeTrackerOriginPoses.GetBestMatchingPose(originalGaze.SystemTimeStamp);
                if (!bestMatchingPose.Valid)
                {
                    Debug.Log("Did not find a matching pose");
                    continue;
                }
#endif

                gazeData            = new VRGazeData(originalGaze, bestMatchingPose);
                _gazeDataQueue.Next = gazeData;
            }

            var queueCount = UnprocessedGazeDataCount;
            if (queueCount > 0)
            {
                Debug.LogWarning("We didn't manage to empty the queue: " + queueCount + " items left...");
            }

            _latestGazeData = gazeData;
        }