protected override void UpdateKeyStates()
 {
     nativeKeyboard.GetCurrentState(ref nativeState);
     for (int i = 0; i < (int)Key.NumberOfKeys; i++)
     {
         UpdateKeyState(i, nativeState.IsPressed(KeyboardKeyMapper.Translate((Key)i)));
     }
 }
Exemplo n.º 2
0
        protected virtual void SetViewMatrix(float time, SharpDX.DirectInput.KeyboardState kState)
        {
            float speed       = 0.001f;
            var   rotation    = Matrix.Identity;
            var   translation = Matrix.Identity;

            if (kState.IsPressed(SharpDX.DirectInput.Key.D))
            {
                rotation = Matrix.RotationY(-speed * time);
            }
            if (kState.IsPressed(SharpDX.DirectInput.Key.A))
            {
                rotation = Matrix.RotationY(speed * time);
            }
            if (kState.IsPressed(SharpDX.DirectInput.Key.W))
            {
                rotation = Matrix.RotationX(speed * time);
            }
            if (kState.IsPressed(SharpDX.DirectInput.Key.S))
            {
                rotation = Matrix.RotationX(-speed * time);
            }
            if (kState.IsPressed(SharpDX.DirectInput.Key.Left))
            {
                rotation = Matrix.RotationZ(speed * time);
            }
            if (kState.IsPressed(SharpDX.DirectInput.Key.Right))
            {
                rotation = Matrix.RotationZ(-speed * time);
            }

            if (kState.IsPressed(SharpDX.DirectInput.Key.Up))
            {
                translation = Matrix.Translation(0, 0, -speed * time * 100);
            }
            if (kState.IsPressed(SharpDX.DirectInput.Key.Down))
            {
                translation = Matrix.Translation(0, 0, speed * time * 100);
            }

            _view = _view * rotation * translation;
        }