示例#1
0
文件: InputUpdate.cs 项目: edg3/Rock
 public void Update(GameTime gameTime, InputService input)
 {
     input.Mouse.Update(gameTime);
     input.Keyboard.Update(gameTime);
     input.GamePad.Update(gameTime);
 }
示例#2
0
文件: GameScreen.cs 项目: edg3/Rock
 public virtual void Update(GameTime gameTime, InputService input)
 {
 }
        public Action <AuthorizationState> PrepareChallenge(Target target, AuthorizeChallenge challenge, string identifier, Options options, InputService input)
        {
            var httpChallenge = challenge.Challenge as HttpChallenge;

            CreateAuthorizationFile(target, httpChallenge);
            BeforeAuthorize(target, httpChallenge);

            _log.Information("Answer should now be browsable at {answerUri}", httpChallenge.FileUrl);
            if (options.Test && !options.Renew)
            {
                if (input.PromptYesNo("Try in default browser?"))
                {
                    Process.Start(httpChallenge.FileUrl);
                    input.Wait();
                }
            }
            if (options.Warmup)
            {
                _log.Information("Waiting for site to warmup...");
                WarmupSite(new Uri(httpChallenge.FileUrl));
            }

            return(authzState => Cleanup(target, httpChallenge));
        }
示例#4
0
        public void Input(InputService inputService)
        {
            this.TargetVelocity = JVector.Zero;
            this.TryJump = false;

            if (inputService.Repeated.Contains(Keys.W))
            {
                this.TargetVelocity += JVector.Forward;
            }

            if (inputService.Repeated.Contains(Keys.A))
            {
                this.TargetVelocity += JVector.Right;
            }

            if (inputService.Repeated.Contains(Keys.S))
            {
                this.TargetVelocity += JVector.Backward;
            }

            if (inputService.Repeated.Contains(Keys.D))
            {
                this.TargetVelocity += JVector.Left;
            }

            if (this.TargetVelocity.LengthSquared() > 0.0f)
            {
                this.TargetVelocity.Normalize();
            }

            if (inputService.Repeated.Contains(Keys.Right))
            {
                this.Yaw += 0.27f;
            }

            if (inputService.Repeated.Contains(Keys.Left))
            {
                this.Yaw -= 0.27f;
            }

            if (inputService.MouseDelta.X != 0)
            {
                this.Yaw += inputService.MouseDelta.X * 0.1f;

                if (this.Yaw > 360)
                {
                    this.Yaw = 0;
                }

                if (this.Yaw < 0)
                {
                    this.Yaw = 360;
                }
            }

            if (inputService.MouseDelta.Y != 0)
            {
                this.Pitch += inputService.MouseDelta.Y * 0.1f;

                if (this.Pitch > 90)
                {
                    this.Pitch = 90;
                }

                if (this.Pitch < -90)
                {
                    this.Pitch = -90;
                }
            }

            if (inputService.Pressed.Contains(Keys.Space))
            {
                this.TryJump = true;
            }

            // Walk speed
            this.TargetVelocity *= this.WalkSpeed;
        }
        public static IInputService CreateInputService(
            IKeyStateService keyStateService,
            IDictionaryService dictionaryService,
            IAudioService audioService,
            ICalibrationService calibrationService,
            ICapturingStateManager capturingStateManager,
            List <INotifyErrors> errorNotifyingServices)
        {
            //Log.Info("Creating InputService.");

            //Instantiate point source
            IPointSource pointSource;

            switch (Settings.Default.PointsSource)
            {
            case PointsSources.GazeTracker:
                pointSource = new GazeTrackerSource(
                    Settings.Default.PointTtl,
                    Settings.Default.GazeTrackerUdpPort,
                    new Regex(GazeTrackerUdpRegex));
                break;

            case PointsSources.TheEyeTribe:
                var theEyeTribePointService = new TheEyeTribePointService();
                errorNotifyingServices.Add(theEyeTribePointService);
                pointSource = new PointServiceSource(
                    Settings.Default.PointTtl,
                    theEyeTribePointService);
                break;

            case PointsSources.TobiiEyeX:
            case PointsSources.TobiiRex:
            case PointsSources.TobiiPcEyeGo:
                var tobiiEyeXPointService       = new TobiiEyeXPointService();
                var tobiiEyeXCalibrationService = calibrationService as TobiiEyeXCalibrationService;
                if (tobiiEyeXCalibrationService != null)
                {
                    tobiiEyeXCalibrationService.EyeXHost = tobiiEyeXPointService.EyeXHost;
                }
                errorNotifyingServices.Add(tobiiEyeXPointService);
                pointSource = new PointServiceSource(
                    Settings.Default.PointTtl,
                    tobiiEyeXPointService);
                break;

            case PointsSources.MousePosition:
                pointSource = new MousePositionSource(
                    Settings.Default.PointTtl);
                break;

            default:
                throw new ArgumentException("'PointsSource' settings is missing or not recognised! Please correct and restart OptiKey.");
            }

            //Instantiate key trigger source
            ITriggerSource keySelectionTriggerSource;

            switch (Settings.Default.KeySelectionTriggerSource)
            {
            case TriggerSources.Fixations:
                keySelectionTriggerSource = new KeyFixationSource(
                    Settings.Default.KeySelectionTriggerFixationLockOnTime,
                    Settings.Default.KeySelectionTriggerFixationResumeRequiresLockOn,
                    Settings.Default.KeySelectionTriggerFixationDefaultCompleteTime,
                    Settings.Default.KeySelectionTriggerFixationCompleteTimesByIndividualKey
                        ? Settings.Default.KeySelectionTriggerFixationCompleteTimesByKeyValues
                        : null,
                    Settings.Default.KeySelectionTriggerIncompleteFixationTtl,
                    pointSource.Sequence);
                break;

            case TriggerSources.KeyboardKeyDownsUps:
                keySelectionTriggerSource = new KeyboardKeyDownUpSource(
                    Settings.Default.KeySelectionTriggerKeyboardKeyDownUpKey,
                    pointSource.Sequence);
                break;

            case TriggerSources.MouseButtonDownUps:
                keySelectionTriggerSource = new MouseButtonDownUpSource(
                    Settings.Default.KeySelectionTriggerMouseDownUpButton,
                    pointSource.Sequence);
                break;

            default:
                throw new ArgumentException(
                          "'KeySelectionTriggerSource' setting is missing or not recognised! Please correct and restart OptiKey.");
            }

            //Instantiate point trigger source
            ITriggerSource pointSelectionTriggerSource;

            switch (Settings.Default.PointSelectionTriggerSource)
            {
            case TriggerSources.Fixations:
                pointSelectionTriggerSource = new PointFixationSource(
                    Settings.Default.PointSelectionTriggerFixationLockOnTime,
                    Settings.Default.PointSelectionTriggerFixationCompleteTime,
                    Settings.Default.PointSelectionTriggerLockOnRadiusInPixels,
                    Settings.Default.PointSelectionTriggerFixationRadiusInPixels,
                    pointSource.Sequence);
                break;

            case TriggerSources.KeyboardKeyDownsUps:
                pointSelectionTriggerSource = new KeyboardKeyDownUpSource(
                    Settings.Default.PointSelectionTriggerKeyboardKeyDownUpKey,
                    pointSource.Sequence);
                break;

            case TriggerSources.MouseButtonDownUps:
                pointSelectionTriggerSource = new MouseButtonDownUpSource(
                    Settings.Default.PointSelectionTriggerMouseDownUpButton,
                    pointSource.Sequence);
                break;

            default:
                throw new ArgumentException(
                          "'PointSelectionTriggerSource' setting is missing or not recognised! "
                          + "Please correct and restart OptiKey.");
            }

            var inputService = new InputService(keyStateService, dictionaryService, audioService, capturingStateManager,
                                                pointSource, keySelectionTriggerSource, pointSelectionTriggerSource);

            inputService.RequestSuspend(); //Pause it initially
            return(inputService);
        }
        public override void Update(GameTime gameTime)
        {
            // ----- Move object A with arrow keys.
            // Compute displacement.
            Vector3F displacement = Vector3F.Zero;

            if (InputService.IsDown(Keys.Up))
            {
                displacement.Y += 0.1f;
            }
            if (InputService.IsDown(Keys.Left))
            {
                displacement.X -= 0.1f;
            }
            if (InputService.IsDown(Keys.Down))
            {
                displacement.Y -= 0.1f;
            }
            if (InputService.IsDown(Keys.Right))
            {
                displacement.X += 0.1f;
            }

            // Update the position of object A (green box).
            _startPoseA.Position += displacement;

            // ----- CONTINUOUS COLLISION DETECTION -----
            // Object A moves from its current position to _targetPoseA.
            // Object B moves from its current position to _targetPoseB.
            // Let's see if they collide during their movement.
            ((GeometricObject)_collisionObjectA.GeometricObject).Pose = _startPoseA;
            ((GeometricObject)_collisionObjectB.GeometricObject).Pose = _startPoseB;
            _timeOfImpact = _collisionDetection.GetTimeOfImpact(
                _collisionObjectA,
                _targetPoseA,
                _collisionObjectB,
                _targetPoseB,
                0.05f);
            // The resulting time of impact is 1 if they do not collide or if they collide in their
            // end position. The time of impact is less then one if they collide before they reach
            // their target position.
            // -----

            // ----- Draw objects using the DebugRenderer of the graphics screen.
            // We reset the DebugRenderer every frame.
            var debugRenderer = GraphicsScreen.DebugRenderer;

            debugRenderer.Clear();

            // Draw game objects in the start pose.
            debugRenderer.DrawShape(_collisionObjectA.GeometricObject.Shape, _startPoseA, Vector3F.One, Color.Gray, false, false);
            debugRenderer.DrawShape(_collisionObjectB.GeometricObject.Shape, _startPoseB, Vector3F.One, Color.Gray, false, false);

            // Draw game objects in the target pose.
            debugRenderer.DrawShape(_collisionObjectA.GeometricObject.Shape, _targetPoseA, Vector3F.One, Color.Gray, false, false);
            debugRenderer.DrawShape(_collisionObjectB.GeometricObject.Shape, _targetPoseB, Vector3F.One, Color.Gray, false, false);

            // Draw objects at the first time of impact.
            if (_timeOfImpact < 1)
            {
                // Set objects to intermediate pose at time of impact.
                var poseA = Pose.Interpolate(_startPoseA, _targetPoseA, _timeOfImpact);
                var poseB = Pose.Interpolate(_startPoseB, _targetPoseB, _timeOfImpact);

                // Draw intermediate objects.
                debugRenderer.DrawShape(_collisionObjectA.GeometricObject.Shape, poseA, Vector3F.One, Color.Red, false, false);
                debugRenderer.DrawShape(_collisionObjectB.GeometricObject.Shape, poseB, Vector3F.One, Color.Red, false, false);
            }
        }
