Пример #1
0
 public void cameraComeBack( )
 {
     if (camera_state == CAMERA_STATE.CAMERA_STATE_SCROLL)
     {
         camera_state = CAMERA_STATE.CAMERA_STATE_COME_BACK;
     }
 }
Пример #2
0
        public override void onResume()
        {
            base.onResume();
            State = CAMERA_STATE.IDLE;

            startBackgroundThread();

            // initialize SCamera
            mSCamera = new SCamera();
            try
            {
                mSCamera.initialize(this);
            }
            catch (SsdkUnsupportedException)
            {
                showAlertDialog("Fail to initialize SCamera.", true);
                return;
            }

            OrientationListener = true;

            if (!checkRequiredFeatures())
            {
                return;
            }

            createUI();
            openCamera();
        }
Пример #3
0
    // public Vector3 GetReleaseUpPositionInWorld()
    // {
    //  return upPositionInWorldSpace;
    // }

    public void ResetCameraParams()
    {
        DragCameraX = 0;
        DragCameraY = 0;

        deltaX = deltaZ = 0;
        isDown = isPressed = isReleased = touch2FingerReleased = false;

#if UNITY_EDITOR || UNITY_PLAYER || UNITY_STANDALONE_WIN || UNITY_METRO
        deltaX_mouse             = deltaY_mouse = deltaZ_mouse = 0;
        touch2FingerDeltaX_mouse = touch2FingerDeltaY_mouse = 0;
        isDown_mouse             = isPressed_mouse = isReleased_mouse = touch2FingerReleased_mouse = false;
#endif

#if UNITY_IPHONE || UNITY_ANDROID || UNITY_WP8 || UNITY_METRO
        deltaX_touch             = deltaY_touch = deltaZ_touch = 0;
        touch2FingerDeltaX_touch = touch2FingerDeltaY_touch = 0;
        isDown_touch             = isPressed_touch = isReleased_touch = touch2FingerReleased_touch = false;

        touch3FingerDeltaX   = 0;
        touch3FingerDeltaY   = 0;
        touch3FingerReleased = false;
#endif
        mCameraState = CAMERA_STATE.eIdle;
    }
Пример #4
0
        public bool CheckState(CAMERA_STATE desiredState)
        {
            // Returns True if camera is in desired_state.
            var camStatus = GetCamStatus();
            var state     = (CAMERA_STATE)camStatus["state"];

            return(state == desiredState);
        }
Пример #5
0
        public void ExpectState(CAMERA_STATE anticipatedState)
        {
            var camStatus = GetCamStatus();
            var state     = (CAMERA_STATE)camStatus["state"];

            if (state != anticipatedState)
            {
                Console.WriteLine($"Camera not in expected state: anticipated {GetTextState(anticipatedState)} != {GetTextState(state)}");
                Environment.Exit(1);
            }
        }
 /// <summary>
 /// Starts a preview.
 /// </summary>
 private void startPreview()
 {
     try
     {
         mSCameraSession.setRepeatingRequest(mPreviewBuilder.build(), mSessionCaptureCallback, mBackgroundHandler);
         mState = CAMERA_STATE.PREVIEW;
     }
     catch (CameraAccessException)
     {
         showAlertDialog("Fail to start preview.", true);
     }
 }
Пример #7
0
 void Start()
 {
     m_CharacterTargetRot = gameObject.transform.rotation;
     m_CameraTargetRot    = Camera.main.transform.rotation;
     smooth      = false;
     cameraState = CAMERA_STATE.FREE_CAM;
     playerMove  = gameObject.GetComponent <PlayerMove> ();
     inputState  = CURRENT_INPUT.NONE;
     deltaX      = 0f;
     deltaY      = 0f;
     Application.targetFrameRate = 90;
 }
Пример #8
0
 /// <summary>
 /// Starts a preview.
 /// </summary>
 private void startPreview()
 {
     try
     {
         // Starts displaying the preview.
         mSCameraSession.setRepeatingBurst(mRepeatingList, mSessionCaptureCallback, mBackgroundHandler);
         State = CAMERA_STATE.PREVIEW;
     }
     catch (CameraAccessException)
     {
         showAlertDialog("Fail to start preview.", true);
     }
 }
Пример #9
0
    void come_back( )
    {
        Vector3 c_to_p = _target.transform.position - _camera.transform.position;

        if (c_to_p.x > DRAW_RANGE)
        {
            _camera.transform.position = new Vector3(
                _camera.transform.position.x + ( float )0.5,
                _camera.transform.position.y,
                _camera.transform.position.z
                );
        }
        else if (c_to_p.x < -DRAW_RANGE)
        {
            _camera.transform.position = new Vector3(
                _camera.transform.position.x - ( float )0.5,
                _camera.transform.position.y,
                _camera.transform.position.z
                );
        }
        if (c_to_p.y > DRAW_RANGE)
        {
            _camera.transform.position = new Vector3(
                _camera.transform.position.x,
                _camera.transform.position.y + ( float )0.5,
                _camera.transform.position.z
                );
        }
        else if (c_to_p.y < -DRAW_RANGE)
        {
            _camera.transform.position = new Vector3(
                _camera.transform.position.x,
                _camera.transform.position.y - ( float )0.5,
                _camera.transform.position.z
                );
        }

        Vector3 m_to_c = _camera.transform.position - _map.transform.position;
        bool    correct_x = c_to_p.x <DRAW_RANGE && c_to_p.x> -DRAW_RANGE;
        bool    correct_y = c_to_p.y <DRAW_RANGE && c_to_p.y> -DRAW_RANGE;
        bool    border_x = m_to_c.x <rec_x / 2 || m_to_c.x> _map_size.x - rec_x / 2;
        bool    border_y = m_to_c.y <rec_y / 2 || m_to_c.y> _map_size.y - rec_y / 2;

        if ((correct_x && correct_y) || (border_x && correct_y) || (correct_x && border_y))
        {
            camera_state = CAMERA_STATE.CAMERA_STATE_NORMAL;
            before_pos   = new Vector3(0, 0, 0);
        }
    }
Пример #10
0
        private void recordVideo()
        {
            lock (this)
            {
                State = CAMERA_STATE.RECORD_VIDEO;

                // UI
                mRecordButton.Text    = [email protected]_title_stop;
                mVideoSpinner.Enabled = false;

                // Start recording
                mMediaRecorder.start();

                mRecordingStartTime = DateTimeHelperClass.CurrentUnixTimeMillis();
            }
        }
