示例#1
0
        public override void Tick(float deltaTime)
        {
            base.Tick(deltaTime);

            Vector3 moveDir = Vector3.Zero;

            if (Input.GetKey(System.Windows.Input.Key.W))
            {
                moveDir -= Vector3.UnitZ;
            }
            if (Input.GetKey(System.Windows.Input.Key.S))
            {
                moveDir += Vector3.UnitZ;
            }
            if (Input.GetKey(System.Windows.Input.Key.D))
            {
                moveDir += Vector3.UnitX;
            }
            if (Input.GetKey(System.Windows.Input.Key.A))
            {
                moveDir -= Vector3.UnitX;
            }
            if (Input.GetKey(System.Windows.Input.Key.Q))
            {
                moveDir -= Vector3.UnitY;
            }
            if (Input.GetKey(System.Windows.Input.Key.E))
            {
                moveDir += Vector3.UnitY;
            }

            // If they're holding down the shift key adjust their FOV when they scroll, otherwise adjust move speed.
            if (Input.GetKey(System.Windows.Input.Key.LeftShift) || Input.GetKey(System.Windows.Input.Key.RightShift))
            {
                Camera.NearClipPlane = MathE.Clamp(Camera.NearClipPlane + Input.MouseScrollDelta * 50 * deltaTime * 1.0f, 100, 10000);
                Camera.FarClipPlane  = MathE.Clamp(Camera.FarClipPlane + Input.MouseScrollDelta * 10 * deltaTime * 1.2f, 5000, 100000);
            }
            else
            {
                MoveSpeed += Input.MouseScrollDelta * 100 * deltaTime;
                MoveSpeed  = MathE.Clamp(MoveSpeed, 100, 8000);
            }

            if (Input.GetMouseButton(1))
            {
                Rotate(deltaTime, Input.MouseDelta.X, Input.MouseDelta.Y);
            }

            // Early out if we're not moving this frame.
            if (moveDir.LengthFast < 0.1f)
            {
                return;
            }

            float moveSpeed = Input.GetKey(System.Windows.Input.Key.LeftShift) ? MoveSpeed * 3f : MoveSpeed;

            // Normalize the move direction
            moveDir.NormalizeFast();

            // Make it relative to the current rotation.
            moveDir = Camera.Transform.Rotation.Multiply(moveDir);

            Camera.Transform.Position += Vector3.Multiply(moveDir, moveSpeed * deltaTime);
        }
示例#2
0
 public static Color Lerp(Color a, Color b, float t)
 {
     t = MathE.ClampNormalized(t);
     return(new Color(a.R + (b.R - a.R) * t, a.G + (b.G - a.G) * t, a.B + (b.B - a.B) * t, a.A + (b.A - a.A) * t));
 }