Beispiel #1
0
        private void NewGazePoint(object sender, GazePointEventArgs gazePointEventArgs)
        {
            const double screenExtensionFactor = 0;
            var          screenExtensionX      = _host.ScreenBounds.Value.Width * screenExtensionFactor;
            var          screenExtensionY      = _host.ScreenBounds.Value.Height * screenExtensionFactor;

            var gazePointX = gazePointEventArgs.X + screenExtensionX / 2;
            var gazePointY = gazePointEventArgs.Y + screenExtensionY / 2;

            var screenWidth  = _host.ScreenBounds.Value.Width + screenExtensionX;
            var screenHeight = _host.ScreenBounds.Value.Height + screenExtensionY;

            if (screenHeight > 0)
            {
                _aspectRatio = screenWidth / screenHeight;
            }

            var normalizedGazePointX = (float)Math.Min(Math.Max((gazePointX / screenWidth), 0.0), 1.0);
            var normalizedGazePointY = (float)Math.Min(Math.Max((gazePointY / screenHeight), 0.0), 1.0);

            var normalizedCenterDeltaX = (normalizedGazePointX - 0.5f) * 2.0f;
            var normalizedCenterDeltaY = (normalizedGazePointY - 0.5f) * 2.0f;

            if (float.IsNaN(normalizedCenterDeltaX) || float.IsNaN(normalizedCenterDeltaY))
            {
                return;
            }

            _lastNormalizedCenterDelta = new Vector2(normalizedCenterDeltaX, normalizedCenterDeltaY);
            _debugGazeVisualization.Move(_lastNormalizedCenterDelta);
            _lastGazeTime = DateTime.UtcNow;
        }
Beispiel #2
0
        public void MoveCrosshair(Vector2 screenCoords)
        {
            var uiWidth  = UI.WIDTH;
            var uiHeight = UI.HEIGHT;

            var         crosshairPosition = new Vector2(uiWidth * 0.5f + screenCoords.X * uiWidth * 0.5f, uiHeight * 0.5f + screenCoords.Y * uiHeight * 0.5f);
            const float w = 1;            //Filtering is done earlier 0.6f;

            _crosshairPosition = new Vector2(_crosshairPosition.X + (crosshairPosition.X - _crosshairPosition.X) * w,
                                             _crosshairPosition.Y + (crosshairPosition.Y - _crosshairPosition.Y) * w);

            _dotCrosshair.Move(_crosshairPosition);
            _missileLockCrosshair.Move(_crosshairPosition);
        }