Пример #11
0
        public void WaitForTransition(string label, CAMERA_STATE currentState, int timeout)
        {
            Console.WriteLine($"    {label}");

            while (CheckState(currentState) && timeout > 0)
            {
                timeout--;
                Console.WriteLine($"        {GetStatusString()}");
                Thread.Sleep(1000);
            }

            var camStatus = GetCamStatus();
            var state     = (CAMERA_STATE)camStatus["state"];

            Console.WriteLine($"        Transition complete - new state: {GetTextState(state)}");
        }
        /// <summary>
        /// Starts AF process by triggering <seealso cref="com.samsung.android.sdk.camera.SCaptureRequest#CONTROL_AF_TRIGGER_START"/>.
        /// </summary>
        private void lockAF()
        {
            try
            {
                mState        = CAMERA_STATE.WAIT_AF;
                isAFTriggered = false;

                mPreviewBuilder.set(SCaptureRequest.CONTROL_AF_TRIGGER, SCaptureRequest.CONTROL_AF_TRIGGER_START);
                mSCameraSession.capture(mPreviewBuilder.build(), new CaptureCallbackAnonymousInnerClassHelper(this), mBackgroundHandler);
                mPreviewBuilder.set(SCaptureRequest.CONTROL_AF_TRIGGER, SCaptureRequest.CONTROL_AF_TRIGGER_IDLE);
            }
            catch (CameraAccessException)
            {
                showAlertDialog("Fail to trigger AF", true);
            }
        }
        /// <summary>
        /// Starts taking picture.
        /// </summary>
        private void startTakePicture()
        {
            runOnUiThread(() =>
            {
                if (null != mPictureButton)
                {
                    mPictureButton.Text = [email protected]_title_stop;
                }
                initPanoramaUI();
            });

            mPanoramaData.clearData();
            mProcessor.start();

            mState = CAMERA_STATE.TAKE_PICTURE;
        }
        /// <summary>
        /// Starts AE/AWB lock by request <seealso cref="com.samsung.android.sdk.camera.SCaptureRequest#CONTROL_AE_LOCK"/> and <seealso cref="com.samsung.android.sdk.camera.SCaptureRequest#CONTROL_AWB_LOCK"/>.
        /// </summary>
        private void lockAEAWB()
        {
            try
            {
                mState = CAMERA_STATE.WAIT_AEAWB_LOCK;

                mPreviewBuilder.set(SCaptureRequest.CONTROL_AE_LOCK, true);
                mPreviewBuilder.set(SCaptureRequest.CONTROL_AWB_LOCK, true);
                mSCameraSession.setRepeatingRequest(mPreviewBuilder.build(), mSessionCaptureCallback, mBackgroundHandler);

                isAEAWBLocked = true;
            }
            catch (CameraAccessException)
            {
                showAlertDialog("Fail to lock AE/AWB", true);
            }
        }
Пример #15
0
        public override void onPause()
        {
            if (State == CAMERA_STATE.RECORD_VIDEO)
            {
                stopRecordVideo(true);
            }

            State = CAMERA_STATE.CLOSING;

            OrientationListener = false;

            stopBackgroundThread();

            closeCamera();

            base.onPause();
        }
Пример #16
0
        //Update() is called every frame (as often as possible)
        private void Update()
        {
            //Toggle Follow Target
            if (Input.GetKeyDown(KeyCode.F) && Target)
            {
                State = (State == CAMERA_STATE.Follow) ? CAMERA_STATE.Scroll : CAMERA_STATE.Follow;
            }

            if (State == CAMERA_STATE.Follow && Target != null)
            {
            }
            else if (State == CAMERA_STATE.Scroll)
            {
                //Scroll Left/Right
                if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow))
                {
                    Camera.main.transform.Translate(Vector3.right * -ScrollSpeed.x);
                }
                else if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow))
                {
                    Camera.main.transform.Translate(Vector3.right * ScrollSpeed.x);
                }

                //Scroll Up/Down
                if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow))
                {
                    Camera.main.transform.Translate(Vector3.up * ScrollSpeed.y);
                }
                else if (Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow))
                {
                    Camera.main.transform.Translate(Vector3.up * -ScrollSpeed.y);
                }

                var scrollWheelDelta = Input.GetAxis("Mouse ScrollWheel");
                if (scrollWheelDelta > 0f)
                {
                    Camera.main.transform.Translate(Vector3.forward * ScrollSpeed.z);
                }
                else if (scrollWheelDelta < 0f)
                {
                    Camera.main.transform.Translate(Vector3.forward * -ScrollSpeed.z);
                }
            }
        }
Пример #17
0
        private void MultishotCaptureVideo(CAMERA_STATE PostCaptureExpectedState, bool CancelDuringPostTriggerFill = false, string baseFilename = null)
        {
            // Example showing full pre-trigger buffer fill, trigger, save video capture process
            api.ExpectRunningState();
            api.WaitForTransition("Waiting for pre-trigger buffer to fill", CAMERA_STATE.RUNNING, 10);
            api.ExpectState(CAMERA_STATE.RUNNING_PRETRIGGER_FULL);

            this.TriggerCamera(api, "Camera triggered, filling post-trigger buffer", baseFilename);
            Console.WriteLine($"    Percentage pre-trigger buffer filled before trigger: {api.GetPretriggerFillLevel()}");

            if (CancelDuringPostTriggerFill)
            {
                var status = api.Cancel();

                Console.WriteLine($"    Video captured canceled during post trigger fill: {status}");
                Thread.Sleep(1000);
                api.ExpectRunningState();
                return;
            }

            api.WaitForTransition("Waiting for post-trigger buffer to fill", CAMERA_STATE.TRIGGERED, 10);
            api.ExpectState(PostCaptureExpectedState);
        }
