protected Vector4 getJoystickPointerRect(Window joystickWindow, int axisNo)
        {
            float value = FrameWorkStaticHelper.GetJoystickVector(joysticks, false, axisNo);
            //vvector.y *= EngineConfig.InverseKeys ? -1.0f : 1.0f;

            float pointerSize = joystickWindow.h;

            Vector4 pos = new Vector4(joystickWindow.x, joystickWindow.y, pointerSize, pointerSize);

            pos.x += joystickWindow.w * 0.5f + (joystickWindow.w * 0.5f - pointerSize * 0.5f) * value - pointerSize * 0.5f;
            pos.y += joystickWindow.h * 0.5f - pointerSize * 0.5f;

            return(pos);
        }
Example #2
0
        protected virtual void OnUpdateModel(FrameEvent evt)
        {
            mouseDiff = mousePos - lastMousePos;


            Degree scaleRotate = rotateSpeed * evt.timeSinceLastFrame;


            inputKeyboard.Capture();
            if (inputJoysticks != null)
            {
                foreach (JoyStick j in inputJoysticks)
                {
                    j.Capture();
                }
            }

            /*
             * if (inputKeyboard.IsKeyDown(KeyMap.Instance.Left))
             * {
             *     camera.Yaw(scaleRotate);
             * }
             *
             * if (inputKeyboard.IsKeyDown(KeyMap.Instance.Right))
             * {
             *     camera.Yaw(-scaleRotate);
             * }
             *
             * if (inputKeyboard.IsKeyDown(KeyMap.Instance.Up))
             * {
             *     camera.Pitch(scaleRotate);
             * }
             *
             * if (inputKeyboard.IsKeyDown(KeyMap.Instance.Down))
             * {
             *     camera.Pitch(-scaleRotate);
             * }*/

            if (inputJoysticks != null)
            {
                Vector2 joyVector = FrameWorkStaticHelper.GetJoystickVector(inputJoysticks, true);
                if (joyVector.x != 0)
                {
                    camera.Yaw(-joyVector.x * scaleRotate);
                }
                if (joyVector.y != 0)
                {
                    camera.Pitch(joyVector.y * scaleRotate);
                }
            }



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

            // toggle rendering mode
            if (inputKeyboard.IsKeyDown(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(KeyCode.KC_SYSRQ))
            {
                string[] temp     = Directory.GetFiles(Environment.CurrentDirectory, "wscreenshot*.jpg");
                string   fileName = string.Format("wscreenshot{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(KeyCode.KC_B))
            {
                sceneMgr.ShowBoundingBoxes = !sceneMgr.ShowBoundingBoxes;
            }

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



            // turn off debug text when delay ends
            if (debugTextDelay < 0.0f)
            {
                debugTextDelay = 0.0f;
                mDebugText     = "";
            }
            else if (debugTextDelay > 0.0f)
            {
                debugTextDelay -= evt.timeSinceLastFrame;
            }

            //  inputMouse.Capture();
            HandleCameraInput(inputKeyboard, null, inputJoysticks, evt, camera, null, null);
        }