Exemple #1
0
        /// <summary>
        /// This method set the reaction to each key stroke
        /// </summary>
        /// <param name="evt">Can be used to tune the reaction timings</param>
        /// <returns></returns>
        public bool ProcessInput(FrameEvent evt)
        {
            Vector3 displacements = Vector3.ZERO;
            Vector3 angles        = Vector3.ZERO;

            mKeyboard.Capture();
            mMouse.Capture();

            if (mKeyboard.IsKeyDown(MOIS.KeyCode.KC_A))
            {
                playerController.Left = true;
            }
            else
            {
                playerController.Left = false;
            }

            if (mKeyboard.IsKeyDown(MOIS.KeyCode.KC_D))
            {
                playerController.Right = true;
            }
            else
            {
                playerController.Right = false;
            }

            if (mKeyboard.IsKeyDown(MOIS.KeyCode.KC_W))
            {
                playerController.Forward = true;
            }
            else
            {
                playerController.Forward = false;
            }

            if (mKeyboard.IsKeyDown(MOIS.KeyCode.KC_S))
            {
                playerController.Backward = true;
            }
            else
            {
                playerController.Backward = false;
            }


            if (mMouse.MouseState.ButtonDown(MOIS.MouseButtonID.MB_Left))
            {
                angles.y = -mMouse.MouseState.X.rel;
            }

            if (mMouse.MouseState.ButtonDown(MOIS.MouseButtonID.MB_Right))
            {
                angles.y = mMouse.MouseState.X.rel;
            }


            playerController.Angles = angles;
            return(true);
        }
        /// <summary>
        /// This method set the reaction to each key stroke
        /// </summary>
        /// <param name="evt">Can be used to tune the reaction timings</param>
        /// <returns></returns>
        public bool ProcessInput(FrameEvent evt)
        {
            Vector3 displacements = Vector3.ZERO;
            Vector3 angles        = Vector3.ZERO;

            mKeyboard.Capture();
            mMouse.Capture();

            if (mKeyboard.IsKeyDown(MOIS.KeyCode.KC_A))
            {
                controller.Left = true;
            }
            else
            {
                controller.Left = false;
            }
            if (mKeyboard.IsKeyDown(MOIS.KeyCode.KC_D))
            {
                controller.Right = true;
            }
            else
            {
                controller.Right = false;
            }
            if (mKeyboard.IsKeyDown(MOIS.KeyCode.KC_W))
            {
                controller.Forward = true;
            }
            else
            {
                controller.Forward = false;
            }
            if (mKeyboard.IsKeyDown(MOIS.KeyCode.KC_S))
            {
                controller.Backward = true;
            }
            else
            {
                controller.Backward = false;
            }

            if (mKeyboard.IsKeyDown(MOIS.KeyCode.KC_LSHIFT))
            {
                controller.Accellerate = true;
            }
            else
            {
                controller.Accellerate = false;
            }

            angles.y          = -mMouse.MouseState.X.rel;
            controller.Angles = angles;
            return(true);
        }
Exemple #3
0
        protected virtual bool OnFrameRenderingQueued(FrameEvent evt)
        {
            mKeyboard.Capture();
            mMouse.Capture();

            Vector3 cameraMove = Vector3.ZERO;

            if (mKeyboard.IsKeyDown(MOIS.KeyCode.KC_W))
            {
                cameraMove += mCamera.Direction;
            }

            if (mKeyboard.IsKeyDown(MOIS.KeyCode.KC_S))
            {
                cameraMove -= mCamera.Direction;
            }

            if (mKeyboard.IsKeyDown(MOIS.KeyCode.KC_A))
            {
                cameraMove -= mCamera.Right;
            }

            if (mKeyboard.IsKeyDown(MOIS.KeyCode.KC_D))
            {
                cameraMove += mCamera.Right;
            }

            if (mKeyboard.IsKeyDown(MOIS.KeyCode.KC_Q))
            {
                cameraMove += mCamera.Up;
            }

            if (mKeyboard.IsKeyDown(MOIS.KeyCode.KC_E))
            {
                cameraMove -= mCamera.Up;
            }


            cameraMove.Normalise();
            cameraMove *= 150; // Natural speed is 150 units/sec.

            if (cameraMove != Vector3.ZERO)
            {
                mCamera.Move(cameraMove * evt.timeSinceLastFrame);
            }

            mCamera.Yaw(new Degree(-mMouse.MouseState.X.rel));
            mCamera.Pitch(new Degree(-mMouse.MouseState.Y.rel));

            mTimer -= evt.timeSinceLastFrame;
            return(mTimer > 0);
        }