Пример #18
0
    // Update is called once per frame
    // all control in building part
    // include:
    //            camera control
    //            building control
    //            farmer control
    //            if input is in UI state, prevent all controls from above

    void Update()
    {
        float _currTime = Time.realtimeSinceStartup;

        mDeltaTime       = _currTime - mTimeAtLastFrame;
        mTimeAtLastFrame = _currTime;

        deltaX = deltaZ = 0;
        isDown = isPressed = isReleased = touch2FingerReleased = false;

#if UNITY_EDITOR || UNITY_PLAYER || UNITY_STANDALONE_WIN || UNITY_METRO
        deltaX_mouse             = deltaY_mouse = deltaZ_mouse = 0;
        touch2FingerDeltaX_mouse = touch2FingerDeltaY_mouse = 0;
        isDown_mouse             = isPressed_mouse = isReleased_mouse = touch2FingerReleased_mouse = false;
#endif

#if UNITY_IPHONE || UNITY_ANDROID || UNITY_WP8 || UNITY_METRO
        deltaX_touch             = deltaY_touch = deltaZ_touch = 0;
        touch2FingerDeltaX_touch = touch2FingerDeltaY_touch = 0;
        isDown_touch             = isPressed_touch = isReleased_touch = touch2FingerReleased_touch = false;

        touch3FingerDeltaX     = 0;
        touch3FingerDeltaY     = 0;
        touch2FingerDeltaAngle = 0;
#endif

#if UNITY_EDITOR || UNITY_PLAYER || UNITY_STANDALONE_WIN || UNITY_METRO
        // zoom in/out
        deltaY_mouse = Input.GetAxis("Mouse ScrollWheel");

        if (Input.GetKeyDown(KeyCode.PageUp))
        {
            deltaY_mouse = -0.5f;
        }
        if (Input.GetKeyDown(KeyCode.PageDown))
        {
            deltaY_mouse = 0.5f;
        }

        if (Input.GetMouseButtonDown(0))
        {
            currentPosition_mouse = Input.mousePosition;
            downPosition_mouse    = Input.mousePosition;
            touchMoveAway_mouse   = false;
            this.setTouchMoveAway(false);
            isDown_mouse = true;
            //PandaUI.Instance.allowUserInput = false;
        }
        else if (Input.GetMouseButton(0))
        {
            Vector3 deltaMouse = Input.mousePosition - currentPosition_mouse;
            deltaX_mouse          = -deltaMouse.x;
            deltaZ_mouse          = -deltaMouse.y;
            currentPosition_mouse = Input.mousePosition;

            if (Mathf.Abs(downPosition_mouse.x - currentPosition_mouse.x) > MOVE_DELTA ||
                Mathf.Abs(downPosition_mouse.y - currentPosition_mouse.y) > MOVE_DELTA)
            {
                touchMoveAway_mouse = true;
                this.setTouchMoveAway(true);
            }
            isPressed_mouse = true;
        }
        else if (Input.GetMouseButtonUp(0))
        {
            isReleased_mouse      = true;
            releasePosition_mouse = Input.mousePosition;
        }
        else if (Input.GetMouseButtonDown(1))
        {
            currentPosition2_mouse = Input.mousePosition;
            downPosition2_mouse    = Input.mousePosition;
            touchMoveAway2_mouse   = false;
            touch2Finger_mouse     = true;
            //PandaUI.Instance.allowUserInput = false;
        }
        else if (Input.GetMouseButton(1))
        {
            Vector3 deltaMouse = Input.mousePosition - currentPosition2_mouse;
            touch2FingerDeltaX_mouse = deltaMouse.x;
            touch2FingerDeltaY_mouse = deltaMouse.y;
            currentPosition2_mouse   = Input.mousePosition;

            // if (Mathf.Abs(downPosition2_mouse.x - currentPosition2_mouse.x) > MOVE_DELTA ||
            //     Mathf.Abs(downPosition2_mouse.y - currentPosition2_mouse.y) > MOVE_DELTA )
            // {
            //  touchMoveAway2_mouse = true;
            // }
        }
        else if (Input.GetMouseButtonUp(1))
        {
            if (!touchMoveAway2_mouse)
            {
                touch2FingerReleased_mouse = true;
            }
            touch2Finger_mouse = false;
        }
        else if (Input.GetMouseButtonDown(2))
        {
            currentPosition3_mouse = Input.mousePosition;
            downPosition3_mouse    = Input.mousePosition;
            touchMoveAway2_mouse   = false;
            touch2Finger_mouse     = true;
        }
        else if (Input.GetMouseButton(2))
        {
            Vector3 deltaMouse = Input.mousePosition - currentPosition3_mouse;
            touch2FingerDeltaX_mouse = deltaMouse.x;
            touch2FingerDeltaY_mouse = deltaMouse.y;
            currentPosition3_mouse   = Input.mousePosition;
        }
        else if (Input.GetMouseButtonUp(2))
        {
            if (!touchMoveAway2_mouse)
            {
                touch2FingerReleased_mouse = true;
            }
            touch2Finger_mouse = false;
        }
        else
        {
            currentPosition_mouse = Vector3.zero;
            mCameraState          = CAMERA_STATE.eIdle;
            touch2Finger_mouse    = false;
            touchMoveAway_mouse   = false;
            //PandaUI.Instance.allowUserInput = true;
        }
#endif

#if UNITY_EDITOR || UNITY_PLAYER || UNITY_STANDALONE_WIN
        deltaX = deltaX_mouse;
        deltaZ = deltaZ_mouse;

        isDown               = isDown_mouse;
        isPressed            = isPressed_mouse;
        isReleased           = isReleased_mouse;
        touch2FingerReleased = touch2FingerReleased_mouse;

        downPosition    = downPosition_mouse;
        currentPosition = currentPosition_mouse;
        releasePosition = releasePosition_mouse;
        touch2Finger    = touch2Finger_mouse;
#endif

#if (UNITY_IPHONE || UNITY_ANDROID || UNITY_WP8 || UNITY_METRO) && !UNITY_EDITOR
        int fingerCount = Input.touchCount;
        // camera move
        if (fingerCount == 1)
        {
            oldDistance_touch = 0;
            startTouch3Finger = false;

            if (!touch2Finger_touch && !touch3Finger)
            {
                isPressed_touch = true;
                if (Input.GetTouch(0).phase == TouchPhase.Began)
                {
                    touchMoveAway_touch = false;
                    this.setTouchMoveAway(false);
                    downPosition_touch    = Input.GetTouch(0).position;
                    prePosition_touch     = Vector3.zero;
                    currentPosition_touch = downPosition_touch;
                    detailPosition_touch  = Vector3.zero;
                    isDown_touch          = true;
                    isPressed_touch       = false;
                    // if(ReposHandlerX && ReposHandlerX.ReposNow){ReposHandlerX.Btn_ReposBuilding_release();}
                    //PandaUI.Instance.allowUserInput = false;
                }

                if (Input.GetTouch(0).phase == TouchPhase.Moved)
                {
                    deltaX_touch          = -Input.GetTouch(0).position.x + currentPosition_touch.x;
                    deltaZ_touch          = -Input.GetTouch(0).position.y + currentPosition_touch.y;
                    prePosition_touch     = currentPosition_touch;
                    currentPosition_touch = Input.GetTouch(0).position;
                    detailPosition_touch  = currentPosition_touch - prePosition_touch;

                    if (Mathf.Abs(downPosition_touch.x - currentPosition_touch.x) > MOVE_DELTA ||
                        Mathf.Abs(downPosition_touch.y - currentPosition_touch.y) > MOVE_DELTA)
                    {
                        touchMoveAway_touch = true;
                        this.setTouchMoveAway(true);
                    }

                    //print("touch move "+deltaX_touch +" "+deltaZ_touch);
                }

                if (Input.GetTouch(0).phase == TouchPhase.Ended)
                {
                    isReleased_touch      = true;
                    isPressed_touch       = false;
                    releasePosition_touch = Input.GetTouch(0).position;
                    // if(ReposHandlerX && ReposHandlerX.ReposNow){ReposHandlerX.Btn_ReposBuilding_release();}
                }
            }
        }
        // zoom in/out
        else if (fingerCount == 2)
        {
            touch2Finger_touch = true;

            if (touch3Finger)
            {
                touch2Finger_touch = false;
            }
            //print("2 touch move ");

            if (oldDistance_touch == 0)
            {
                touch2StartTime        = _currTime;
                oldDistance_touch      = Vector2.Distance(Input.GetTouch(0).position, Input.GetTouch(1).position);
                prePosition_touch      = Vector3.zero;
                currentPosition_touch  = Input.GetTouch(0).position;
                detailPosition_touch   = Vector3.zero;
                currentPosition2_touch = Input.GetTouch(1).position;
                detailPosition2_touch  = Vector3.zero;
                downPosition_touch     = currentPosition_touch;
                downPosition2_touch    = currentPosition2_touch;
                touchMoveAway2_touch   = false;
            }
            else
            {
                if (Input.GetTouch(0).phase == TouchPhase.Moved || Input.GetTouch(1).phase == TouchPhase.Moved)
                {
                    if (_currTime - touch2StartTime > FINGER_2_JUDGE_TIME)
                    {
                        if (!touchMoveAway2_touch)
                        {
                            if ((Mathf.Abs(downPosition_touch.x - Input.GetTouch(0).position.x) > MOVE_DELTA || Mathf.Abs(downPosition_touch.y - Input.GetTouch(0).position.y) > MOVE_DELTA) ||
                                (Mathf.Abs(downPosition2_touch.x - Input.GetTouch(1).position.x) > MOVE_DELTA || Mathf.Abs(downPosition2_touch.y - Input.GetTouch(1).position.y) > MOVE_DELTA))
                            {
                                touchMoveAway2_touch = true;
                            }
                        }

                        prePosition_touch      = currentPosition_touch;
                        currentPosition_touch  = Input.GetTouch(0).position;
                        detailPosition_touch   = currentPosition_touch - prePosition_touch;
                        prePosition2_touch     = currentPosition2_touch;
                        currentPosition2_touch = Input.GetTouch(1).position;
                        detailPosition2_touch  = currentPosition2_touch - prePosition2_touch;

                        // if (touchMoveAway2_touch)
                        // {
                        //  if (!touch2TypeDecided)
                        //  {
                        //      //judge is room or rotate
                        //      touch2Zooming = false;
                        //      touch2Rotating = false;
                        //      touch2Angleing = false;

                        //      Vector3 newPos1 = Input.GetTouch(0).position;
                        //      Vector3 newPos2 = Input.GetTouch(1).position;

                        //      float angleChange_all = Vector3.Angle(newPos2 - newPos1 , downPosition2_touch - downPosition_touch);
                        //      float distanceChange = Vector3.Distance(newPos2 , newPos1) - Vector3.Distance(downPosition2_touch, downPosition_touch);
                        //      float distanceChangePercent = Mathf.Abs(distanceChange) / Mathf.Abs(Vector3.Distance(downPosition2_touch, downPosition_touch));
                        //      // DebugUtils.LogTouch("angleChange_all "+angleChange_all);

                        //      if (distanceChangePercent >= FINGER_2_JUDGE_ZOOM_DISTANCE_CHANGE || angleChange_all <= FINGER_2_JUDGE_ZOOM_ANGLE_CHANGE) //if is zoom
                        //      {
                        //          float angleChange_cross = Vector3.Angle(newPos2 - downPosition2_touch , newPos1 - downPosition_touch);
                        //          if (angleChange_cross > 60) // if move different direction
                        //          {
                        //              if (distanceChangePercent >= FINGER_2_JUDGE_ZOOM_DISTANCE_CHANGE)
                        //              {
                        //                  touch2Zooming = true;
                        //                  touch2Rotating = false;
                        //                  touch2TypeDecided = true;
                        //                  // DebugUtils.LogTouch("decided touch2Zooming");
                        //              }
                        //              else if (angleChange_all > FINGER_2_JUDGE_ZOOM_ANGLE_CHANGE)
                        //              {
                        //                  touch2Rotating = true;
                        //                  touch2Zooming = false;
                        //                  touch2TypeDecided = true;
                        //                  // DebugUtils.LogTouch("decided touch2Rotate 0");
                        //              }
                        //              else
                        //              {
                        //                  //waiting
                        //              }
                        //          }
                        //          else
                        //          {
                        //              touch2FingerSameDeltaY_touch = (newPos1.y - downPosition_touch.y + newPos2.y - downPosition2_touch.y)/2;
                        //              touch2Rotating = false;
                        //              touch2Angleing = true;
                        //              touch2Zooming = false;
                        //              touch2TypeDecided = true;
                        //              // DebugUtils.LogTouch("decided touch2Rotate 1");
                        //          }

                        //          if (touch2TypeDecided)
                        //          {
                        //              mCameraState = CAMERA_STATE.eIdle;

                        //              prePosition_touch = currentPosition_touch;
                        //              currentPosition_touch = Input.GetTouch(0).position;
                        //              detailPosition_touch = currentPosition_touch - prePosition_touch;
                        //              prePosition2_touch = currentPosition2_touch;
                        //              currentPosition2_touch = Input.GetTouch(1).position;
                        //              detailPosition2_touch = currentPosition2_touch - prePosition2_touch;
                        //          }
                        //      }

                        //      if (angleChange_all > FINGER_2_JUDGE_ZOOM_ANGLE_CHANGE)
                        //      {
                        //          touch2Rotating = true;
                        //          touch2Angleing = false;
                        //          touch2TypeDecided = true;
                        //          // DebugUtils.LogTouch("decided touch2Rotate 3");
                        //          prePosition_touch = currentPosition_touch;
                        //          currentPosition_touch = Input.GetTouch(0).position;
                        //          detailPosition_touch = currentPosition_touch - prePosition_touch;
                        //          prePosition2_touch = currentPosition2_touch;
                        //          currentPosition2_touch = Input.GetTouch(1).position;
                        //          detailPosition2_touch = currentPosition2_touch - prePosition2_touch;
                        //      }

                        //  }
                        //  else
                        //  {
                        //      if (touch2Zooming || mCameraState == CAMERA_STATE.eZooming)
                        //      {
                        //          //mCameraState = CAMERA_STATE.eZooming;
                        //          newDistance_touch = Vector2.Distance(Input.GetTouch(0).position, Input.GetTouch(1).position);
                        //          deltaY_touch = newDistance_touch - oldDistance_touch;
                        //          // DebugUtils.LogTouch("zooming deltaY "+deltaY_touch);
                        //      }

                        //      touch2FingerDeltaAngle = 0f;
                        //      if (touch2Rotating)
                        //      {
                        //          //mCameraState = CAMERA_STATE.eRotating;

                        //          // bool sameSide = false;
                        //          Vector3 newPos1 = Input.GetTouch(0).position;
                        //          Vector3 newPos2 = Input.GetTouch(1).position;

                        //          // float angleChange_cross = Vector3.Angle(newPos2 - currentPosition2_touch , newPos1 - currentPosition_touch);
                        //          // if (angleChange_cross < 90) // if move together at same side
                        //          // {
                        //          //  sameSide = true;

                        //          //  //caculate angels by screen center point
                        //          //  Vector3 midlePoint = new Vector3(SCREEN_WIDTH/2, SCREEN_HEIGHT/2, currentPosition_touch.z);

                        //          //  float angleChange_1 = SignAngle(currentPosition_touch - midlePoint, newPos1 - midlePoint );
                        //          //  float angleChange_2 = SignAngle(currentPosition2_touch - midlePoint, newPos2 - midlePoint );

                        //          //  touch2FingerDeltaAngle = (angleChange_1 + angleChange_2) / 2;
                        //          //  // DebugUtils.LogTouch("1 same touch2FingerDeltaAngle "+touch2FingerDeltaAngle);
                        //          // }

                        //          // //judge by center point of two start point
                        //          // if (!sameSide)
                        //          // {
                        //              Vector3 midlePoint = new Vector3((currentPosition_touch.x + currentPosition2_touch.x)/2,
                        //                  (currentPosition_touch.y + currentPosition2_touch.y)/2,
                        //                  (currentPosition_touch.z + currentPosition2_touch.z)/2);

                        //              float angleChange_1 = SignAngle(currentPosition_touch - midlePoint,  newPos1 - midlePoint);
                        //              float angleChange_2 = SignAngle(currentPosition2_touch - midlePoint,  newPos2 - midlePoint);

                        //              if ( angleChange_1 * angleChange_2 > 0 )
                        //              {
                        //                  // sameSide = true;

                        //                  touch2FingerDeltaAngle = SignAngle(currentPosition2_touch - currentPosition_touch, newPos2 - newPos1);
                        //              //	int direction = touch2FingerDeltaAngle >= 0 ? 1: -1;
                        //              //	touch2FingerDeltaAngle = FINGER_2_ROTATE_SPEED_PER_SECOND * direction * mDeltaTime;

                        //                  // DebugUtils.LogTouch("2 same touch2FingerDeltaAngle "+touch2FingerDeltaAngle);
                        //              }


                        //              if((angleChange_1 == 0 && angleChange_2 != 0) || (angleChange_2 == 0 && angleChange_1 != 0)) //if one finger move, one stop
                        //              {
                        //                  // sameSide = true;
                        //                  if (angleChange_1 == 0)
                        //                      touch2FingerDeltaAngle = SignAngle(currentPosition2_touch - currentPosition_touch, newPos2 - currentPosition_touch);
                        //                  if (angleChange_2 == 0)
                        //                      touch2FingerDeltaAngle = SignAngle(currentPosition_touch - currentPosition2_touch, newPos1 - currentPosition2_touch);

                        //              //	int direction = touch2FingerDeltaAngle >= 0 ? 1: -1;
                        //              //	touch2FingerDeltaAngle = FINGER_2_ROTATE_SPEED_PER_SECOND * direction * mDeltaTime;

                        //                  // DebugUtils.LogTouch("3 one touch one stop touch2FingerDeltaAngle "+touch2FingerDeltaAngle);
                        //              }

                        //              if (angleChange_1 == 0 && angleChange_2 == 0)
                        //              {
                        //                  touch2FingerDeltaAngle = 0;
                        //                  // DebugUtils.LogTouch("2 finger all stop ");
                        //              }

                        //          }

                        //          //still not same direction, useless

                        //          // if (!sameSide)
                        //          // {
                        //          //  // DebugUtils.LogTouch("not same direction, abandon");
                        //          //  touch2FingerDeltaAngle = 0;
                        //          // }
                        //      }

                        //      if(touch2Angleing)
                        //      {
                        //          mCameraState = CAMERA_STATE.eAngle;
                        //      }

                        //      touch2FingerDeltaAngle = -touch2FingerDeltaAngle;

                        //      prePosition_touch = currentPosition_touch;
                        //      currentPosition_touch = Input.GetTouch(0).position;
                        //      detailPosition_touch = currentPosition_touch - prePosition_touch;
                        //      prePosition2_touch = currentPosition2_touch;
                        //      currentPosition2_touch = Input.GetTouch(1).position;
                        //      detailPosition2_touch = currentPosition2_touch - prePosition2_touch;
                        //  }
                        // }
                    }
                }
            }
        }
        else
        {
            //print("no touch move ");
            if (touch2Finger_touch)
            {
                // if (!touchMoveAway2_touch)
                {
                    touch2FingerReleased_touch = true;
                }
            }

            if (touch3Finger)
            {
                if (!touchMoveAway3)
                {
                    touch3FingerReleased = true;
                }
            }

            startTouch3Finger  = false;
            touch2Finger_touch = false;
            touch3Finger       = false;
            this.setTouchMoveAway(false);
            touchMoveAway_touch   = false;
            touchMoveAway2_touch  = false;
            touchMoveAway3        = false;
            touch2TypeDecided     = false;
            touch2Rotating        = false;
            touch2Zooming         = false;
            touch2Angleing        = false;
            oldDistance_touch     = 0;
            currentPosition_touch = Vector3.zero;
            detailPosition_touch  = Vector3.zero;
            prePosition_touch     = Vector3.zero;

            touch3TypeDecided = false;
            touch3Rotating    = false;
            touch3Pitching    = false;

            mCameraState = CAMERA_STATE.eIdle;
            //PandaUI.Instance.allowUserInput = true;
        }
#endif

#if (UNITY_IPHONE || UNITY_ANDROID || UNITY_WP8) && !UNITY_EDITOR
        deltaX = deltaX_touch;
        deltaZ = deltaZ_touch;

        isDown               = isDown_touch;
        isPressed            = isPressed_touch;
        isReleased           = isReleased_touch;
        touch2FingerReleased = touch2FingerReleased_touch;

        downPosition    = downPosition_touch;
        currentPosition = currentPosition_touch;
        releasePosition = releasePosition_touch;
        touch2Finger    = touch2Finger_touch;

        this.setTouchMoveAway(touchMoveAway_touch);
#endif

#if UNITY_METRO
        // Determine isDown from touch OR mouse
        isDown = isDown_touch || isDown_mouse;
        if (isDown_touch)
        {
            downPosition = downPosition_touch;
        }
        else if (isDown_mouse)
        {
            downPosition = downPosition_mouse;
        }

        // Determine touchMoveAway from touch OR mouse
        this.setTouchMoveAway(touchMoveAway_touch || touchMoveAway_mouse);
        if (touchMoveAway_touch)
        {
            deltaX = deltaX_touch;
            deltaZ = deltaZ_touch;
        }
        else if (touchMoveAway_mouse)
        {
            deltaX = deltaX_mouse;
            deltaZ = deltaZ_mouse;
        }

        currentPosition = currentPosition_mouse;
        #if !UNITY_EDITOR
        // Override position with touch position if there were touches.
        if (fingerCount > 0)
        {
            currentPosition = currentPosition_touch;
        }
        #endif

        // Determine isReleased from touch OR mouse
        isReleased = isReleased_touch || isReleased_mouse;
        if (isReleased_touch)
        {
            releasePosition = releasePosition_touch;
        }
        else if (isReleased_mouse)
        {
            releasePosition = releasePosition_mouse;
        }

        // Determine isPressed from touch OR mouse
        isPressed = isPressed_mouse || isPressed_touch;

        touch2Finger         = touch2Finger_mouse || touch2Finger_touch;
        touch2FingerReleased = touch2FingerReleased_mouse || touch2FingerReleased_touch;
#endif
        if (isDown)
        {
            downPositionInScreen     = currentPosition;
            downPositionInWorldSpace = bCamera.transform.position;
            // RaycastHit hit;
            // Ray ray = mCurCamera.ScreenPointToRay (currentPosition);
            //          if (Physics.Raycast (ray, out hit, Mathf.Infinity, 1 << Consts.CAMERA_MOVE_LAYER))
            //          {
            //              downPositionInWorldSpace = hit.point;
            //          }
        }

        // if(UI_Event.sIsEvent)
        // {
        //  UI_Event.sIsEvent = false;
        //  // Debug.Log("is ui event");
        //  return;
        // }


        // if(!ForcsOnUI)
        // {
        //  if(BuildingManager.instance.mCurrentBuildingControl == null && !RoadManager.instance.mInputLock)
        //  {
        //      ControlCamera();
        //  }
        //  if(!RoadManager.instance.mInputLock)
        //              ControlBuilding();
        //  ControlBuildRoadConstruction();
        // }


        // unset wasDragged if we have finished processing isReleased during this update.
        if (isReleased && wasDragged)
        {
            wasDragged = false;
        }

        //Debug.LogError("ccccccccccccccccccccccccccccccc");
    }
