private void ClearFocusedObjectIfOld() { if (!_focusedObject.IsRecentlyHit()) { _focusedObject = ScoredObject.Empty(); } }
public void RemoveObject(GameObject gameObject) { _scoredObjects.Remove(gameObject.GetInstanceID()); if (_focusedObject.GameObject.GetInstanceID() == gameObject.GetInstanceID()) { _focusedObject = ScoredObject.Empty(); } }
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); }
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); }
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); }
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(); }
public bool Equals(ScoredObject otherObject) { return(GameObject.GetInstanceID() == otherObject.GameObject.GetInstanceID()); }
public void Reset() { _scoredObjects.Clear(); _focusedObject = ScoredObject.Empty(); }