Exemple #4
0
        /// <summary>
        /// This method set the reaction to each key stroke
        /// </summary>
        /// <param name="evt">Can be used to tune the reaction timings</param>
        /// <returns></returns>
        public bool ProcessInput(FrameEvent evt)
        {
            Vector3 displacements = Vector3.ZERO;
            Vector3 angles        = Vector3.ZERO;

            mKeyboard.Capture();
            mMouse.Capture();

            if (mKeyboard.IsKeyDown(MOIS.KeyCode.KC_A))
            {
                displacements += new Vector3(-0.1f, 0, 0);
            }

            if (mKeyboard.IsKeyDown(MOIS.KeyCode.KC_D))
            {
                displacements += new Vector3(0.1f, 0, 0);
            }

            if (mKeyboard.IsKeyDown(MOIS.KeyCode.KC_W))
            {
                displacements += new Vector3(0, 0, -0.1f);
            }

            if (mKeyboard.IsKeyDown(MOIS.KeyCode.KC_S))
            {
                displacements += new Vector3(0, 0, 0.1f);
            }

            if (mKeyboard.IsKeyDown(MOIS.KeyCode.KC_Q))
            {
                angles += .1f;
            }

            if (mKeyboard.IsKeyDown(MOIS.KeyCode.KC_E))
            {
                angles -= .1f;
            }

            //character.Move(displacements);
            //character.xRotate(angles);

            if (mMouse.MouseState.ButtonDown(MOIS.MouseButtonID.MB_Left))
            {
                angles.z = -mMouse.MouseState.X.rel;
            }
            if (mMouse.MouseState.ButtonDown(MOIS.MouseButtonID.MB_Right))
            {
                angles.x = -mMouse.MouseState.Y.rel;
            }
            //playerController.Rotate(angles);
            return(true);
        }
        public bool Update(MOIS.Keyboard input)
        {
            if (input.IsKeyDown(keyCode))
            {
                if (!keyPressed)
                {
                    keyPressed = true;
                    ToggleCompositor();
                    debugText = compositorName + " " + (compositorIsOn ? "Enabled" : "Disabled");
                    return(true);
                }
            }
            else
            {
                keyPressed = false;
            }

            return(false);
        }