Пример #19
0
		public override void onPause()
		{
			State = CAMERA_STATE.CLOSING;

			OrientationListener = false;

			stopBackgroundThread();

			deinitProcessor();
			closeCamera();

			base.onPause();
		}
Пример #20
0
 public static CAMERA_STATE CameraGetState()
 {
     var ret = new CAMERA_STATE();
     ret.x = Mem.ReadFloat(CAMERA_X);
     ret.y = Mem.ReadFloat(CAMERA_Y);
     ret.z = Mem.ReadFloat(CAMERA_Z);
     return ret;
 }
Пример #21
0
		public override void onResume()
		{
			base.onResume();

			State = CAMERA_STATE.IDLE;

			startBackgroundThread();

			// initialize SCamera
			mSCamera = new SCamera();
			try
			{
				mSCamera.initialize(this);
			}
			catch (SsdkUnsupportedException)
			{
				showAlertDialog("Fail to initialize SCamera.", true);
				return;
			}

			OrientationListener = true;

			if (!checkRequiredFeatures())
			{
				return;
			}
			createProcessor();
			createUI();
			openCamera();
		}
Пример #22
0
 public static void CameraSetState(CAMERA_STATE State)
 {
     Mem.WriteFloat(CAMERA_X, State.x);
     Mem.WriteFloat(CAMERA_Y, State.y);
     Mem.WriteFloat(CAMERA_Z, State.z);
 }
