private void processUserInput(float elapsed, TWKeyboard keyboard, TWMouse mouse)
        {
            if (!enableUserInput)
            {
                return;
            }
            Vector3 vSnelheid = new Vector3();

            if (keyboard.IsKeyDown(Key.S))
            {
                vSnelheid += MathHelper.Forward;
            }
            if (keyboard.IsKeyDown(Key.W))
            {
                vSnelheid += MathHelper.Backward;
            }
            if (keyboard.IsKeyDown(Key.A))
            {
                vSnelheid += MathHelper.Right;
            }
            if (keyboard.IsKeyDown(Key.D))
            {
                vSnelheid += MathHelper.Left;
            }
            if (keyboard.IsKeyDown(Key.Space))
            {
                vSnelheid += MathHelper.Up;
            }
            if (keyboard.IsKeyDown(Key.LeftControl))
            {
                vSnelheid += MathHelper.Down;
            }



            vSnelheid = Vector3.TransformCoordinate(vSnelheid, Matrix.RotationYawPitchRoll(-AngleHorizontal, -AngleVertical, -AngleRoll));

            if (vSnelheid.Length() != 0)
            {
                vSnelheid.Normalize();
            }

            if (keyboard.IsKeyDown(Key.T))
            {
                vSnelheid *= 30;
            }
            if (keyboard.IsKeyDown(Key.LeftShift))
            {
                vSnelheid *= 5;
            }

            vSnelheid *= MovementSpeed;


            Snelheid = vSnelheid;


            Positie       += Snelheid * elapsed;
            CameraPosition = Positie;



            ProcessMouseInput(mouse.RelativeX, mouse.RelativeY);
        }
Пример #2
0
        public void SimulateFlightStep(Island island, Vector3 thrustDirection, Vector3 centerOfThrust)
        {
            var dir = new Vector3();

            if (keyboard.IsKeyDown(Key.W))
            {
                island.Velocity += thrustDirection * TW.Graphics.Elapsed * 10;
            }
            if (keyboard.IsKeyDown(Key.S))
            {
                island.Velocity -= thrustDirection * TW.Graphics.Elapsed * 10;
            }
            if (keyboard.IsKeyDown(Key.Space))
            {
                island.Position += Vector3.UnitY * TW.Graphics.Elapsed * 5;
            }
            if (keyboard.IsKeyDown(Key.LeftControl))
            {
                island.Position -= Vector3.UnitY * TW.Graphics.Elapsed * 5;
            }


            var turnSpeed = 0.8f;

            if (keyboard.IsKeyDown(Key.A))
            {
                turnCluster(island, turnSpeed * TW.Graphics.Elapsed, centerOfThrust);
            }
            if (keyboard.IsKeyDown(Key.D))
            {
                turnCluster(island, -turnSpeed * TW.Graphics.Elapsed, centerOfThrust);
            }

            if (keyboard.IsKeyDown(Key.LeftArrow))
            {
                island.Velocity -= getThrustRightDirection(thrustDirection) * TW.Graphics.Elapsed;
            }
            if (keyboard.IsKeyDown(Key.RightArrow))
            {
                island.Velocity += getThrustRightDirection(thrustDirection) * TW.Graphics.Elapsed;
            }
            if (keyboard.IsKeyDown(Key.UpArrow))
            {
                island.Velocity += thrustDirection * TW.Graphics.Elapsed;
            }
            if (keyboard.IsKeyDown(Key.DownArrow))
            {
                island.Velocity -= thrustDirection * TW.Graphics.Elapsed;
            }

            if (island.Velocity.Length() < 0.1f &&
                !keyboard.IsKeyDown(Key.W) &&
                !keyboard.IsKeyDown(Key.S) &&
                !keyboard.IsKeyDown(Key.LeftArrow) &&
                !keyboard.IsKeyDown(Key.RightArrow) &&
                !keyboard.IsKeyDown(Key.UpArrow) &&
                !keyboard.IsKeyDown(Key.DownArrow)
                )
            {
                island.Velocity = new Vector3();
            }
            // Add up and down?

            island.GetIslandsInCluster().ForEach(c => c.Velocity = island.Velocity);

            adjustForDocking(island, centerOfThrust);
        }