예제 #1
0
        //--------------------------------------------------------------------
        // MonoBehaviour Messages
        //--------------------------------------------------------------------

        private void Awake()
        {
#if UNITY_EDITOR
            _gameViewBoundsProvider = CreateEditorScreenHelper();
#else
            _gameViewBoundsProvider = new UnityPlayerGameViewBoundsProvider();
#endif
            _gazeFocus = new GazeFocus();

            _gazePointDataProvider = new GazePointDataProvider(this);
            _headPoseDataProvider  = new HeadPoseDataProvider();
        }
        private void UpdateFocusConfidenceScore(
            IEnumerable <GameObject> objectsInGaze)
        {
            foreach (var objectInGaze in objectsInGaze)
            {
                var instanceId = objectInGaze.GetInstanceID();
                if (!_scoredObjects.ContainsKey(instanceId))
                {
                    if (!GazeFocus.IsFocusableObject(objectInGaze))
                    {
                        continue;
                    }

                    _scoredObjects.Add(objectInGaze.GetInstanceID(),
                                       new ScoredObject(objectInGaze, GainGazeDwellTime,
                                                        LoseGazeDwellTime));
                }

                var hitObject = _scoredObjects[instanceId];
                hitObject.AddHit(Time.unscaledTime, Time.unscaledDeltaTime);
            }

            ClearFocusedObjectIfOld();
        }
예제 #3
0
        public FocusedObject GetFocusedObject(
            IEnumerable <global::Tobii.Framework.GazePoint> lastGazePoints, Camera camera)
        {
            var gazePoint = lastGazePoints.Last();

            if (!gazePoint.IsValid)
            {
                return(FocusedObject.Invalid);
            }

            GameObject focusedObject = null;
            RaycastHit hitInfo;

            if (HitTestFromPoint.FindObjectInWorld(out hitInfo,
                                                   gazePoint.Screen, camera, MaximumDistance, LayerMask))
            {
                if (GazeFocus.IsFocusableObject(hitInfo.collider.gameObject))
                {
                    focusedObject = hitInfo.collider.gameObject;
                }
            }

            return(new FocusedObject(focusedObject));
        }