Пример #23
0
		public override void onPause()
		{
			State = CAMERA_STATE.CLOSING;

			if (mSettingDialog != null)
			{
				mSettingDialog.dismiss();
				mSettingDialog = null;
			}

			OrientationListener = false;

			stopBackgroundThread();
			closeCamera();

			mSCamera = null;
			base.onPause();
		}
Пример #24
0
    // Update is called once per frame
    void FixedUpdate()
    {
        //リザルト画面で処理されないようにする
        if (SceneManager.GetActiveScene().name == "Main" || SceneManager.GetActiveScene().name == "MatchingRoom")
        {
            if (photonView.isMine)
            {
                //相手からの攻撃(ロケットパンチ)に当たっていない場合に処理
                if (punchHit.PunchHitFlag == false)
                {
                    //カメラの操作用関数
                    CameraOperation();

                    //カメラの状態の切り替え
                    switch (cameraState)
                    {
                    case CAMERA_STATE.NORMAL:    //通常状態のカメラ

                        //カメラの位置をある程度離しておく
                        DistanceToPlayer = 3f;
                        //カメラの位置はプレイヤーを中心に据える
                        SlideDistanceM = 0.0f;

                        //照準モードではないのでターゲットカーソルは非表示にする
                        TargetCursor.gameObject.SetActive(false);

                        //構えのモーションを止めて通常の状態に戻す
                        anim.SetBool("Aim", false);

                        //状態の切り替え
                        //PS4コントローラー操作-------------------------------------------------------
                        if (Input.GetButton("R_Button"))
                        {
                            if (ButtonPushFlag == false)
                            {
                                cameraState    = CAMERA_STATE.AIM;
                                ButtonPushFlag = true;
                            }
                        }
                        else
                        {
                            ButtonPushFlag = false;
                        }
                        //-----------------------------------------------------------------------------

                        //キーボード操作--------------------------------------------------------------
                        if (Input.GetKeyDown(KeyCode.Space))
                        {
                            cameraState = CAMERA_STATE.AIM;
                        }
                        //-----------------------------------------------------------------------------


                        break;

                    case CAMERA_STATE.AIM:    //照準モード

                        //照準を合わせるモードなのでカメラをプレイヤーの近くに移動
                        DistanceToPlayer = 0.0f;
                        //カメラを右に少しずらす
                        SlideDistanceM = 0.1f;

                        //照準モードなのでターゲットカーソルを表示
                        TargetCursor.gameObject.SetActive(true);

                        //構えのモーションを再生
                        anim.SetBool("Aim", true);

                        //状態の切り替え
                        //PS4コントローラー操作-------------------------------------------------------
                        if (Input.GetButton("R_Button"))
                        {
                            if (ButtonPushFlag == false)
                            {
                                cameraState    = CAMERA_STATE.NORMAL;
                                ButtonPushFlag = true;
                            }
                        }
                        else
                        {
                            ButtonPushFlag = false;
                        }
                        //-----------------------------------------------------------------------------

                        //キーボード操作--------------------------------------------------------------
                        if (Input.GetKeyDown(KeyCode.Space))
                        {
                            cameraState = CAMERA_STATE.NORMAL;
                        }
                        //-----------------------------------------------------------------------------

                        break;
                    }
                }

                //カメラの状態がAIMだった場合に処理
                if (cameraState == CAMERA_STATE.AIM)
                {
                    //攻撃を受けたらカメラの状態を通常状態に戻す
                    if (punchHit.PunchHitFlag == true)
                    {
                        cameraState = CAMERA_STATE.NORMAL;
                    }
                }
            }
        }
        else
        {
            if (photonView.isMine)
            {
                cameraTransform = Camera.main.transform;

                //カメラの横回転のための変数
                var rotX = 0.0f;

                //カメラの上下方向変換用の変数
                var rotY   = 0.0f;
                var lookAt = gameObject.transform.position + Vector3.up * HeightM;

                //回転
                cameraTransform.RotateAround(lookAt, Vector3.up, rotX);
                //カメラがプレイヤーの真上や真下にある時にそれ以上回転させないようにする
                if (cameraTransform.forward.y > 0.9f && rotY < 0)
                {
                    rotY = 0;
                }

                if (cameraTransform.forward.y < -0.9f && rotY > 0)
                {
                    rotY = 0;
                }
                cameraTransform.transform.RotateAround(lookAt, cameraTransform.transform.right, rotY);

                //カメラとプレイヤーとの間の距離を調整
                cameraTransform.transform.position = lookAt - cameraTransform.transform.forward * DistanceToPlayer;
                //注視点の設定
                cameraTransform.transform.LookAt(lookAt);
                //カメラを横にずらして中央を開ける
                cameraTransform.transform.position = cameraTransform.transform.position + cameraTransform.transform.right * SlideDistanceM;
            }
        }
    }
 /// <summary>
 /// Stops taking picture.
 /// </summary>
 private void stopTakePicture()
 {
     mState = CAMERA_STATE.PROCESSING;
     mProcessor.stop();
 }
 public void LockCamera()
 {
     _state = CAMERA_STATE.LOCKED;
 }