Exemple #6
0
        protected virtual void HandleInput(FrameEvent evt)
        {
            // Move about 100 units per second,
            float moveScale = camSpeed * evt.timeSinceLastFrame;
            // Take about 10 seconds for full rotation
            Degree rotScale = rotateSpeed * evt.timeSinceLastFrame;

            Vector3 translateVector = Vector3.ZERO;


            // set the scaling of camera motion
            Degree scaleRotate = rotateSpeed * evt.timeSinceLastFrame;

            Vector3 camVelocity = Vector3.ZERO;

            inputKeyboard.Capture();

            if (inputKeyboard.IsKeyDown(MOIS.KeyCode.KC_ESCAPE))
            {
                // stop rendering loop
                shutDown = true;
            }

            if (inputKeyboard.IsKeyDown(MOIS.KeyCode.KC_A))
            {
                translateVector.x = -moveScale;
            }

            if (inputKeyboard.IsKeyDown(MOIS.KeyCode.KC_D))
            {
                translateVector.x = moveScale;
            }

            if (inputKeyboard.IsKeyDown(MOIS.KeyCode.KC_W))
            {
                translateVector.z = -moveScale;
            }

            if (inputKeyboard.IsKeyDown(MOIS.KeyCode.KC_S))
            {
                translateVector.z = moveScale;
            }

            if (inputKeyboard.IsKeyDown(MOIS.KeyCode.KC_LEFT))
            {
                camera.Yaw(scaleRotate);
            }

            if (inputKeyboard.IsKeyDown(MOIS.KeyCode.KC_RIGHT))
            {
                camera.Yaw(-scaleRotate);
            }

            if (inputKeyboard.IsKeyDown(MOIS.KeyCode.KC_UP))
            {
                camera.Pitch(scaleRotate);
            }

            if (inputKeyboard.IsKeyDown(MOIS.KeyCode.KC_DOWN))
            {
                camera.Pitch(-scaleRotate);
            }

            // subtract the time since last frame to delay specific key presses
            toggleDelay -= evt.timeSinceLastFrame;

            // toggle rendering mode
            if (inputKeyboard.IsKeyDown(MOIS.KeyCode.KC_R) && toggleDelay < 0)
            {
                if (camera.PolygonMode == PolygonMode.PM_POINTS)
                {
                    camera.PolygonMode = PolygonMode.PM_SOLID;
                }
                else if (camera.PolygonMode == PolygonMode.PM_SOLID)
                {
                    camera.PolygonMode = PolygonMode.PM_WIREFRAME;
                }
                else
                {
                    camera.PolygonMode = PolygonMode.PM_POINTS;
                }

                Console.WriteLine("Rendering mode changed to '{0}'.", camera.PolygonMode);

                toggleDelay = 1;
            }

            if (inputKeyboard.IsKeyDown(MOIS.KeyCode.KC_T) && toggleDelay < 0)
            {
                // toggle the texture settings
                switch (filtering)
                {
                case TextureFilterOptions.TFO_BILINEAR:
                    filtering = TextureFilterOptions.TFO_TRILINEAR;
                    aniso     = 1;
                    break;

                case TextureFilterOptions.TFO_TRILINEAR:
                    filtering = TextureFilterOptions.TFO_ANISOTROPIC;
                    aniso     = 8;
                    break;

                case TextureFilterOptions.TFO_ANISOTROPIC:
                    filtering = TextureFilterOptions.TFO_BILINEAR;
                    aniso     = 1;
                    break;
                }

                Console.WriteLine("Texture Filtering changed to '{0}'.", filtering);

                // set the new default
                MaterialManager.Singleton.SetDefaultTextureFiltering(filtering);
                MaterialManager.Singleton.DefaultAnisotropy = aniso;

                toggleDelay = 1;
            }

            if (inputKeyboard.IsKeyDown(MOIS.KeyCode.KC_SYSRQ))
            {
                string[] temp     = System.IO.Directory.GetFiles(Environment.CurrentDirectory, "screenshot*.jpg");
                string   fileName = string.Format("screenshot{0}.jpg", temp.Length + 1);

                TakeScreenshot(fileName);

                // show briefly on the screen
                mDebugText = string.Format("Wrote screenshot '{0}'.", fileName);

                // show for 2 seconds
                debugTextDelay = 2.0f;
            }

            if (inputKeyboard.IsKeyDown(MOIS.KeyCode.KC_B))
            {
                sceneMgr.ShowBoundingBoxes = !sceneMgr.ShowBoundingBoxes;
            }

            if (inputKeyboard.IsKeyDown(MOIS.KeyCode.KC_F))
            {
                // hide all overlays, includes ones besides the debug overlay
                viewport.OverlaysEnabled = !viewport.OverlaysEnabled;
            }

            inputMouse.Capture();
            MOIS.MouseState_NativePtr mouseState = inputMouse.MouseState;

            if (!mouseState.ButtonDown(MOIS.MouseButtonID.MB_Left))
            {
                Degree cameraYaw   = -mouseState.X.rel * .13f;
                Degree cameraPitch = -mouseState.Y.rel * .13f;

                camera.Yaw(cameraYaw);
                camera.Pitch(cameraPitch);
            }
            else
            {
                translateVector.x += mouseState.X.rel * 0.13f;
            }


            // move the camera based on the accumulated movement vector
            camera.MoveRelative(translateVector);

            // update performance stats once per second
            if (statDelay < 0.0f && showDebugOverlay)
            {
                UpdateStats();
                statDelay = 1.0f;
            }
            else
            {
                statDelay -= evt.timeSinceLastFrame;
            }

            // turn off debug text when delay ends
            if (debugTextDelay < 0.0f)
            {
                debugTextDelay = 0.0f;
                mDebugText     = "";
            }
            else if (debugTextDelay > 0.0f)
            {
                debugTextDelay -= evt.timeSinceLastFrame;
            }
        }
