Пример #1
0
 void end_camera_action()
 {
     if (bInAction)
     {
         rcInfo    = null;
         bInAction = false;
     }
     bUsingMouse = bUsingGamepad = false;
 }
Пример #2
0
        public void DoCameraControl(FScene scene, fCamera mainCamera, InputState input)
        {
            if (bInAction == false)
            {
                if (Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1) || Input.GetMouseButtonDown(2))
                {
                    curPos2D  = new Vector2(0, 0);
                    rcInfo    = new CameraManipulator.RateControlInfo(curPos2D);
                    bInAction = bUsingMouse = true;
                }
                else if (InputExtension.Get.GamepadRightShoulder.Down || InputExtension.Get.GamepadLeftShoulder.Down)
                {
                    curPos2D  = secondPos2D = new Vector2(0, 0);
                    rcInfo    = new CameraManipulator.RateControlInfo(curPos2D);
                    rcInfo2   = new CameraManipulator.RateControlInfo(secondPos2D);
                    bInAction = bUsingGamepad = true;
                }
            }

            if (bInAction && bUsingMouse)
            {
                Vector2f mouseDelta = InputExtension.Get.Mouse.PositionDelta;
                curPos2D.x += mouseDelta.x;
                curPos2D.y += mouseDelta.y;

                if (Input.GetMouseButton(0))
                {
                    mainCamera.Manipulator().SceneRateControlledFly(scene, mainCamera, curPos2D, rcInfo);
                }
                else if (Input.GetMouseButton(1))
                {
                    mainCamera.Manipulator().SceneRateControlledZoom(scene, mainCamera, curPos2D, rcInfo);
                }
                else if (Input.GetMouseButton(2))
                {
                    mainCamera.Manipulator().SceneRateControlledEgogentricPan(scene, mainCamera, curPos2D, rcInfo);
                }
            }


            if (bInAction && bUsingGamepad)
            {
                Vector2f stick1 = InputExtension.Get.GamepadLeftStick.Position;
                Vector2f stick2 = InputExtension.Get.GamepadRightStick.Position;
                float    dx     = stick1.x;
                float    dy     = stick1.y;
                float    dx2    = stick2.x;
                float    dy2    = stick2.y;
                curPos2D.x    += dx;
                curPos2D.y    += dy;
                secondPos2D.x += dx2;
                secondPos2D.y += dy2;
                float use_t = 3.0f;     // 5 == hard stop, 1 == bit too soft
                curPos2D.x    = MathUtil.SignedClamp(curPos2D.x, rcInfo.rampUpRadius);
                curPos2D.x    = Mathf.Lerp(curPos2D.x, 0, use_t * Time.deltaTime);
                curPos2D.y    = MathUtil.SignedClamp(curPos2D.y, rcInfo.rampUpRadius);
                curPos2D.y    = Mathf.Lerp(curPos2D.y, 0, use_t * Time.deltaTime);
                secondPos2D.x = MathUtil.SignedClamp(secondPos2D.x, rcInfo.rampUpRadius);
                secondPos2D.x = Mathf.Lerp(secondPos2D.x, 0, use_t * Time.deltaTime);
                secondPos2D.y = MathUtil.SignedClamp(secondPos2D.y, rcInfo.rampUpRadius);
                secondPos2D.y = Mathf.Lerp(secondPos2D.y, 0, use_t * Time.deltaTime);

                if (InputExtension.Get.GamepadRightShoulder.Down)
                {
                    mainCamera.Manipulator().SceneRateControlledZoom(scene, mainCamera, curPos2D, rcInfo);
                    secondPos2D[0] = 0;
                    mainCamera.Manipulator().SceneRateControlledEgogentricPan(scene, mainCamera, secondPos2D, rcInfo2);
                }
                else if (InputExtension.Get.GamepadLeftShoulder.Down)
                {
                    mainCamera.Manipulator().SceneRateControlledFly(scene, mainCamera, curPos2D, rcInfo);
                    mainCamera.Manipulator().SceneRateControlledEgogentricPan(scene, mainCamera, secondPos2D, rcInfo2);
                }
            }
        }