Пример #27
0
		/// <summary>
		/// Take picture.
		/// </summary>
		private void takePicture()
		{
			if (State == CAMERA_STATE.CLOSING)
			{
				return;
			}

			try
			{
				// Sets orientation
				mCaptureBuilder.set(SCaptureRequest.JPEG_ORIENTATION, JpegOrientation);

				if (mImageFormat == ImageFormat.JPEG)
				{
					mCaptureBuilder.addTarget(mJpegReader.Surface);
				}
				else
				{
					mCaptureBuilder.addTarget(mRawReader.Surface);
				}

				mSCameraSession.capture(mCaptureBuilder.build(), new CaptureCallbackAnonymousInnerClassHelper5(this), mBackgroundHandler);

				if (mImageFormat == ImageFormat.JPEG)
				{
					mCaptureBuilder.removeTarget(mJpegReader.Surface);
				}
				else
				{
					mCaptureBuilder.removeTarget(mRawReader.Surface);
				}

				State = CAMERA_STATE.TAKE_PICTURE;
			}
			catch (CameraAccessException)
			{
				showAlertDialog("Fail to start preview.", true);
			}
		}
Пример #28
0
		private void lockAE()
		{
			try
			{
				mPreviewBuilder.set(SCaptureRequest.CONTROL_AE_LOCK, true);
				mSCameraSession.setRepeatingRequest(mPreviewBuilder.build(), mSessionCaptureCallback, mBackgroundHandler);
				State = CAMERA_STATE.WAIT_AE_LOCK;
			}
			catch (CameraAccessException)
			{
				showAlertDialog("Fail to lock AE", true);
			}
		}