Exemple #7
0
        /// <summary>
        /// This method set the reaction to each key stroke
        /// The ProcessInput method should not call the functions to move or rotate the player,
        /// it should just set the values of how much movement or rotation the player should do.
        /// </summary>
        /// <param name="evt">Can be used to tune the reaction timings</param>
        /// <returns></returns>
        public bool ProcessInput(FrameEvent evt)
        {
            Vector3 displacements = Vector3.ZERO;
            Vector3 angles        = Vector3.ZERO;

            mKeyboard.Capture();
            mMouse.Capture();

            if (mKeyboard.IsKeyDown(MOIS.KeyCode.KC_A))
            {
                playerController.Left = true;
            }
            else
            {
                playerController.Left = false;
            }

            if (mKeyboard.IsKeyDown(MOIS.KeyCode.KC_D))
            {
                playerController.Right = true;
            }
            else
            {
                playerController.Right = false;
            }

            if (mKeyboard.IsKeyDown(MOIS.KeyCode.KC_W))
            {
                playerController.Forward = true;
            }
            else
            {
                playerController.Forward = false;
            }


            if (mKeyboard.IsKeyDown(MOIS.KeyCode.KC_S))
            {
                playerController.Backward = true;
            }
            else
            {
                playerController.Backward = false;
            }

            if (mKeyboard.IsKeyDown(MOIS.KeyCode.KC_SPACE))
            {
                playerController.Shoot = true;
            }
            else
            {
                playerController.Shoot = false;
            }

            if (mKeyboard.IsKeyDown(MOIS.KeyCode.KC_LSHIFT))
            {
                playerController.Accellerate = true;
            }
            else
            {
                playerController.Accellerate = false;
            }

            if (mMouse.MouseState.ButtonDown(MOIS.MouseButtonID.MB_Left))
            {
                angles.y /*z*/ = -mMouse.MouseState.X.rel;   //change angles.z into angles.y
            }
            if (mMouse.MouseState.ButtonDown(MOIS.MouseButtonID.MB_Right))
            {
                angles.y /*x*/ = -mMouse.MouseState.Y.rel; //change angles.z into angles.y
            }
            playerController.Angles = angles;              //the pass the angle vector to the PlayerController as playerController.Angles = angles after the if statements for the mouse
            return(true);
        }
