示例#1
0
 private void ClearFocusedObjectIfOld()
 {
     if (!_focusedObject.IsRecentlyHit())
     {
         _focusedObject = ScoredObject.Empty();
     }
 }
示例#2
0
 public void RemoveObject(GameObject gameObject)
 {
     _scoredObjects.Remove(gameObject.GetInstanceID());
     if (_focusedObject.GameObject.GetInstanceID() == gameObject.GetInstanceID())
     {
         _focusedObject = ScoredObject.Empty();
     }
 }
示例#3
0
        public FocusedObject GetFocusedObject(IEnumerable <GazePoint> lastGazePoints, Camera camera)
        {
            var objectsInGaze = FindObjectsInGaze(lastGazePoints, camera);

            UpdateFocusConfidenceScore(objectsInGaze);
            var focusChallenger = FindFocusChallenger();

            if (focusChallenger.GetScore()
                > _focusedObject.GetScore() + Threshold)
            {
                _focusedObject = focusChallenger;
            }

            return(FocusedGameObject);
        }
示例#4
0
        public FocusedObject GetFocusedObject(IEnumerable <GazePoint> lastGazePoints, Camera camera)
        {
            var gazePoints = lastGazePoints.Where(gazePoint => gazePoint.IsWithinScreenBounds);

            foreach (var gazePoint in gazePoints)
            {
                var objectsInGaze = FindObjectsInGaze(gazePoint.Screen, camera);
                UpdateFocusConfidenceScore(objectsInGaze);
            }

            var focusChallenger = FindFocusChallenger();

            if (focusChallenger.GetScore() > _focusedObject.GetScore() + Threshold)
            {
                _focusedObject = focusChallenger;
            }

            return(FocusedGameObject);
        }
示例#5
0
        private ScoredObject FindFocusChallenger()
        {
            ScoredObject topFocusChallenger = ScoredObject.Empty();
            float        topScore           = 0.0f;

            foreach (var key in _scoredObjects.Keys)
            {
                ScoredObject scoredObject = _scoredObjects[key];

                var score = scoredObject.GetScore(Time.time - LoseGazeDwellTime, Time.time - GainGazeDwellTime);

                if (score > topScore)
                {
                    topScore           = score;
                    topFocusChallenger = scoredObject;
                }
            }

            return(topFocusChallenger);
        }
示例#6
0
        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));
                }

                ScoredObject hitObject = _scoredObjects[instanceId];
                hitObject.AddHit(Time.time, Time.deltaTime);
            }

            ClearFocusedObjectIfOld();
        }
示例#7
0
 public bool Equals(ScoredObject otherObject)
 {
     return(GameObject.GetInstanceID() == otherObject.GameObject.GetInstanceID());
 }
示例#8
0
 public void Reset()
 {
     _scoredObjects.Clear();
     _focusedObject = ScoredObject.Empty();
 }