Пример #29
0
		/// <summary>
		/// Unlock AF.
		/// </summary>
		private void unlockAF()
		{
			// If we send TRIGGER_CANCEL. Lens move to its default position. This results in bad user experience.
			if (mPreviewBuilder.get(SCaptureRequest.CONTROL_AF_MODE) == SCaptureRequest.CONTROL_AF_MODE_AUTO || mPreviewBuilder.get(SCaptureRequest.CONTROL_AF_MODE) == SCaptureRequest.CONTROL_AF_MODE_MACRO)
			{
				State = CAMERA_STATE.PREVIEW;
				return;
			}

			// Triggers CONTROL_AF_TRIGGER_CANCEL to return to initial AF state.
			try
			{
				mPreviewBuilder.set(SCaptureRequest.CONTROL_AF_TRIGGER, SCaptureRequest.CONTROL_AF_TRIGGER_CANCEL);
				mSCameraSession.capture(mPreviewBuilder.build(), new CaptureCallbackAnonymousInnerClassHelper3(this), mBackgroundHandler);
				mPreviewBuilder.set(SCaptureRequest.CONTROL_AF_TRIGGER, SCaptureRequest.CONTROL_AF_TRIGGER_IDLE);
			}
			catch (CameraAccessException)
			{
				showAlertDialog("Fail to cancel AF", false);
			}
		}
Пример #30
0
 public void cameraRelease( )
 {
     camera_state = stop_state;
 }
Пример #31
0
		/// <summary>
		/// Starts a preview.
		/// </summary>
		private void startPreview()
		{
			lock (this)
			{
				if (mSCameraSession == null)
				{
					return;
				}
        
				try
				{
					// Starts displaying the preview.
					mSCameraSession.setRepeatingRequest(mPreviewBuilder.build(), mSessionCaptureCallback, mBackgroundHandler);
					State = CAMERA_STATE.PREVIEW;
				}
				catch (CameraAccessException)
				{
					showAlertDialog("Fail to start preview.", true);
				}
			}
		}
Пример #32
0
		public override void onResume()
		{
			base.onResume();

			State = CAMERA_STATE.IDLE;

			startBackgroundThread();

			// initialize SCamera
			mSCamera = new SCamera();
			try
			{
				mSCamera.initialize(this);
			}
			catch (SsdkUnsupportedException)
			{
				showAlertDialog("Fail to initialize SCamera.", true);
				return;
			}

			mCaptureResultQueue = new LinkedBlockingQueue<SCaptureResult>();

			OrientationListener = true;
			createUI();
			checkRequiredFeatures();
			openCamera(mLensFacing);
		}
Пример #33
0
 public string GetTextState(CAMERA_STATE state)
 {
     return(TextStateLookup.ContainsKey(state) ? TextStateLookup[state] : "Logic error - unknown state");
 }
Пример #34
0
		/// <summary>
		/// Starts AF process by triggering <seealso cref="com.samsung.android.sdk.camera.SCaptureRequest#CONTROL_AF_TRIGGER_START"/>.
		/// </summary>
		private void lockAF()
		{
			try
			{
				State = CAMERA_STATE.WAIT_AF;
				isAFTriggered = false;

				// Set AF trigger to SCaptureRequest.Builder
				mPreviewBuilder.set(SCaptureRequest.CONTROL_AF_TRIGGER, SCaptureRequest.CONTROL_AF_TRIGGER_START);

				// App should send AF triggered request for only a single capture.
				mSCameraSession.capture(mPreviewBuilder.build(), new CaptureCallbackAnonymousInnerClassHelper(this), mBackgroundHandler);
				mPreviewBuilder.set(SCaptureRequest.CONTROL_AF_TRIGGER, SCaptureRequest.CONTROL_AF_TRIGGER_IDLE);
			}
			catch (CameraAccessException)
			{
				showAlertDialog("Fail to trigger AF", true);
			}
		}
Пример #35
0
    void ControlCamera()
    {
        if (enableCamera && bCamera)
        {
            // Check for Camera MOVING.
            if ((deltaX != 0 || deltaZ != 0) && (mCameraState == CAMERA_STATE.eIdle || mCameraState == CAMERA_STATE.eMoving || mCameraState == CAMERA_STATE.ePressingBuilding))
            {
                //Debug.LogError("mCameraState  " + mCameraState);
                if (mCameraState == CAMERA_STATE.eIdle)
                {
                    mCameraState = CAMERA_STATE.eMoving;
                }

                Vector3 move_position = (downPositionInScreen - currentPosition) * 60f;
                move_position.x = move_position.x / Screen.width;
                move_position.y = move_position.y / Screen.height;
                //Debug.Log("move_position " + move_position);
                bCamera.MoveEx(downPositionInWorldSpace, move_position.x, move_position.y);

                // // if camera move, the touch position should always point to "downPositionInWorldSpace"
                // RaycastHit hit;
                //             Vector3 currentPointInWorldSpace = downPositionInWorldSpace;

                //             Ray ray = mCurCamera.ScreenPointToRay (currentPosition);
                //             if (Physics.Raycast (ray, out hit, Mathf.Infinity, 1 << Consts.CAMERA_MOVE_LAYER))
                //             {
                //                 currentPointInWorldSpace = hit.point;
                //             }

                //             bCamera.Move(downPositionInWorldSpace.x - currentPointInWorldSpace.x, downPositionInWorldSpace.z - currentPointInWorldSpace.z);

                //             // bCamera.Move((downPosition.x - currentPosition.x)*Time.deltaTime, (downPosition.y - currentPosition.y)*Time.deltaTime);
            }

#if UNITY_EDITOR || UNITY_PLAYER || UNITY_STANDALONE_WIN
            else if (touch2Finger_mouse)
            {
                if (Input.GetMouseButton(2) && (mCameraState == CAMERA_STATE.eIdle || mCameraState == CAMERA_STATE.eAngle))
                {
                    mCameraState = CAMERA_STATE.eAngle;
                    bCamera.RotateX(touch2FingerDeltaY_mouse);
                }
                else if (touch2FingerDeltaX_mouse != 0 || touch2FingerDeltaY_mouse != 0)
                {
                    //downPosition2_mouse
                    mCameraState = CAMERA_STATE.eRotating;
                    {
                        bCamera.RotateY(touch2FingerDeltaX_mouse);
                        //float dy = -Mathf.Sign(touch2FingerDeltaY_mouse)*20f;
                        bCamera.ZoomEx(touch2FingerDeltaY_mouse);
                        //bCamera.Rotate(0, touch2FingerDeltaY_mouse/ SCREEN_HEIGHT, 50);
                    }
                }
            }
#endif

#if UNITY_IPHONE || UNITY_ANDROID || UNITY_WP8 || UNITY_METRO
            else if (touch2Finger_touch && touchMoveAway2_touch)
            {
                Vector3 newPos1 = currentPosition_touch;
                Vector3 newPos2 = currentPosition2_touch;

                GMath.LinePointSide side1 = GMath.CheckLinePointSide(downPosition_touch, downPosition2_touch, newPos1);
                GMath.LinePointSide side2 = GMath.CheckLinePointSide(downPosition_touch, downPosition2_touch, newPos2);

                float point_distance = Mathf.Abs((newPos1 - downPosition_touch).y + (newPos2 - downPosition2_touch).y) / Screen.height / 2f;

                // float distance_x = Mathf.Abs(Mathf.Abs((downPosition_touch - downPosition2_touch).x) - Mathf.Abs((newPos1 - newPos2).x))/Screen.width;
                float distance_x = ((downPosition_touch - downPosition2_touch).magnitude - (newPos1 - newPos2).magnitude) / Screen.width;

                Vector3 tmpv1            = downPosition_touch - downPosition2_touch;
                Vector3 tmpv2            = newPos1 - newPos2;
                float   tmp_detail_angle = Vector3.SignedAngle(tmpv1, tmpv2, Vector2.right);

                // Debug.Log("distance_x " + distance_x + " distance_y " + distance_y
                //  + " point_distance " + point_distance + " mCameraState " + mCameraState);

                if ((point_distance > 0.1f && mCameraState == CAMERA_STATE.eIdle && side1 != GMath.LinePointSide.ON_LINE && side1 == side2) ||
                    mCameraState == CAMERA_STATE.eAngle)
                {
                    mCameraState = CAMERA_STATE.eAngle;
                    float detail_distance = (detailPosition_touch.y + detailPosition2_touch.y) / 2f;
                    // Debug.Log("detail_distance " + detail_distance);
                    bCamera.RotateX(detail_distance * Time.unscaledDeltaTime);
                }
                else if (((tmp_detail_angle > 3f || Mathf.Abs(distance_x) > 0.06f) && mCameraState == CAMERA_STATE.eIdle) ||
                         (mCameraState == CAMERA_STATE.eRotating))
                {
                    mCameraState = CAMERA_STATE.eRotating;
                    float detail_x = ((prePosition_touch - prePosition2_touch).magnitude - (newPos1 - newPos2).magnitude) / Screen.width;
                    // float detail_x = distance_x * 1f;

                    Vector3 v1            = prePosition_touch - prePosition2_touch;
                    Vector3 v2            = newPos1 - newPos2;
                    float   detail_angle  = Vector3.SignedAngle(v1, v2, Vector2.right);
                    float   cross_product = GMath.LineCrossProduct(v1, v2);
                    if (cross_product < 0)
                    {
                        detail_angle *= -1f;
                    }
                    // Debug.Log("detail_x " + detail_x);
                    // Debug.Log("detail_angle " + detail_angle);
                    bCamera.RotateY(detail_angle * Time.unscaledDeltaTime * 50f);
                    bCamera.ZoomEx(detail_x * Time.unscaledDeltaTime * 3500f);
                }
            }
#endif
            // // rotate to default rotation
            // else if ((touch2FingerReleased) && mCameraState == CAMERA_STATE.eIdle )
            // {
            //  bCamera.RotateBack();
            // }
            // no input and move
            else if (touch2FingerReleased)
            {
                bCamera.FinishFinger2Touch();
                //bCamera.SmoothStop();
            }
            else if (isReleased)
            {
                bCamera.FinishMove();
            }
            else if (!isPressed && !isDown && !touch2Finger)
            {
                //hasInput = false;
            }
        }
    }
 public void UnLockCamera()
 {
     _state = CAMERA_STATE.CANMOVE;
 }
