public void Tick()
        {
            _headToCenterEyeTranslation = CoordinatesHelper.GetHeadToCenterEyeTranslation();
            _hmdToWorldTransformer.Tick();
            _localToWorldMatrix = _hmdToWorldTransformer.GetLocalToWorldMatrix();

            // Copy consumer data
            lock (_lockEyeTrackingDataLocal)
            {
                EyeTrackingDataHelper.Copy(_eyeTrackingDataLocalInternal, _eyeTrackingDataLocal);
            }
            _eyeTrackingDataLocal.Timestamp = Time.unscaledTime;

            // Shuffle data from internal queue to public queue
            lock (_lockAdvancedData)
            {
                while (_advancedInternalQueue.Count > 1)
                {
                    _advancedPublicQueue.Enqueue(_advancedInternalQueue.Dequeue());
                }

                // Copy newest data to _advancedEyeTrackingData
                if (_advancedInternalQueue.Count == 1)
                {
                    var data = _advancedInternalQueue.Dequeue();
                    EyeTrackingDataHelper.Copy(data, _advancedEyeTrackingData);
                    _advancedPublicQueue.Enqueue(data);
                }

                // Limit size of public queue
                while (_advancedPublicQueue.Count > AdvancedDataQueueSize)
                {
                    _advancedPublicQueue.Dequeue();
                }
            }
        }
Exemplo n.º 2
0
        private void OnAdvancedWearableData(ref tobii_wearable_advanced_data_t data)
        {
            var advancedData = _advancedData.Count >= AdvancedDataQueueSize
                ? _advancedData.Dequeue()
                : new TobiiXR_AdvancedEyeTrackingData();

            StreamEngineDataMapper.MapAdvancedData(advancedData, ref data,
                                                   _streamEngineTracker.ConvergenceDistanceSupported, CoordinatesHelper.GetHeadToCenterEyeTranslation());
            _advancedData.Enqueue(advancedData);

            // Keep a copy of latest received value
            EyeTrackingDataHelper.Copy(advancedData, _advancedEyeTrackingData);

            // Also fill in consumer api
            StreamEngineDataMapper.FromAdvancedData(_eyeTrackingDataLocal, ref data,
                                                    _streamEngineTracker.ConvergenceDistanceSupported, CoordinatesHelper.GetHeadToCenterEyeTranslation());
            _eyeTrackingDataLocal.Timestamp = Time.unscaledTime;
        }
Exemplo n.º 3
0
 private void OnWearableData(ref tobii_wearable_consumer_data_t data)
 {
     StreamEngineDataMapper.FromConsumerData(_eyeTrackingDataLocal, ref data,
                                             _streamEngineTracker.ConvergenceDistanceSupported, CoordinatesHelper.GetHeadToCenterEyeTranslation());
     _eyeTrackingDataLocal.Timestamp = Time.unscaledTime;
 }