Пример #1
0
        private bool HandleInput(DInput input, float frameTime)
        {
            // Set the frame time for calculating the updated position.
            Position.SetFrameTime(frameTime);

            // Handle the input
            bool keydown = input.IsLeftArrowPressed();

            Position.TurnLeft(keydown);
            keydown = input.IsRightArrowPressed();
            Position.TurnRight(keydown);
            keydown = input.IsUpArrowPressed();
            Position.MoveForward(keydown);
            keydown = input.IsDownArrowPressed();
            Position.MoveBackward(keydown);
            keydown = input.IsPageUpPressed();
            Position.LookUpward(keydown);
            keydown = input.IsPageDownPressed();
            Position.LookDownward(keydown);
            keydown = input.IsAPressed();
            Position.MoveUpward(keydown);
            keydown = input.IsZPressed();
            Position.MoveDownward(keydown);

            // Determine if the user interface should be displayed or not.
            if (input.IsF1Toogled())
            {
                DisplayUI = !DisplayUI;
            }
            // Determine if the terrain should be rendered in wireframe or not.
            if (input.IsF2Toogled())
            {
                WireFrame = !WireFrame;
            }
            // Determine if we should render the lines around each terrain cell.
            if (input.isF3Toggled())
            {
                CellLines = !CellLines;
            }
            // Determine if we should be locked to the terrain height when we move around or not.
            if (input.isF4Toggled())
            {
                HeightLocked = !HeightLocked;
            }

            // Set the position and rOTATION of the camera.
            Camera.SetPosition(Position.PositionX, Position.PositionY, Position.PositionZ);
            Camera.SetRotation(Position.RotationX, Position.RotationY, Position.RotationZ);

            return(true);
        }
Пример #2
0
        private bool HandleInput(DInput input, float frameTime)
        {
            // Set the frame time for calculating the updated position.
            Position.SetFrameTime(frameTime);

            // Handle the input
            bool keydown = input.IsLeftArrowPressed();

            Position.TurnLeft(keydown);
            keydown = input.IsRightArrowPressed();
            Position.TurnRight(keydown);
            keydown = input.IsUpArrowPressed();
            Position.MoveForward(keydown);
            keydown = input.IsDownArrowPressed();
            Position.MoveBackward(keydown);
            keydown = input.IsPageUpPressed();
            Position.LookUpward(keydown);
            keydown = input.IsPageDownPressed();
            Position.LookDownward(keydown);
            keydown = input.IsAPressed();
            Position.MoveUpward(keydown);
            keydown = input.IsZPressed();
            Position.MoveDownward(keydown);

            // Determine if the user interface should be displayed or not.
            if (input.IsF1Toogled())
            {
                DisplayUI = !DisplayUI;
            }

            // Set the position and rOTATION of the camera.
            Camera.SetPosition(Position.PositionX, Position.PositionY, Position.PositionZ);
            Camera.SetRotation(Position.RotationX, Position.RotationY, Position.RotationZ);

            return(true);
        }