Пример #37
0
 public void cameraStop( )
 {
     stop_state   = camera_state;
     camera_state = CAMERA_STATE.CAMERA_STATE_STOP;
 }
Пример #38
0
 public void FollowTarget(GameObject target)
 {
     Target = target;
     State  = CAMERA_STATE.Follow;
 }
Пример #39
0
    // Update is called once per frame
    void Update( )
    {
        Vector3 truth_pos = Input.mousePosition;
        Vector3 mouse_pos = _camera.ScreenToWorldPoint(truth_pos);
        //マウス操作
        bool th   = Input.GetKeyDown(KeyCode.Mouse0);
        bool push = Input.GetMouseButton(0);

        //タッチ操作
        //	th = ( 0 != Input.touchCount );
        //	if (th) {
        //		mouse_pos = _camera.ScreenToWorldPoint(Input.touches[0].deltaPosition);
        //	}

        if (_map_size.x > STANDARD_X || _map_size.y > STANDARD_Y)
        {
            if (th && (-3 < mouse_pos.y - _camera.transform.position.y && !(mouse_pos.y - _camera.transform.position.y > 3 && mouse_pos.x - _camera.transform.position.x < -5)) &&
                camera_state == CAMERA_STATE.CAMERA_STATE_NORMAL)
            {
                camera_state = CAMERA_STATE.CAMERA_STATE_SCROLL;
            }
        }
        if (th)
        {
            Debug.Log(mouse_pos - _camera.transform.position);
        }
        if (camera_state == CAMERA_STATE.CAMERA_STATE_NORMAL)
        {
            _target.GetComponent <Player> ( ).setOperatable(true);
        }
        else
        {
            _target.GetComponent <Player> ( ).setOperatable(false);
        }

        if (_target.GetComponent <Player>( ).getEnd( ))
        {
            return;
        }

        switch (camera_state)
        {
        case CAMERA_STATE.CAMERA_STATE_NORMAL:
            normal( );
            break;

        case CAMERA_STATE.CAMERA_STATE_SCROLL:
            if (push)
            {
                scroll(mouse_pos);
            }
            else
            {
                before_pos = new Vector3(0, 0, 0);
                if (scroll_range != new Vector3(0, 0, 0))
                {
                    inertia( );
                }
            }
            break;

        case CAMERA_STATE.CAMERA_STATE_COME_BACK:
            come_back( );
            break;

        case  CAMERA_STATE.CAMERA_STATE_STOP:
            break;

        default:
            break;
        }

        Vector3 m_to_c = _camera.transform.position - _map.transform.position;

        if (m_to_c.x < rec_x / 2)
        {
            _camera.transform.position = new Vector3(
                _map.transform.position.x + rec_x / 2,
                _camera.transform.position.y,
                _camera.transform.position.z
                );
        }
        else if (m_to_c.x > _map_size.x - rec_x / 2)
        {
            _camera.transform.position = new Vector3(
                _map.transform.position.x + (_map_size.x - rec_x / 2),
                _camera.transform.position.y,
                _camera.transform.position.z
                );
        }
        if (m_to_c.y < rec_y / 2)
        {
            _camera.transform.position = new Vector3(
                _camera.transform.position.x,
                _map.transform.position.y + rec_y / 2,
                _camera.transform.position.z
                );
        }
        else if (m_to_c.y > _map_size.y - rec_y / 2)
        {
            _camera.transform.position = new Vector3(
                _camera.transform.position.x,
                _map.transform.position.y + (_map_size.y - rec_y / 2),
                _camera.transform.position.z
                );
        }
    }
Пример #40
0
		/// <summary>
		/// Take picture.
		/// </summary>
		private void takePicture()
		{
			if (State == CAMERA_STATE.CLOSING)
			{
				return;
			}

			try
			{
				clearInputImages();

				// Sets orientation
				mCaptureBuilder.set(SCaptureRequest.JPEG_ORIENTATION, JpegOrientation);

				// Make a list of capture request to capture multi input images
				IList<SCaptureRequest> captureRequestList = new List<SCaptureRequest>();
				for (int count = 0; count < mProcessor.Parameters.get(SCameraLowLightProcessor.MULTI_INPUT_COUNT_RANGE).Upper; count++)
				{
					captureRequestList.Add(mCaptureBuilder.build());
				}

				// Use captureBurst to take multi input images. Low light processor needs multi input images to produce low light enhancement image,
				mSCameraSession.captureBurst(captureRequestList, new CaptureCallbackAnonymousInnerClassHelper5(this), mBackgroundHandler);
				State = CAMERA_STATE.TAKE_PICTURE;
			}
			catch (CameraAccessException)
			{
				showAlertDialog("Fail to start preview.", true);
			}
		}