Exemple #8
0
        /// <summary>
        /// This method set the reaction to each key stroke
        /// </summary>
        /// <param name="evt">Can be used to tune the reaction timings</param>
        /// <returns></returns>
        public bool ProcessInput(FrameEvent evt)
        {
            //Vector3 displacements = Vector3.ZERO;
            Vector3 angles = Vector3.ZERO;

            mKeyboard.Capture();
            mMouse.Capture();

            if (mKeyboard.IsKeyDown(MOIS.KeyCode.KC_A))
            {
                playerController.Left = true;
            }
            else
            {
                playerController.Left = false;
            }

            if (mKeyboard.IsKeyDown(MOIS.KeyCode.KC_D))
            {
                playerController.Right = true;
            }
            else
            {
                playerController.Right = false;
            }

            if (mKeyboard.IsKeyDown(MOIS.KeyCode.KC_W))
            {
                playerController.Forward = true;
            }
            else
            {
                playerController.Forward = false;
            }
            if (mKeyboard.IsKeyDown(MOIS.KeyCode.KC_S))
            {
                playerController.Backward = true;
            }
            else
            {
                playerController.Backward = false;
            }
            if (mKeyboard.IsKeyDown(MOIS.KeyCode.KC_SPACE))
            {
                playerController.Up = true;
            }
            else
            {
                playerController.Up = false;
            }
            //Console.WriteLine(mKeyboard.IsKeyDown(MOIS.KeyCode.KC_A));
            // player.Move(displacements);

            //  if (mMouse.MouseState.ButtonDown(MOIS.MouseButtonID.MB_Left))
            //  {
            angles += -mMouse.MouseState.X.rel;
            playerController.Character.Model.GameNode.Yaw(angles.y * 0.005f);
            //Console.WriteLine(angles.y);

            //  }
            // if (mMouse.MouseState.ButtonDown(MOIS.MouseButtonID.MB_Right))
            // {
            //    angles.x = -mMouse.MouseState.Y.rel;
            //}
            //player.Rotate(angles/10);
            //playerController.Update(evt);
            return(true);
        }
Exemple #9
0
        public bool ProcessInput(FrameEvent ect)
        {
            Vector3 displacements = Vector3.ZERO;
            Vector3 angles        = Vector3.ZERO;

            mKeyboard.Capture();
            mMouse.Capture();

            if (mKeyboard.IsKeyDown(MOIS.KeyCode.KC_A))
            {
                playerController.Left = true;
                displacements        += new Vector3(-0.1f, 0, 0);
            }
            else
            {
                playerController.Left = false;
            }
            if (mKeyboard.IsKeyDown(MOIS.KeyCode.KC_D))
            {
                playerController.Right = true;
                displacements         += new Vector3(0.1f, 0, 0);
            }
            else
            {
                playerController.Right = false;
            }
            if (mKeyboard.IsKeyDown(MOIS.KeyCode.KC_W))
            {
                playerController.Forward = true;
                displacements           += new Vector3(0, 0, 0.1f);
            }
            else
            {
                playerController.Forward = false;
            }
            if (mKeyboard.IsKeyDown(MOIS.KeyCode.KC_S))
            {
                playerController.Backward = true;
                displacements            += new Vector3(0, 0, -0.1f);
            }
            else
            {
                playerController.Backward = false;
            }
            if (mKeyboard.IsKeyDown(MOIS.KeyCode.KC_SPACE))
            {
                playerController.Shoot = true;
            }
            else
            {
                playerController.Shoot = false;
            }

            if (mKeyboard.IsKeyDown(MOIS.KeyCode.KC_LSHIFT))
            {
                playerController.Accellerate = true;
            }
            else
            {
                playerController.Accellerate = false;
            }
            //if (mKeyboard.IsKeyDown(MOIS.KeyCode.KC_E)) // Swap guns here
            //{
            //    playerController.
            //}

            //player.Move(displacements); //UNCOMMENT THIS!!


            //mMouse.MouseMoved .MouseMoved(MOIS.MouseButtonID.MB_Left)
            if (mMouse.MouseState.ButtonDown(MOIS.MouseButtonID.MB_Left))
            {
                angles.y = mMouse.MouseState.X.rel;
            }
            if (mMouse.MouseState.ButtonDown(MOIS.MouseButtonID.MB_Right))
            {
                angles.x = mMouse.MouseState.Y.rel;
            }
            playerController.Angles = angles;

            //playerController.Rotate(angles); UNCOMMENT THIS!!
            return(true);
        }