示例#7
0
        public override void Update(GameTime gameTime)
        {
            bool updateCurve = false;

            // When the sample is started or when <Space> is pressed, we create a random curve.
            if (_curve == null || InputService.IsPressed(Keys.Space, true))
            {
                _curve = new Curve2F
                {
                    PreLoop    = _loopType,
                    PostLoop   = _loopType,
                    SmoothEnds = _smoothEnds
                };

                // Create random key points.
                for (float x = 0; x <= 1; x += 0.1f)
                {
                    float y = RandomHelper.Random.NextFloat(0, 1);

                    _curve.Add(new CurveKey2F
                    {
                        Point = new Vector2F(x, y),

                        // We use the same interpolation type (spline type) for all curve keys. But
                        // it is possible to use a different interpolation type for each curve key.
                        Interpolation = _interpolationType,
                    });
                }

                updateCurve = true;
            }

            // If <1> is pressed, we change the loop type.
            if (InputService.IsPressed(Keys.D1, true))
            {
                // Choose next enumeration value for _loopType.
                if ((int)_loopType + 1 >= EnumHelper.GetValues(typeof(CurveLoopType)).Length)
                {
                    _loopType = 0;
                }
                else
                {
                    _loopType++;
                }

                _curve.PreLoop  = _loopType;
                _curve.PostLoop = _loopType;
                updateCurve     = true;
            }

            // If <2> is pressed, we change the spline type.
            if (InputService.IsPressed(Keys.D2, true))
            {
                // Choose next enumeration value for _interpolationType.
                if ((int)_interpolationType + 1 >= EnumHelper.GetValues(typeof(SplineInterpolation)).Length)
                {
                    _interpolationType = 0;
                }
                else
                {
                    _interpolationType++;
                }

                // We skip Bézier and Hermite splines because both need additional information per
                // curve key (control points or tangents), which we did not specify in the curve creation.
                while (_interpolationType == SplineInterpolation.Bezier ||
                       _interpolationType == SplineInterpolation.Hermite)
                {
                    _interpolationType++;
                }

                _curve.ForEach(key => key.Interpolation = _interpolationType);
                updateCurve = true;
            }

            // If <3> is pressed, we toggle "SmoothEnds".
            // If SmoothEnds is enabled the curve is smoother at the first and at the last
            // key point. The effect of SmoothEnds is visible, for example, if the loop type
            // is "Oscillate" and the spline type is "CatmullRom".
            if (InputService.IsPressed(Keys.D3, true))
            {
                _smoothEnds       = !_smoothEnds;
                _curve.SmoothEnds = _smoothEnds;
                updateCurve       = true;
            }

            if (updateCurve)
            {
                var debugRenderer = GraphicsScreen.DebugRenderer2D;
                debugRenderer.Clear();
                debugRenderer.DrawText(
                    string.Format("\n\nLoop type = {0}\nInterpolation = {1}\nSmoothEnds = {2}",
                                  _curve.PreLoop, _curve[0].Interpolation, _curve.SmoothEnds));

                // Draw two lines to create chart axes.
                debugRenderer.DrawLine(new Vector3(100, 300, 0), new Vector3(1000, 300, 0), Color.Black, true);
                debugRenderer.DrawLine(new Vector3(300, 100, 0), new Vector3(300, 320, 0), Color.Black, true);

                Vector2F scale  = new Vector2F(400, 200);
                Vector2F offset = new Vector2F(300, 100);

                // Draw a small cross for all curve key points.
                for (int index = 0; index < _curve.Count; index++)
                {
                    CurveKey2F key   = _curve[index];
                    Vector2F   point = scale * key.Point + offset;
                    debugRenderer.DrawLine(new Vector3(point.X - 5, point.Y - 5, 0), new Vector3(point.X + 5, point.Y + 5, 0), Color.Black, true);
                    debugRenderer.DrawLine(new Vector3(point.X + 5, point.Y - 5, 0), new Vector3(point.X - 5, point.Y + 5, 0), Color.Black, true);
                }

                // Draw the curve.
                const float stepSize = 0.02f;
                for (float x = -0.5f; x < 1.7f; x += stepSize)
                {
                    Vector2F point0 = scale * _curve.GetPoint(x) + offset;
                    Vector2F point1 = scale * _curve.GetPoint(x + stepSize) + offset;
                    debugRenderer.DrawLine(new Vector3(point0.X, point0.Y, 0), new Vector3(point1.X, point1.Y, 0), Color.Black, true);
                }
            }

            base.Update(gameTime);
        }
 public PlayerUseCase(AppState appState, InputService inputService)
 {
     _appState     = appState;
     _inputService = inputService;
 }
