public GazeDelta Next(GazeData data) { if (data == null) { return(null); } var result = new GazeDelta { IsFixated = data.IsFixated, TimeStamp = data.TimeStamp, Presence = (data.State & GazeData.STATE_TRACKING_PRESENCE) != 0, Gaze = (data.State & GazeData.STATE_TRACKING_PRESENCE) != 0, Failed = (data.State & GazeData.STATE_TRACKING_FAIL) != 0, LostTracking = (data.State & GazeData.STATE_TRACKING_LOST) != 0, Eyes = (data.State & GazeData.STATE_TRACKING_EYES) != 0, LeftEye = data.LeftEye, RightEye = data.RightEye, RawCoordinates = data.RawCoordinates, SmoothedCoordinates = data.SmoothedCoordinates, Head = data.HeadPosition(), IsUsable = true, Last = this }; Last = null; return(result); }
public void OnGazeUpdate(GazeData gazeData) { var isValid = ((gazeData.State & GazeData.STATE_TRACKING_GAZE) != 0) && ((gazeData.State & GazeData.STATE_TRACKING_PRESENCE) != 0) && ((gazeData.State & GazeData.STATE_TRACKING_EYES) != 0) && ((gazeData.State & GazeData.STATE_TRACKING_FAIL) == 0) && ((gazeData.State & GazeData.STATE_TRACKING_LOST) == 0) && gazeData.SmoothedCoordinates != null && gazeData.SmoothedCoordinates.X != 0 && gazeData.SmoothedCoordinates.Y != 0 ; if (!isValid) { return; } var headPosition = gazeData.HeadPosition(); if (headPosition == null) { return; } //Now that we can suppose the data is probably valid we can make use of it. var cursorPoint = GetCursorPosition(); var gazePoint = gazeData.SmoothedCoordinates; ZCurrent = headPosition.Z; YGaze = gazePoint.Y; YMouse = cursorPoint.Y; }