示例#1
0
        private void OnGazePoint(Tobii.GameIntegration.Net.GazePoint gazePoint)
        {
            long  eyetrackerCurrentUs    = gazePoint.TimeStampMicroSeconds;         // TODO awaiting new API from tgi;
            float timeStampUnityUnscaled = Time.unscaledTime - ((eyetrackerCurrentUs - gazePoint.TimeStampMicroSeconds) / 1000000f);

            var bounds = _tobiiHost.GameViewInfo.NormalizedClientAreaBounds;

            if (float.IsNaN(bounds.x) ||
                float.IsNaN(bounds.y) ||
                float.IsNaN(bounds.width) ||
                float.IsNaN(bounds.height) ||
                bounds.width < float.Epsilon ||
                bounds.height < float.Epsilon)
            {
                return;
            }

            var x = (0.5f + gazePoint.X * 0.5f - bounds.x) / bounds.width;
            var y = (0.5f + gazePoint.Y * 0.5f - (1 - bounds.height - bounds.y)) / bounds.height;

            Last = new GazePoint(new Vector2(x, y), timeStampUnityUnscaled, gazePoint.TimeStampMicroSeconds);
        }