示例#9
0
        private void GenerateContent()
        {
            Log.DebugFormat("GenerateContent called. Keyboard language is '{0}' and Keyboard type is '{1}'",
                            Settings.Default.KeyboardAndDictionaryLanguage, Keyboard != null ? Keyboard.GetType() : null);

            //Clear out point to key map and pause input service
            PointToKeyValueMap = null;
            if (InputService != null)
            {
                InputService.RequestSuspend();
            }

            object newContent = ErrorContent;

            if (Keyboard is ViewModelKeyboards.Alpha)
            {
                switch (Settings.Default.KeyboardAndDictionaryLanguage)
                {
                case Languages.CroatianCroatia:
                    newContent = new CroatianViews.Alpha {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.DutchBelgium:
                    newContent = new DutchViews.BelgiumAlpha {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.DutchNetherlands:
                    newContent = new DutchViews.NetherlandsAlpha {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.FrenchFrance:
                    newContent = new FrenchViews.Alpha {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.GermanGermany:
                    newContent = new GermanViews.Alpha {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.GreekGreece:
                    newContent = new GreekViews.Alpha {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.ItalianItaly:
                    newContent = new ItalianViews.Alpha {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.RussianRussia:
                    newContent = new RussianViews.Alpha {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.SpanishSpain:
                    newContent = new SpanishViews.Alpha {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.TurkishTurkey:
                    newContent = new TurkishViews.Alpha {
                        DataContext = Keyboard
                    };
                    break;

                default:
                    newContent = new EnglishViews.Alpha {
                        DataContext = Keyboard
                    };
                    break;
                }
            }
            else if (Keyboard is ViewModelKeyboards.ConversationAlpha)
            {
                switch (Settings.Default.KeyboardAndDictionaryLanguage)
                {
                case Languages.CroatianCroatia:
                    newContent = new CroatianViews.ConversationAlpha {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.DutchBelgium:
                    newContent = new DutchViews.BelgiumConversationAlpha {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.DutchNetherlands:
                    newContent = new DutchViews.NetherlandsConversationAlpha {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.FrenchFrance:
                    newContent = new FrenchViews.ConversationAlpha {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.GermanGermany:
                    newContent = new GermanViews.ConversationAlpha {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.GreekGreece:
                    newContent = new GreekViews.ConversationAlpha {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.ItalianItaly:
                    newContent = new ItalianViews.ConversationAlpha {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.RussianRussia:
                    newContent = new RussianViews.ConversationAlpha {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.SpanishSpain:
                    newContent = new SpanishViews.ConversationAlpha {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.TurkishTurkey:
                    newContent = new TurkishViews.ConversationAlpha {
                        DataContext = Keyboard
                    };
                    break;

                default:
                    newContent = new EnglishViews.ConversationAlpha {
                        DataContext = Keyboard
                    };
                    break;
                }
            }
            else if (Keyboard is ViewModelKeyboards.ConversationNumericAndSymbols)
            {
                newContent = new CommonViews.ConversationNumericAndSymbols {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.Currencies1)
            {
                newContent = new CommonViews.Currencies1 {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.Currencies2)
            {
                newContent = new CommonViews.Currencies2 {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.Diacritics1)
            {
                newContent = new CommonViews.Diacritics1 {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.Diacritics2)
            {
                newContent = new CommonViews.Diacritics2 {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.Diacritics3)
            {
                newContent = new CommonViews.Diacritics3 {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.Language)
            {
                newContent = new CommonViews.Language {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.Menu)
            {
                newContent = new CommonViews.Menu {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.Minimised)
            {
                newContent = new CommonViews.Minimised {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.Mouse)
            {
                newContent = new CommonViews.Mouse {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.NumericAndSymbols2)
            {
                newContent = new CommonViews.NumericAndSymbols2 {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.NumericAndSymbols3)
            {
                newContent = new CommonViews.NumericAndSymbols3 {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.NumericAndSymbols1)
            {
                newContent = new CommonViews.NumericAndSymbols1 {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.PhysicalKeys)
            {
                newContent = new CommonViews.PhysicalKeys {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.SizeAndPosition)
            {
                newContent = new CommonViews.SizeAndPosition {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.YesNoQuestion)
            {
                newContent = new CommonViews.YesNoQuestion {
                    DataContext = Keyboard
                };
            }

            Content = newContent;
        }
示例#10
0
 public override void Execute()
 {
     InputService.InitInputService(InputControlModel);
 }
示例#11
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            float deltaTime = (float)gameTime.ElapsedGameTime.TotalSeconds;

            // <1> / <Shift> + <1> --> Change the downsample factor.
            if (InputService.IsPressed(Keys.D1, true))
            {
                bool isShiftDown = (InputService.ModifierKeys & ModifierKeys.Shift) != 0;
                if (isShiftDown)
                {
                    _godRayFilter.DownsampleFactor++;
                }
                else
                {
                    _godRayFilter.DownsampleFactor = Math.Max(1, _godRayFilter.DownsampleFactor - 1);
                }
            }

            // <2> / <Shift> + <2> --> Change number of samples.
            if (InputService.IsPressed(Keys.D2, true))
            {
                bool isShiftDown = (InputService.ModifierKeys & ModifierKeys.Shift) != 0;
                if (isShiftDown)
                {
                    _godRayFilter.NumberOfSamples++;
                }
                else
                {
                    _godRayFilter.NumberOfSamples = Math.Max(1, _godRayFilter.NumberOfSamples - 1);
                }
            }

            // <3> / <Shift> + <3> --> Change number of blur passes.
            if (InputService.IsPressed(Keys.D3, true))
            {
                bool isShiftDown = (InputService.ModifierKeys & ModifierKeys.Shift) != 0;
                if (isShiftDown)
                {
                    _godRayFilter.NumberOfPasses++;
                }
                else
                {
                    _godRayFilter.NumberOfPasses = Math.Max(1, _godRayFilter.NumberOfPasses - 1);
                }
            }

            // <4> / <Shift> + <4> --> Change light radius.
            if (InputService.IsDown(Keys.D4))
            {
                // Increase or decrease value by a factor of 1.01 every frame (1/60 s).
                bool  isShiftDown = (InputService.ModifierKeys & ModifierKeys.Shift) != 0;
                float factor      = isShiftDown ? 1.01f : 1.0f / 1.01f;
                _godRayFilter.LightRadius *= (float)Math.Pow(factor, deltaTime * 60);
            }

            // <5> / <Shift> + <5> --> Change intensity.
            if (InputService.IsDown(Keys.D5))
            {
                // Increase or decrease value by a factor of 1.01 every frame (1/60 s).
                bool  isShiftDown = (InputService.ModifierKeys & ModifierKeys.Shift) != 0;
                float factor      = isShiftDown ? 1.01f : 1.0f / 1.01f;
                _godRayFilter.Intensity *= (float)Math.Pow(factor, deltaTime * 60);
            }

            // <6> / <Shift> + <6> --> Change scale.
            if (InputService.IsDown(Keys.D6))
            {
                // Increase or decrease value by a factor of 1.01 every frame (1/60 s).
                bool  isShiftDown = (InputService.ModifierKeys & ModifierKeys.Shift) != 0;
                float factor      = isShiftDown ? 1.01f : 1.0f / 1.01f;
                _godRayFilter.Scale *= (float)Math.Pow(factor, deltaTime * 60);
            }

            // <7> / <Shift> + <7> --> Change softness.
            if (InputService.IsDown(Keys.D7))
            {
                // Increase or decrease value by a factor of 1.01 every frame (1/60 s).
                bool  isShiftDown = (InputService.ModifierKeys & ModifierKeys.Shift) != 0;
                float factor      = isShiftDown ? 1.01f : 1.0f / 1.01f;
                _godRayFilter.Softness *= (float)Math.Pow(factor, deltaTime * 60);
                _godRayFilter.Softness  = MathHelper.Clamp(_godRayFilter.Softness, 0, 1);
            }

            GraphicsScreen.DebugRenderer.DrawText(
                "\n\nPress <1> or <Shift>+<1> to decrease or increase the downsample factor: " + _godRayFilter.DownsampleFactor
                + "\nPress <2> or <Shift>+<2> to decrease or increase the number of samples: " + _godRayFilter.NumberOfSamples
                + "\nPress <3> or <Shift>+<3> to decrease or increase the number of passes: "
                + _godRayFilter.NumberOfPasses
                + "\nHold <4> or <Shift>+<4> to decrease or increase the light radius: " + _godRayFilter.LightRadius
                + "\nHold <5> or <Shift>+<5> to decrease or increase the intensity: " + _godRayFilter.Intensity
                + "\nHold <6> or <Shift>+<6> to decrease or increase the scale: " + _godRayFilter.Scale
                + "\nHold <7> or <Shift>+<7> to decrease or increase the softness: " + _godRayFilter.Softness);
        }
示例#12
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            float deltaTime = (float)gameTime.ElapsedGameTime.TotalSeconds;

            // <1> / <Shift> + <1> --> Change number of samples.
            if (InputService.IsPressed(Keys.D1, true))
            {
                bool isShiftDown = (InputService.ModifierKeys & ModifierKeys.Shift) != 0;
                if (isShiftDown)
                {
                    _godRayFilter.NumberOfSamples++;
                }
                else
                {
                    _godRayFilter.NumberOfSamples = Math.Max(1, _godRayFilter.NumberOfSamples - 1);
                }
            }

            // <2> / <Shift> + <2> --> Change scale.
            if (InputService.IsDown(Keys.D2))
            {
                // Increase or decrease value by a factor of 1.01 every frame (1/60 s).
                bool  isShiftDown = (InputService.ModifierKeys & ModifierKeys.Shift) != 0;
                float factor      = isShiftDown ? 1.01f : 1.0f / 1.01f;
                _godRayFilter.Scale *= (float)Math.Pow(factor, deltaTime * 60);
            }

            // <3> / <Shift> + <3> --> Change exposure.
            if (InputService.IsDown(Keys.D3))
            {
                // Increase or decrease value by a factor of 1.01 every frame (1/60 s).
                bool  isShiftDown = (InputService.ModifierKeys & ModifierKeys.Shift) != 0;
                float factor      = isShiftDown ? 1.01f : 1.0f / 1.01f;
                _godRayFilter.Exposure *= (float)Math.Pow(factor, deltaTime * 60);
            }

            // <4> / <Shift> + <4> --> Change weight.
            if (InputService.IsDown(Keys.D4))
            {
                // Increase or decrease value by a factor of 1.01 every frame (1/60 s).
                bool  isShiftDown = (InputService.ModifierKeys & ModifierKeys.Shift) != 0;
                float factor      = isShiftDown ? 1.01f : 1.0f / 1.01f;
                _godRayFilter.Weight *= (float)Math.Pow(factor, deltaTime * 60);
            }

            // <5> / <Shift> + <5> --> Change decay.
            if (InputService.IsDown(Keys.D5))
            {
                // Increase or decrease value by a factor of 1.01 every frame (1/60 s).
                bool  isShiftDown = (InputService.ModifierKeys & ModifierKeys.Shift) != 0;
                float factor      = isShiftDown ? 1.01f : 1.0f / 1.01f;
                _godRayFilter.Decay *= (float)Math.Pow(factor, deltaTime * 60);
            }

            GraphicsScreen.DebugRenderer.DrawText(
                "\n\nPress <1> or <Shift>+<1> to decrease or increase the number of samples: " + _godRayFilter.NumberOfSamples
                + "\nHold <2> or <Shift>+<2> to decrease or increase the scale: " + _godRayFilter.Scale
                + "\nHold <3> or <Shift>+<3> to decrease or increase the exposure: " + _godRayFilter.Exposure
                + "\nHold <4> or <Shift>+<4> to decrease or increase the weight: " + _godRayFilter.Weight
                + "\nHold <5> or <Shift>+<5> to decrease or increase the decay: " + _godRayFilter.Decay);
        }
示例#13
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            // <1> / <Shift> + <1> --> Change quality.
            if (InputService.IsPressed(Keys.D1, true))
            {
                bool isShiftDown = (InputService.ModifierKeys & ModifierKeys.Shift) != 0;
                if (isShiftDown)
                {
                    _ssaoFilter.Quality = Math.Min(2, _ssaoFilter.Quality + 1);
                }
                else
                {
                    _ssaoFilter.Quality = Math.Max(0, _ssaoFilter.Quality - 1);
                }
            }

            // <2> / <Shift> + <2> --> Change downsample factor.
            if (InputService.IsPressed(Keys.D2, true))
            {
                bool isShiftDown = (InputService.ModifierKeys & ModifierKeys.Shift) != 0;
                if (isShiftDown)
                {
                    _ssaoFilter.DownsampleFactor++;
                }
                else
                {
                    _ssaoFilter.DownsampleFactor = Math.Max(1, _ssaoFilter.DownsampleFactor - 1);
                }
            }

            // <3> / <Shift> + <3> --> Change number of blur passes.
            if (InputService.IsPressed(Keys.D3, true))
            {
                bool isShiftDown = (InputService.ModifierKeys & ModifierKeys.Shift) != 0;
                if (isShiftDown)
                {
                    _ssaoFilter.NumberOfBlurPasses++;
                }
                else
                {
                    _ssaoFilter.NumberOfBlurPasses = Math.Max(0, _ssaoFilter.NumberOfBlurPasses - 1);
                }
            }

            // <4> --> Toggle edge-aware blur.
            if (InputService.IsPressed(Keys.D4, false))
            {
                _ssaoFilter.UseEdgeAwareBlur = !_ssaoFilter.UseEdgeAwareBlur;
            }

            // <5> / <Shift> + <5> --> Change strength.
            if (InputService.IsDown(Keys.D5))
            {
                // Increase or decrease value by a factor of 1.01 every frame (1/60 s).
                bool  isShiftDown = (InputService.ModifierKeys & ModifierKeys.Shift) != 0;
                float factor      = isShiftDown ? 1.01f : 1.0f / 1.01f;
                float time        = (float)gameTime.ElapsedGameTime.TotalSeconds;
                _ssaoFilter.Strength *= (float)Math.Pow(factor, time * 60);
            }

            // <6> / <Shift> + <6> --> Change inner radius.
            if (InputService.IsDown(Keys.D6))
            {
                // Increase or decrease value by a factor of 1.01 every frame (1/60 s).
                bool     isShiftDown = (InputService.ModifierKeys & ModifierKeys.Shift) != 0;
                float    factor      = isShiftDown ? 1.01f : 1.0f / 1.01f;
                float    time        = (float)gameTime.ElapsedGameTime.TotalSeconds;
                Vector2F radii       = _ssaoFilter.Radii;
                radii.X          *= (float)Math.Pow(factor, time * 60);
                _ssaoFilter.Radii = radii;
            }

            // <7> / <Shift> + <7> --> Change outer radius.
            if (InputService.IsDown(Keys.D7))
            {
                // Increase or decrease value by a factor of 1.01 every frame (1/60 s).
                bool     isShiftDown = (InputService.ModifierKeys & ModifierKeys.Shift) != 0;
                float    factor      = isShiftDown ? 1.01f : 1.0f / 1.01f;
                float    time        = (float)gameTime.ElapsedGameTime.TotalSeconds;
                Vector2F radii       = _ssaoFilter.Radii;
                radii.Y          *= (float)Math.Pow(factor, time * 60);
                _ssaoFilter.Radii = radii;
            }

            // <8> / <Shift> + <8> --> Change max distances.
            if (InputService.IsDown(Keys.D8))
            {
                // Increase or decrease value by a factor of 1.01 every frame (1/60 s).
                bool  isShiftDown = (InputService.ModifierKeys & ModifierKeys.Shift) != 0;
                float factor      = isShiftDown ? 1.01f : 1.0f / 1.01f;
                float time        = (float)gameTime.ElapsedGameTime.TotalSeconds;
                _ssaoFilter.MaxDistances *= (float)Math.Pow(factor, time * 60);
            }

            // <9> --> Toggle edge-aware blur.
            if (InputService.IsPressed(Keys.D9, false))
            {
                _ssaoFilter.CombineWithSource = !_ssaoFilter.CombineWithSource;
            }

            GraphicsScreen.DebugRenderer.DrawText(
                "\n\nPress <1> or <Shift>+<1> to decrease or increase the quality level: " + _ssaoFilter.Quality
                + "\nPress <2> or <Shift>+<2> to decrease or increase the downsample factor: " + _ssaoFilter.DownsampleFactor
                + "\nPress <3> or <Shift>+<3> to decrease or increase the number of blur passes: " + _ssaoFilter.NumberOfBlurPasses
                + "\nPress <4> to toggle the edge-aware blur: " + _ssaoFilter.UseEdgeAwareBlur
                + "\nHold <5> or <Shift>+<5> to decrease or increase the AO strength: " + _ssaoFilter.Strength
                + "\nHold <6> or <Shift>+<6> to decrease or increase the inner radius: " + _ssaoFilter.Radii.X
                + "\nHold <7> or <Shift>+<7> to decrease or increase the outer radius: " + _ssaoFilter.Radii.Y
                + "\nHold <8> or <Shift>+<8> to decrease or increase max distance: " + _ssaoFilter.MaxDistances
                + "\nPress <9> to toggle rendering of the AO buffer: " + _ssaoFilter.CombineWithSource);
        }
        private void HandleInput(float deltaTime)
        {
            // Change sensor height.
            if (InputService.IsDown(Keys.NumPad7))
            {
                _kinectSensorHeight += 0.1f * deltaTime;
            }
            if (InputService.IsDown(Keys.NumPad4))
            {
                _kinectSensorHeight -= 0.1f * deltaTime;
            }

            // Change y offset of Kinect skeleton data.
            if (InputService.IsDown(Keys.NumPad8))
            {
                _kinectWrapper.Offset = _kinectWrapper.Offset + new Vector3F(0, 0.1f * deltaTime, 0);
            }
            if (InputService.IsDown(Keys.NumPad5))
            {
                _kinectWrapper.Offset = _kinectWrapper.Offset - new Vector3F(0, 0.1f * deltaTime, 0);
            }

            // Change scale of Kinect skeleton data.
            if (InputService.IsDown(Keys.NumPad9))
            {
                _kinectWrapper.Scale = _kinectWrapper.Scale + new Vector3F(0.1f * deltaTime);
            }
            if (InputService.IsDown(Keys.NumPad6))
            {
                _kinectWrapper.Scale = _kinectWrapper.Scale - new Vector3F(0.1f * deltaTime);
            }

            // Toggle drawing of model.
            if (InputService.IsPressed(Keys.NumPad0, false))
            {
                _drawModel = !_drawModel;
            }

            // Toggle drawing of Kinect skeletons.
            if (InputService.IsPressed(Keys.NumPad1, false))
            {
                _drawKinectSkeletons = !_drawKinectSkeletons;
            }

            // Toggle drawing of model skeletons.
            if (InputService.IsPressed(Keys.NumPad2, false))
            {
                _drawModelSkeletons = !_drawModelSkeletons;
            }

            // Toggle drawing of ragdoll bodies.
            if (InputService.IsPressed(Keys.NumPad3, false))
            {
                _drawRigidBodies = !_drawRigidBodies;
            }

            // Toggle drawing of ragdoll constraints.
            if (InputService.IsPressed(Keys.Decimal, false))
            {
                _drawConstraints = !_drawConstraints;
            }
        }
示例#15
0
        private void GenerateContent()
        {
            Log.DebugFormat("GenerateContent called. Keyboard language is '{0}' and Keyboard type is '{1}'",
                            Settings.Default.KeyboardLanguage, Keyboard != null ? Keyboard.GetType() : null);

            //Clear out point to key map and pause input service
            PointToKeyValueMap = null;
            if (InputService != null)
            {
                InputService.RequestSuspend();
            }

            object newContent = ErrorContent;

            if (Keyboard is ViewModelKeyboards.Alpha)
            {
                switch (Settings.Default.KeyboardLanguage)
                {
                case Languages.EnglishUS:
                case Languages.EnglishUK:
                case Languages.EnglishCanada:
                    newContent = new EnglishViews.Alpha {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.FrenchFrance:
                    newContent = new FrenchViews.Alpha {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.GermanGermany:
                    newContent = new GermanViews.Alpha {
                        DataContext = Keyboard
                    };
                    break;
                }
            }
            else if (Keyboard is ViewModelKeyboards.ConversationAlpha)
            {
                switch (Settings.Default.KeyboardLanguage)
                {
                case Languages.EnglishUS:
                case Languages.EnglishUK:
                case Languages.EnglishCanada:
                    newContent = new EnglishViews.ConversationAlpha {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.FrenchFrance:
                    newContent = new FrenchViews.ConversationAlpha {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.GermanGermany:
                    newContent = new GermanViews.ConversationAlpha {
                        DataContext = Keyboard
                    };
                    break;
                }
            }
            else if (Keyboard is ViewModelKeyboards.ConversationNumericAndSymbols)
            {
                newContent = new CommonViews.ConversationNumericAndSymbols {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.Currencies1)
            {
                newContent = new CommonViews.Currencies1 {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.Currencies2)
            {
                newContent = new CommonViews.Currencies2 {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.Diacritics1)
            {
                switch (Settings.Default.KeyboardLanguage)
                {
                case Languages.FrenchFrance:
                    newContent = new FrenchViews.Diacritics1 {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.GermanGermany:
                    newContent = new GermanViews.Diacritics1 {
                        DataContext = Keyboard
                    };
                    break;

                default:
                    newContent = new CommonViews.Diacritics1 {
                        DataContext = Keyboard
                    };
                    break;
                }
            }
            else if (Keyboard is ViewModelKeyboards.Diacritics2)
            {
                switch (Settings.Default.KeyboardLanguage)
                {
                case Languages.FrenchFrance:
                    newContent = new FrenchViews.Diacritics2 {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.GermanGermany:
                    newContent = new GermanViews.Diacritics2 {
                        DataContext = Keyboard
                    };
                    break;

                default:
                    newContent = new CommonViews.Diacritics2 {
                        DataContext = Keyboard
                    };
                    break;
                }
            }
            else if (Keyboard is ViewModelKeyboards.Diacritics3)
            {
                switch (Settings.Default.KeyboardLanguage)
                {
                case Languages.FrenchFrance:
                    newContent = new FrenchViews.Diacritics3 {
                        DataContext = Keyboard
                    };
                    break;

                case Languages.GermanGermany:
                    newContent = new GermanViews.Diacritics3 {
                        DataContext = Keyboard
                    };
                    break;

                default:
                    newContent = new CommonViews.Diacritics3 {
                        DataContext = Keyboard
                    };
                    break;
                }
            }
            else if (Keyboard is ViewModelKeyboards.Menu)
            {
                newContent = new CommonViews.Menu {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.Minimised)
            {
                newContent = new CommonViews.Minimised {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.Mouse)
            {
                newContent = new CommonViews.Mouse {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.NumericAndSymbols2)
            {
                newContent = new CommonViews.NumericAndSymbols2 {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.NumericAndSymbols3)
            {
                newContent = new CommonViews.NumericAndSymbols3 {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.NumericAndSymbols1)
            {
                newContent = new CommonViews.NumericAndSymbols1 {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.PhysicalKeys)
            {
                newContent = new CommonViews.PhysicalKeys {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.SizeAndPosition)
            {
                newContent = new CommonViews.SizeAndPosition {
                    DataContext = Keyboard
                };
            }
            else if (Keyboard is ViewModelKeyboards.YesNoQuestion)
            {
                newContent = new CommonViews.YesNoQuestion {
                    DataContext = Keyboard
                };
            }

            Content = newContent;
        }