Esempio n. 1
0
    // Use this for initialization
    void Start()
    {
        camPoint = this.gameObject;

        activeCamera = selectedCameraMode;

        SwitchCameraMode();
    }
Esempio n. 2
0
        /// <summary>
        /// Called to change camera mode.
        /// </summary>
        /// <param name="mode">New camera mode.</param>
        protected override void OnChangeCameraMode(CameraModes cameraMode)
        {
            base.OnChangeCameraMode(cameraMode);

            // Update camera settings
            UpdateCamera();
            cameraVelocity = Vector3.Zero;
        }
Esempio n. 3
0
    private static void ChangeMode(CameraModes mode)
    {
        cameraMode = mode;

        Camera camera = Camera.GetComponent <Camera>();

        camera.orthographic = (mode == CameraModes.Free) ? false : true;
    }
Esempio n. 4
0
    public void SetFollow(bool smoothTransition = true)
    {
        mode = CameraModes.Follow;

        //followTransition = smoothTransition;

        currentVelocity = Vector3.zero;
    }
Esempio n. 5
0
        /// <summary>
        /// Sets camero to ortho mode
        /// </summary>
        private void SetOrtho()
        {
            this.StopTranslations();

            this.Position = Vector3.Up;
            this.Interest = Vector3.Zero;

            this.mode = CameraModes.Ortho;
        }
Esempio n. 6
0
        /// <summary>
        /// Sets camera to free mode
        /// </summary>
        /// <param name="newPosition">New position</param>
        /// <param name="newInterest">New interest point</param>
        private void SetFree(Vector3 newPosition, Vector3 newInterest)
        {
            this.StopTranslations();

            this.Position = newPosition;
            this.Interest = newInterest;

            this.mode = CameraModes.Free;
        }
Esempio n. 7
0
 public CameraState(Vector3 cameraPosition, Quaternion cameraAngles, Vector3 cameraHolderPosition, Quaternion cameraHolderAngles, CameraModes cameraMode, Vector3 lookAtPosition = default)
 {
     CameraPosition       = cameraPosition;
     CameraAngles         = cameraAngles;
     CameraHolderPosition = cameraHolderPosition;
     CameraHolderAngles   = cameraHolderAngles;
     CameraMode           = cameraMode;
     LookAtPosition       = (lookAtPosition == default) ? Vector3.zero : lookAtPosition;
 }
        //Camera mode changes need to be performed frame by frame, to ensure that controllers have been initialized.
        void Update()
        {
            if (cameraModeUpdates.Count > 0)
            {
                CameraMode = cameraModeUpdates.Dequeue();
            }

            ChangeCameraMode();
        }
Esempio n. 9
0
 public UICameraPreview(CameraOptions options, SpeedOptions sOptions, string fileUrl, CameraModes mode)
 {
     cameraOptions = options;
     speedOptions  = sOptions;
     CameraMode    = mode;
     IsPreviewing  = false;
     fileUrl       = FileUrl;
     Initialize();
     //SetupUserInterface();
 }
Esempio n. 10
0
    public static void ChangeMode()
    {
        cameraMode = (cameraMode == CameraModes.Free) ? CameraModes.TopDown : CameraModes.Free;

        Camera camera = Camera.GetComponent <Camera>();

        camera.orthographic = !camera.orthographic;

        SetDefaultCameraPosition();
    }
Esempio n. 11
0
 public void ReplayCam()
 {
     _camModes = CameraModes.Replay;
     // Lower other camera priorities
     DisableCutscene();
     _droneCamera.Priority = 5;
     _raceCamera.Priority  = 5;
     // activate drone
     _replayShots.Priority = 15;
 }
Esempio n. 12
0
 public void StaticCams()
 {
     _camModes = CameraModes.Static;
     // Lower other camera priorities
     DisableCutscene();
     _droneCamera.Priority = 5;
     _raceCamera.Priority  = 5;
     _replayShots.Priority = 5;
     SetStaticCam(_curStaticCam);
 }
Esempio n. 13
0
    public void SetFixed(Vector3 fixedPosition, Vector3 startPosition)
    {
        if (startPosition != Vector3.zero)
        {
            transform.position = startPosition;
        }

        mode = CameraModes.Fixed;
        this.fixedPosition = fixedPosition;
        currentVelocity    = Vector3.zero;
    }
Esempio n. 14
0
        void OnSceneLoaded(Scene newScene, LoadSceneMode newSceneLoadMode)
        {
            //If a new single scene has been loaded, setup the camera.
            if (newSceneLoadMode == LoadSceneMode.Single)
            {
                //When the scene changes, we don't need the old updates anymore.
                cameraModeUpdates = new Queue <CameraModes>();

                CameraMode = CameraModes.None;
            }
        }
Esempio n. 15
0
 public void PlayCutscene()
 {
     _camModes = CameraModes.Cutscene;
     // Lower other camera priorities
     _droneCamera.Priority = 5;
     _raceCamera.Priority  = 5;
     _replayShots.Priority = 5;
     // activate cutscene
     _cutsceneDirector.enabled = true;
     _cutsceneDirector.Stop();
     _cutsceneDirector.Play();
 }
Esempio n. 16
0
    public void ChangeCameraMode(CameraModes cameraMode)
    {
        switch (cameraMode)
        {
        case CameraModes.PlayerShooting:
            _currentMode = FollowPlayerInShooterMode;
            break;

        case CameraModes.PlayerClimb:
            _currentMode = FollowPlayerInClimbMode;
            break;
        }
    }
Esempio n. 17
0
 //called when camera needs to be sent to base functionality
 //called when turns end
 public void HardResetCamera()
 {
     _moving = false;
     RemoveSubscriptions();
     if (_zoomed)
     {
         FocusPosition(_objOfInterest, CameraModes.MOVING);
     }
     else
     {
         _myCurrMode = CameraModes.FREE;
         GameUpdate.PlayerSubscribe += PlayerControl;
     }
 }
Esempio n. 18
0
        private void SetCameraMode(CameraModes cameraMode)
        {
            if (!fpController || !spaceshipCamera || !grassMowerCamera)
            {
                Debug.Log("Not all cameras are set. Please assign the relevant cameras from the inspector");
                return;
            }

            fpController.SetActive(false);
            spaceshipCamera.SetActive(false);
            grassMowerCamera.SetActive(false);

            _spaceShip.GetComponent <SpaceshipController>().enabled = false;
            _spaceShipThrusterGlow.gameObject.SetActive(false);
            _spaceShipControlsText.gameObject.SetActive(false);

            _grassMower.GetComponent <GrassMowerController>().enabled        = false;
            _grassMower.GetComponent <GPUInstancerInstanceRemover>().enabled = false;
            _grassMowerControlsText.gameObject.SetActive(false);

            switch (cameraMode)
            {
            case CameraModes.FPMode:
                fpController.SetActive(true);
                _activeCameraGO = fpController;
                break;

            case CameraModes.SpaceshipMode:
                spaceshipCamera.SetActive(true);
                _spaceShip.GetComponent <SpaceshipController>().enabled = true;
                _spaceShipThrusterGlow.gameObject.SetActive(true);
                _spaceShipControlsText.gameObject.SetActive(true);
                _activeCameraGO = spaceshipCamera;
                break;

            case CameraModes.MowerMode:
                grassMowerCamera.SetActive(true);
                _grassMower.GetComponent <GrassMowerController>().enabled        = true;
                _grassMower.GetComponent <GPUInstancerInstanceRemover>().enabled = true;
                _grassMowerControlsText.gameObject.SetActive(true);
                _activeCameraGO = grassMowerCamera;
                break;
            }

            _currentCameraMode = cameraMode;

            // Notify GPU Instancer of the camera change:
            GPUInstancerAPI.SetCamera(_activeCameraGO.GetComponentInChildren <Camera>());
        }
Esempio n. 19
0
        public void Init()
        {
            CameraModes_Items root = new CameraModes_Items(CameraModeNames.CameraModes.CameraMode.ToString());

            CameraModes.Add(root);
            /////////////////////////////////////////////////////
            CameraModes_Items fixedCamera = new CameraModes_Items(CameraModeNames.CameraModes.Fixed.ToString());

            root.ChildCameras.Add(fixedCamera);
            CameraModes_Items fixedTrackingCamera = new CameraModes_Items(CameraModeNames.CameraModes.FixedTracking.ToString());

            fixedCamera.ChildCameras.Add(fixedTrackingCamera);
            CameraModes_Items closest2TargetCamera = new CameraModes_Items(CameraModeNames.CameraModes.ClosestToTarget.ToString());

            fixedTrackingCamera.ChildCameras.Add(closest2TargetCamera);
            /////////////////////////////////////////////////////
            CameraModes_Items chaseCamera = new CameraModes_Items(CameraModeNames.CameraModes.Chase.ToString());

            root.ChildCameras.Add(chaseCamera);
            CameraModes_Items chaseFYACamera = new CameraModes_Items(CameraModeNames.CameraModes.ChaseFreeYawAxis.ToString());

            chaseCamera.ChildCameras.Add(chaseFYACamera);
            /////////////////////////////////////////////////////
            CameraModes_Items attachedCamera = new CameraModes_Items(CameraModeNames.CameraModes.Attached.ToString());

            root.ChildCameras.Add(attachedCamera);
            CameraModes_Items firstPersonCamera = new CameraModes_Items(CameraModeNames.CameraModes.FirstPerson.ToString());

            attachedCamera.ChildCameras.Add(firstPersonCamera);
            /////////////////////////////////////////////////////
            CameraModes_Items planeBindedCamera = new CameraModes_Items(CameraModeNames.CameraModes.PlaneBinded.ToString());

            root.ChildCameras.Add(planeBindedCamera);
            CameraModes_Items planViewCamera = new CameraModes_Items(CameraModeNames.CameraModes.PlanView.ToString());

            planeBindedCamera.ChildCameras.Add(planViewCamera);
            CameraModes_Items rtsCamera = new CameraModes_Items(CameraModeNames.CameraModes.RTS.ToString());

            planViewCamera.ChildCameras.Add(rtsCamera);
            /////////////////////////////////////////////////////
            CameraModes_Items throughTargetCamera = new CameraModes_Items(CameraModeNames.CameraModes.ThroughTarget.ToString());

            root.ChildCameras.Add(throughTargetCamera);
            /////////////////////////////////////////////////////
            CameraModes_Items fixedDirectionCamera = new CameraModes_Items(CameraModeNames.CameraModes.FixedDirection.ToString());

            root.ChildCameras.Add(fixedDirectionCamera);
            path_ExportUnity.Text = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
        }
Esempio n. 20
0
    //called when the camers needs to focus on a certain character
    void MoveToPosition()
    {
        _currTime = (Time.time - _startTime) / _moveSpeed;

        if (_currTime > 1)
        {
            _currTime                   = 1;
            _myCurrMode                 = CameraModes.FREE;
            GameUpdate.UISubscribe     -= MoveToPosition;
            GameUpdate.PlayerSubscribe += PlayerControl;
            _moving = false;
            //Debug.Log("Done Moving");
        }
        //Debug.Log("moving");
        transform.position = RandomThings.Interpolate(_currTime, _startPos, _targetPos);
    }
Esempio n. 21
0
        /// <summary>
        /// Sets camera to isometric mode
        /// </summary>
        /// <param name="axis">Isometrix axis</param>
        /// <param name="newInterest">Interest point</param>
        /// <param name="distance">Distance to interest point from viewer point</param>
        private void SetIsometric(IsometricAxis axis, Vector3 newInterest, float distance)
        {
            this.StopTranslations();

            Vector3 tmpPosition = Vector3.Zero;

            if (axis == IsometricAxis.NW)
            {
                tmpPosition            = new Vector3(1, 1, 1);
                this.isoMetricForward  = new Vector3(-1f, 0f, -1f);
                this.isoMetricBackward = new Vector3(1f, 0f, 1f);
                this.isoMetricLeft     = new Vector3(1f, 0f, -1f);
                this.isoMetricRight    = new Vector3(-1f, 0f, 1f);
            }
            else if (axis == IsometricAxis.NE)
            {
                tmpPosition            = new Vector3(-1, 1, 1);
                this.isoMetricForward  = new Vector3(1f, 0f, -1f);
                this.isoMetricBackward = new Vector3(-1f, 0f, 1f);
                this.isoMetricLeft     = new Vector3(1f, 0f, 1f);
                this.isoMetricRight    = new Vector3(-1f, 0f, -1f);
            }
            else if (axis == IsometricAxis.SW)
            {
                tmpPosition            = new Vector3(1, 1, -1);
                this.isoMetricForward  = new Vector3(-1f, 0f, 1f);
                this.isoMetricBackward = new Vector3(1f, 0f, -1f);
                this.isoMetricLeft     = new Vector3(-1f, 0f, -1f);
                this.isoMetricRight    = new Vector3(1f, 0f, 1f);
            }
            else if (axis == IsometricAxis.SE)
            {
                tmpPosition            = new Vector3(-1, 1, -1);
                this.isoMetricForward  = new Vector3(1f, 0f, 1f);
                this.isoMetricBackward = new Vector3(-1f, 0f, -1f);
                this.isoMetricLeft     = new Vector3(-1f, 0f, 1f);
                this.isoMetricRight    = new Vector3(1f, 0f, -1f);
            }

            this.mode          = CameraModes.FreeIsometric;
            this.isometricAxis = axis;

            this.Position  = Vector3.Normalize(tmpPosition) * distance;
            this.Position += newInterest;
            this.Interest  = newInterest;
        }
Esempio n. 22
0
    //The method the player uses to change mode.
    void ChangeCameraMode()
    {
        if (Input.GetKeyDown(KeyCode.F))
        {
            //if(seectedCameraMode == CameraModes.FirstPerson)
            //    seectedCameraMode = CameraModes.ThirdPerson;
            //else
            //    seectedCameraMode = CameraModes.FirstPerson;

            selectedCameraMode++;

            if ((int)selectedCameraMode == Enum.GetNames(typeof(CameraModes)).Length)
            {
                selectedCameraMode = 0;
            }
        }
    }
Esempio n. 23
0
    //Activates the camera specified in selectedCameraMode.
    void SwitchCameraMode()
    {
        RemoveCameraController();

        activeCamera = selectedCameraMode;

        //Might be a better way to do this, but it beats the old one.
        switch (selectedCameraMode)
        {
        case CameraModes.FirstPerson:
            gameObject.AddComponent <FirstPersonCameraController>();
            break;

        case CameraModes.ThirdPerson:
            gameObject.AddComponent <ThirdPersonCameraController>();
            break;

        case CameraModes.Shoulder:
            gameObject.AddComponent <ShoulderCameraController>();
            break;

        case CameraModes.FlyCam:
            gameObject.AddComponent <FlyCameraController>();
            break;

        case CameraModes.TopDown:
            gameObject.AddComponent <TopDownCameraController>();
            break;

        case CameraModes.Static:
            gameObject.AddComponent <StaticCameraController>();
            break;

        case CameraModes.Follow:
            gameObject.AddComponent <FollowCameraController>();
            break;

        //case CameraModes.DogsLife:
        //    gameObject.AddComponent<DogsLifeCameraController>();
        //    break;
        case CameraModes.SceneOverview:
            gameObject.AddComponent <SceneOverviewCameraController>();
            break;
        }
    }
Esempio n. 24
0
    //called when the cmaera needs to zoom in to show detail on a character
    void ZoomOn()
    {
        _currTime = (Time.time - _startTime) / _zoomSpeed;


        //Debug.Log("zooming");

        transform.position = RandomThings.Interpolate(_currTime, _startPos, _targetPos);

        if (_currTime > 1)
        {
            transform.position      = _targetPos;
            _currTime               = 1;
            _myCurrMode             = CameraModes.NONE;
            GameUpdate.UISubscribe -= ZoomOn;
            _moving = false;
        }
    }
Esempio n. 25
0
    public void FocusPosition(Vector3 POI, CameraModes howToLook)
    {
        if (!_moving)
        {
            GameUpdate.PlayerSubscribe -= PlayerControl;
            _objOfInterest              = POI;
            _startPos = transform.position;
            //Debug.Log(POI.name);
            switch (howToLook)
            {
            //if the player left clicks on a character
            //move to that character as the focus
            case CameraModes.MOVING:
                _targetPos              = _objOfInterest - _spaceDiff;
                _zoomed                 = false;
                GameUpdate.UISubscribe += MoveToPosition;
                break;

            //if the player right clicks on a character
            //move to that character as the focus
            //zoom on characters
            case CameraModes.ZOOMING:
                _targetPos              = (_objOfInterest - _spaceDiff) + (transform.forward * _zoomDistance);
                _zoomed                 = true;
                GameUpdate.UISubscribe += ZoomOn;
                break;

            //called when the player tries to rotate the camera around the battlefield
            //used in the GridSetup to rotate the grid preview
            case CameraModes.SHOWCASING:
                GameUpdate.UISubscribe += Showcase;
                break;

            default:
                break;
            }
            _moving     = true;
            _myCurrMode = howToLook;
            _startTime  = Time.time;
        }
    }
Esempio n. 26
0
        public MainWindow()
        {
            InitializeComponent();

            VideoStream.Url = new System.Uri(IPAddress + "/mobile.htm");

            Translator = new Translation(LANGUAGES.English);//English will be the default language
            UpdateInterface();//Update the interface for the new language

            CameraMode = CameraModes.Gunner;//Default as gunner because this mode is critical to the gunner, but optional for the driver.

            BackgroundURLBox.Visible = false;//This url box is only for message passing and should not be seen by the user.
            //Turns LED off by default
            BackgroundURLBox.Url = new System.Uri(IPAddress + "/set_misc.cgi?next_url=ptz.htm&loginuse=admin&loginpas=&ptz_patrol_rate=10&ptz_patrol_up_rate=10&ptz_patrol_down_rate=10&ptz_patrol_left_rate=10&ptz_patrol_right_rate=10&ptz_dispreset=1&ptz_preset=3&led_mode=0&ptz_run_times=2");

            //Configure the custom colors
            Color KilimanjaroGreen = Color.FromArgb(29, 62, 32);
            Color KilimanjaroYellow = Color.FromArgb(191, 196, 140);
            Color KilimanjaroRed = Color.FromArgb(146, 23, 0);
            Color KilimanjaroOrange = Color.FromArgb(179, 95, 16);
            menuStrip1.BackColor = KilimanjaroGreen;
            menuStrip1.ForeColor = KilimanjaroYellow;
            UpButton.BackColor = KilimanjaroGreen;
            UpButton.ForeColor = KilimanjaroYellow;
            UpButton.FlatAppearance.BorderColor = KilimanjaroYellow;
            DownButton.BackColor = KilimanjaroGreen;
            DownButton.ForeColor = KilimanjaroYellow;
            DownButton.FlatAppearance.BorderColor = KilimanjaroYellow;
            LeftButton.BackColor = KilimanjaroGreen;
            LeftButton.ForeColor = KilimanjaroYellow;
            LeftButton.FlatAppearance.BorderColor = KilimanjaroYellow;
            RightButton.BackColor = KilimanjaroGreen;
            RightButton.ForeColor = KilimanjaroYellow;
            RightButton.FlatAppearance.BorderColor = KilimanjaroYellow;
            FireButton.BackColor = KilimanjaroGreen;
            FireButton.ForeColor = KilimanjaroYellow;
            FireButton.FlatAppearance.BorderColor = KilimanjaroYellow;
        }
Esempio n. 27
0
    ////////////////////////////////////////////////////////////////

    public override void Initialize()
    {
        JSDK.Events.EventManager.Get().AddListener <PlayerResetEvent>(OnPlayerReset);
        JSDK.Events.EventManager.Get().AddListener <PlayerDeathEvent>(OnPlayerDeath);

        m_CameraMode        = CameraModes.FocusPlayer;
        m_CurrentAnchorZone = null;

        AssetDataCamera assetDataCamera = AssetManager.GetAssetData <AssetDataCamera>();

        {
            SceneContext context = SceneContext.MetaContext();
            m_Camera       = Camera.main;
            m_CameraHolder = m_Camera.transform.parent.gameObject;
            m_BaseSizeY    = assetDataCamera.SizeY / 2.0f;
            m_BaseSizeX    = m_BaseSizeY * Screen.width / (float)Screen.height;
            SetCameraZoom(1.0f);

            m_ScreenEffectRenderer = m_CameraHolder.GetComponentInChildren <MeshRenderer>();
            m_ScreenEffectRenderer.transform.position = m_ScreenEffectRenderer.transform.position.xy().To3D_Z();
            context.Unset();
        }
    }
Esempio n. 28
0
        public CameraDetailsViewModel(string cameraUrl)
        {
            PreviousWindowCommand          = new RelayCommand(GetToPreviousWindow);
            EnableFaceCaptureCommand       = new RelayCommand(EnableFaceCaptureMode);
            EnableGrayscaleModeCommand     = new RelayCommand(EnableGrayscaleMode);
            EnableOriginalModeCommand      = new RelayCommand(EnableOriginalMode);
            EnableMotionCaptureModeCommand = new RelayCommand(EnableMotionCaptureMode);

            _videoRecordingService  = new VideoRecordingService();
            _motionDetectionService = new MotionDetectionService();
            _faceAnalyzerService    = new FaceAnalyzerService();

            DisplayWidth  = DisplayData.DisplayWidth;
            DisplayHeight = DisplayData.DisplayHeight;

            _cameraMode = CameraModes.Original;

            if (!string.IsNullOrEmpty(cameraUrl))
            {
                CameraUrl = cameraUrl;
                StartCamera();
            }
        }
Esempio n. 29
0
        private void GetPlayerInput()
        {
            moveVector = Vector3.zero;

            // Check Mouse Wheel Input prior to Shift Key so we can apply multiplier on Shift for Scrolling
            mouseWheel = Input.GetAxis("Mouse ScrollWheel");

            float touchCount = Input.touchCount;

            if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift) || touchCount > 0)
            {
                mouseWheel *= 10;

                if (Input.GetKeyDown(KeyCode.I))
                {
                    CameraMode = CameraModes.Isometric;
                }

                if (Input.GetKeyDown(KeyCode.F))
                {
                    CameraMode = CameraModes.Follow;
                }

                if (Input.GetKeyDown(KeyCode.S))
                {
                    MovementSmoothing = !MovementSmoothing;
                }


                // Check for right mouse button to change camera follow and elevation angle
                if (Input.GetMouseButton(1))
                {
                    mouseY = Input.GetAxis("Mouse Y");
                    mouseX = Input.GetAxis("Mouse X");

                    if (mouseY > 0.01f || mouseY < -0.01f)
                    {
                        ElevationAngle -= mouseY * MoveSensitivity;
                        // Limit Elevation angle between min & max values.
                        ElevationAngle = Mathf.Clamp(ElevationAngle, MinElevationAngle, MaxElevationAngle);
                    }

                    if (mouseX > 0.01f || mouseX < -0.01f)
                    {
                        OrbitalAngle += mouseX * MoveSensitivity;
                        if (OrbitalAngle > 360)
                        {
                            OrbitalAngle -= 360;
                        }
                        if (OrbitalAngle < 0)
                        {
                            OrbitalAngle += 360;
                        }
                    }
                }

                // Get Input from Mobile Device
                if (touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Moved)
                {
                    var deltaPosition = Input.GetTouch(0).deltaPosition;

                    // Handle elevation changes
                    if (deltaPosition.y > 0.01f || deltaPosition.y < -0.01f)
                    {
                        ElevationAngle -= deltaPosition.y * 0.1f;
                        // Limit Elevation angle between min & max values.
                        ElevationAngle = Mathf.Clamp(ElevationAngle, MinElevationAngle, MaxElevationAngle);
                    }


                    // Handle left & right
                    if (deltaPosition.x > 0.01f || deltaPosition.x < -0.01f)
                    {
                        OrbitalAngle += deltaPosition.x * 0.1f;
                        if (OrbitalAngle > 360)
                        {
                            OrbitalAngle -= 360;
                        }
                        if (OrbitalAngle < 0)
                        {
                            OrbitalAngle += 360;
                        }
                    }
                }

                // Check for left mouse button to select a new CameraTarget or to reset Follow position
                if (Input.GetMouseButton(0))
                {
                    var        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                    RaycastHit hit;

                    if (Physics.Raycast(ray, out hit, 300, (1 << 10) | (1 << 11) | (1 << 12) | (1 << 14)))
                    {
                        if (hit.transform == CameraTarget)
                        {
                            // Reset Follow Position
                            OrbitalAngle = 0;
                        }
                        else
                        {
                            CameraTarget      = hit.transform;
                            OrbitalAngle      = 0;
                            MovementSmoothing = previousSmoothing;
                        }
                    }
                }


                if (Input.GetMouseButton(2))
                {
                    if (dummyTarget == null)
                    {
                        // We need a Dummy Target to anchor the Camera
                        dummyTarget          = new GameObject("Camera Target").transform;
                        dummyTarget.position = CameraTarget.position;
                        dummyTarget.rotation = CameraTarget.rotation;
                        CameraTarget         = dummyTarget;
                        previousSmoothing    = MovementSmoothing;
                        MovementSmoothing    = false;
                    }
                    else if (dummyTarget != CameraTarget)
                    {
                        // Move DummyTarget to CameraTarget
                        dummyTarget.position = CameraTarget.position;
                        dummyTarget.rotation = CameraTarget.rotation;
                        CameraTarget         = dummyTarget;
                        previousSmoothing    = MovementSmoothing;
                        MovementSmoothing    = false;
                    }


                    mouseY = Input.GetAxis("Mouse Y");
                    mouseX = Input.GetAxis("Mouse X");

                    moveVector = cameraTransform.TransformDirection(mouseX, mouseY, 0);

                    dummyTarget.Translate(-moveVector, Space.World);
                }
            }

            // Check Pinching to Zoom in - out on Mobile device
            if (touchCount == 2)
            {
                var touch0 = Input.GetTouch(0);
                var touch1 = Input.GetTouch(1);

                var touch0PrevPos = touch0.position - touch0.deltaPosition;
                var touch1PrevPos = touch1.position - touch1.deltaPosition;

                var prevTouchDelta = (touch0PrevPos - touch1PrevPos).magnitude;
                var touchDelta     = (touch0.position - touch1.position).magnitude;

                var zoomDelta = prevTouchDelta - touchDelta;

                if (zoomDelta > 0.01f || zoomDelta < -0.01f)
                {
                    FollowDistance += zoomDelta * 0.25f;
                    // Limit FollowDistance between min & max values.
                    FollowDistance = Mathf.Clamp(FollowDistance, MinFollowDistance, MaxFollowDistance);
                }
            }

            // Check MouseWheel to Zoom in-out
            if (mouseWheel < -0.01f || mouseWheel > 0.01f)
            {
                FollowDistance -= mouseWheel * 5.0f;
                // Limit FollowDistance between min & max values.
                FollowDistance = Mathf.Clamp(FollowDistance, MinFollowDistance, MaxFollowDistance);
            }
        }
Esempio n. 30
0
    ////////////////////////////////////////////////////////////////

    void SetCameraMode(CameraModes mode)
    {
        m_CameraMode = mode;
        //PhysicsManager.Get().SetPhysicsSimulationPaused(mode == CameraModes.TransitionToAnchorZone);
    }
Esempio n. 31
0
 void SwitchCameraMode(CameraModes mode)
 {
     ToggleCameraMode(cameraMode, false);
     cameraMode = mode;
     ToggleCameraMode(cameraMode, true);
 }
Esempio n. 32
0
 void ToggleCameraMode(CameraModes mode, bool on)
 {
     switch(mode){
     case CameraModes.AimCamera:
         aimCamera.enabled = on;
         if(on){
             aimCamera.SetCurrentAngle();
             aimCamera.Apply();
         }
         break;
     case CameraModes.MoveCamera:
         moveCamera.enabled = on;
         if(on)
             moveCamera.ResetDirection(transform.rotation);
         break;
     }
     if(on){
         StartTransition(transform.position, transform.rotation, modeTransitionTime);
     }
 }
Esempio n. 33
0
 private void Viewport_Leave(object sender, EventArgs e)
 {
     if (this.CameraMode != CameraModes.None)
     {
         this.CameraMode = CameraModes.None;
     }
     this.ResetCameraState();
 }
Esempio n. 34
0
 void NextCameraMode()
 {
     ToggleCameraMode(cameraMode, false);
     cameraMode++;
     cameraMode = cameraMode >= CameraModes.Last ? (CameraModes)((int)cameraMode % (int)CameraModes.Last) : cameraMode;
     ToggleCameraMode(cameraMode, true);
 }
Esempio n. 35
0
 private void ViewportControl_MouseLeave(object sender, EventArgs e)
 {
     if (this.CameraMode != CameraModes.None)
     {
         this.CameraMode = CameraModes.None;
     }
     this.m_mouseOver = false;
     Game.OnMouseEvent(MouseEvent.MouseLeave, null);
 }
Esempio n. 36
0
 private void ViewportControl_MouseDown(object sender, MouseEventArgs e)
 {
     if (this.CameraMode == CameraModes.None)
     {
         MouseButtons button = e.Button;
         if (button == MouseButtons.Left)
         {
             Game.OnMouseEvent(MouseEvent.MouseDown, e);
             return;
         }
         if (button != MouseButtons.Right)
         {
             if (button != MouseButtons.Middle)
             {
                 return;
             }
             if (!Game.IsInGame && this.CameraEnabled)
             {
                 this.CameraMode = CameraModes.Panning;
                 return;
             }
         }
         else
         {
             if (!Game.IsInGame && this.CameraEnabled)
             {
                 this.CameraMode = CameraModes.Lookaround;
             }
         }
     }
 }
Esempio n. 37
0
    // Update is called once per frame
    void LateUpdate()
    {
        if(lastCameraMode != CameraModes.AimCamera && ControlSchemeInterface.instance.GetAxis(ControlAxis.AIMING) == 1.0f)
        {
            SwitchCameraMode(CameraModes.AimCamera);
        }
        else if (lastCameraMode != CameraModes.MoveCamera && ControlSchemeInterface.instance.GetAxis(ControlAxis.AIMING) == 0.0f){
            SwitchCameraMode(CameraModes.MoveCamera);
        }

        Vector3 newPosition = transform.position;
        Quaternion newRotation = transform.rotation;
        switch(cameraMode){
            case CameraModes.AimCamera:
                newPosition = aimCamera.position;
                newRotation = aimCamera.rotation;
                break;
            case CameraModes.MoveCamera:
                if(!useIndoorCamera){
                    newPosition = moveCamera.position;
                    newRotation = moveCamera.rotation;
                }
                else{
                    newPosition = indoorCameraTransform.position;
                    newRotation = indoorCameraTransform.rotation;
                }
                break;
        }
        if(transitioning){
        //Debug.Log("transitioning");
            if(transitionTime != 0f){
                transform.position = Vector3.Slerp(transPos, newPosition, transTimer / transitionTime);
                transform.rotation = Quaternion.Slerp(transRot, newRotation, transTimer / transitionTime);
            }
            transTimer += Time.deltaTime;
            if(transTimer >= transitionTime){
                transitioning = false;
            }
        }
        else{
            transform.position = newPosition;
            transform.rotation = newRotation;
        }
        lastCameraMode = cameraMode;
    }
        void GetPlayerInput()
        {
            moveVector = Vector3.zero;

            // Check Mouse Wheel Input prior to Shift Key so we can apply multiplier on Shift for Scrolling
            mouseWheel = Input.GetAxis("Mouse ScrollWheel");

            float touchCount = Input.touchCount;

            if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift) || touchCount > 0)
            {
                mouseWheel *= 10;

                if (Input.GetKeyDown(KeyCode.I))
                    CameraMode = CameraModes.Isometric;

                if (Input.GetKeyDown(KeyCode.F))
                    CameraMode = CameraModes.Follow;

                if (Input.GetKeyDown(KeyCode.S))
                    MovementSmoothing = !MovementSmoothing;


                // Check for right mouse button to change camera follow and elevation angle
                if (Input.GetMouseButton(1))
                {
                    mouseY = Input.GetAxis("Mouse Y");
                    mouseX = Input.GetAxis("Mouse X");

                    if (mouseY > 0.01f || mouseY < -0.01f)
                    {
                        ElevationAngle -= mouseY * MoveSensitivity;
                        // Limit Elevation angle between min & max values.
                        ElevationAngle = Mathf.Clamp(ElevationAngle, MinElevationAngle, MaxElevationAngle);
                    }

                    if (mouseX > 0.01f || mouseX < -0.01f)
                    {
                        OrbitalAngle += mouseX * MoveSensitivity;
                        if (OrbitalAngle > 360)
                            OrbitalAngle -= 360;
                        if (OrbitalAngle < 0)
                            OrbitalAngle += 360;
                    }
                }

                // Get Input from Mobile Device
                if (touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Moved)
                {
                    Vector2 deltaPosition = Input.GetTouch(0).deltaPosition;

                    // Handle elevation changes
                    if (deltaPosition.y > 0.01f || deltaPosition.y < -0.01f)
                    {
                        ElevationAngle -= deltaPosition.y * 0.1f;
                        // Limit Elevation angle between min & max values.
                        ElevationAngle = Mathf.Clamp(ElevationAngle, MinElevationAngle, MaxElevationAngle);
                    }


                    // Handle left & right 
                    if (deltaPosition.x > 0.01f || deltaPosition.x < -0.01f)
                    {
                        OrbitalAngle += deltaPosition.x * 0.1f;
                        if (OrbitalAngle > 360)
                            OrbitalAngle -= 360;
                        if (OrbitalAngle < 0)
                            OrbitalAngle += 360;
                    }

                }

                // Check for left mouse button to select a new CameraTarget or to reset Follow position
                if (Input.GetMouseButton(0))
                {
                    RaycastHit hit;
                    Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                    if (Physics.Raycast(ray, out hit, 300, 1 << 10 | 1 << 11 | 1 << 12 | 1 << 14))
                    {
                        if (hit.transform == CameraTarget)
                        {
                            // Reset Follow Position
                            OrbitalAngle = 0;
                        }
                        else
                        {
                            CameraTarget = hit.transform;
                            OrbitalAngle = 0;
                            MovementSmoothing = previousSmoothing;
                        }

                    }
                }


                if (Input.GetMouseButton(2))
                {
                    if (dummyTarget == null)
                    {
                        // We need a Dummy Target to anchor the Camera
                        dummyTarget = new GameObject("Camera Target").transform;
                        dummyTarget.position = CameraTarget.position;
                        dummyTarget.rotation = CameraTarget.rotation;
                        CameraTarget = dummyTarget;
                        previousSmoothing = MovementSmoothing;
                        MovementSmoothing = false;
                    }
                    else if (dummyTarget != CameraTarget)
                    {
                        // Move DummyTarget to CameraTarget
                        dummyTarget.position = CameraTarget.position;
                        dummyTarget.rotation = CameraTarget.rotation;
                        CameraTarget = dummyTarget;
                        previousSmoothing = MovementSmoothing;
                        MovementSmoothing = false;
                    }


                    mouseY = Input.GetAxis("Mouse Y");
                    mouseX = Input.GetAxis("Mouse X");

                    moveVector = cameraTransform.TransformDirection(mouseX, mouseY, 0);

                    dummyTarget.Translate(-moveVector, Space.World);

                }

            }

            // Check Pinching to Zoom in - out on Mobile device
            if (touchCount == 2)
            {
                Touch touch0 = Input.GetTouch(0);
                Touch touch1 = Input.GetTouch(1);

                Vector2 touch0PrevPos = touch0.position - touch0.deltaPosition;
                Vector2 touch1PrevPos = touch1.position - touch1.deltaPosition;

                float prevTouchDelta = (touch0PrevPos - touch1PrevPos).magnitude;
                float touchDelta = (touch0.position - touch1.position).magnitude;

                float zoomDelta = prevTouchDelta - touchDelta;

                if (zoomDelta > 0.01f || zoomDelta < -0.01f)
                {
                    FollowDistance += zoomDelta * 0.25f;
                    // Limit FollowDistance between min & max values.
                    FollowDistance = Mathf.Clamp(FollowDistance, MinFollowDistance, MaxFollowDistance);
                }


            }

            // Check MouseWheel to Zoom in-out
            if (mouseWheel < -0.01f || mouseWheel > 0.01f)
            {

                FollowDistance -= mouseWheel * 5.0f;
                // Limit FollowDistance between min & max values.
                FollowDistance = Mathf.Clamp(FollowDistance, MinFollowDistance, MaxFollowDistance);
            }


        }
Esempio n. 39
0
 private void ViewportControl_MouseDown(object sender, MouseEventArgs e)
 {
     if (this.CameraMode == CameraModes.None)
     {
         MouseButtons button = e.Button;
         if (button != MouseButtons.Left)
         {
             if (button != MouseButtons.Right)
             {
                 if ((button == MouseButtons.Middle) && (!Editor.IsIngame && this.CameraEnabled))
                 {
                     this.CameraMode = CameraModes.Panning;
                 }
             }
             else if (!Editor.IsIngame && this.CameraEnabled)
             {
                 this.CameraMode = CameraModes.Lookaround;
             }
         }
         else
         {
             Editor.OnMouseEvent(Editor.MouseEvent.MouseDown, e);
         }
     }
 }
Esempio n. 40
0
 private void ViewportControl_MouseUp(object sender, MouseEventArgs e)
 {
     if (this.CameraMode == CameraModes.None)
     {
         if (e.Button == MouseButtons.Left)
         {
             Editor.OnMouseEvent(Editor.MouseEvent.MouseUp, e);
         }
     }
     else if ((e.Button == MouseButtons.Middle) || (e.Button == MouseButtons.Right))
     {
         this.CameraMode = CameraModes.None;
     }
 }
Esempio n. 41
0
    // This method can be called from Event Handler to switch Camera modes
    public void ChangeCameraMode(string mode)
    {
        //Parse string from argument to CameraMode. Argument "mode" has to be string, so we can call this method from Event Handler
        CameraModes cameraMode = (CameraModes)System.Enum.Parse(typeof(CameraModes), mode);

        if (currCameraMode == cameraMode)
        {
            return;
        }

        // if Camera Mode has changed
        // disable all CameraControllers,..
        foreach (ICameraController camCtrl in cameraControllers)
        {
            camCtrl.SetEnable(false);
        }

        // ...restore initial parameters (if any Camera Mode need different on the start, it must change it itself)...
        transform.localPosition = initialCameraPosition;
        transform.localRotation = initialCameraRotation;

        // ...and enable one we need
        switch (cameraMode)
        {
        case CameraModes.FirstPersonViewGyro:
        {
            if (SystemInfo.supportsGyroscope)
            {
                TurnOn(CameraModes.FirstPersonViewGyro);
            }
            else
            {
                log = "Gyroscope isn't supported by your device";
            }

#if UNITY_EDITOR
            TurnOn(CameraModes.FirstPersonViewGyro);
#endif
        }
        break;

        case CameraModes.ThirdPersonView:
        {
            if (SystemInfo.supportsAccelerometer)
            {
                TurnOn(CameraModes.ThirdPersonView);
            }
            else
            {
                log = "Accelerometer isn't supported by your device";
            }

#if UNITY_EDITOR
            TurnOn(CameraModes.ThirdPersonView);
#endif
        }
        break;

        case CameraModes.FirstPersonViewAcc:
        {
            if (SystemInfo.supportsAccelerometer)
            {
                TurnOn(CameraModes.FirstPersonViewAcc);
            }
            else
            {
                log = "Accelerometer isn't supported by your device";
            }


#if UNITY_EDITOR
            TurnOn(CameraModes.FirstPersonViewAcc);
#endif
        }
        break;

        case CameraModes.StrategyView:
        {
            if (SystemInfo.supportsAccelerometer)
            {
                TurnOn(CameraModes.StrategyView);
            }
            else
            {
                log = "Accelerometer isn't supported by your device";
            }

#if UNITY_EDITOR
            TurnOn(CameraModes.StrategyView);
#endif
        }
        break;
        }
    }
Esempio n. 42
0
 public void setPlayerType(CameraModes PlayerType)
 {
     if (PlayerType == CameraModes.Gunner)
     {
         FireButton.Visible = true;
         CameraMode = PlayerType;
     }
     if (PlayerType == CameraModes.Driver)
     {
         FireButton.Visible = false;
         CameraMode = PlayerType;
     }
 }
Esempio n. 43
0
 private void ViewportControl_MouseUp(object sender, MouseEventArgs e)
 {
     if (this.CameraMode == CameraModes.None)
     {
         if (e.Button == MouseButtons.Left)
         {
             Game.OnMouseEvent(MouseEvent.MouseUp, e);
             return;
         }
     }
     else
     {
         if (e.Button == MouseButtons.Middle || e.Button == MouseButtons.Right)
         {
             this.CameraMode = CameraModes.None;
         }
     }
 }
Esempio n. 44
0
    void LateUpdate()
    {
        float h = Input.GetAxis("Horizontal");
        float v = Input.GetAxis("Vertical");
        float mouseX = Input.GetAxis("Mouse X");
        float mouseY = Input.GetAxis("Mouse Y");
        Vector3 characterOffset = cameraOrigin.position + new Vector3(0f,height,0f);
        Vector3 targetPosition = Vector3.zero;
        //Determine Camera Mode
        if(Input.GetAxis("Target") > 0.01f)
        {
            letterBox.coverage = Mathf.SmoothStep(letterBox.coverage, widescreen, targetTime);
            camState = CameraModes.Target;
        }else{
            letterBox.coverage = Mathf.SmoothStep(letterBox.coverage, 0f, targetTime);
            if(Input.GetButton("Fire1") && System.Math.Round (controller.Speed, 2) == 0)
                camState = CameraModes.Free;
            if((camState==CameraModes.Free && !Input.GetButton("Fire1")) || (camState == CameraModes.Target && (Input.GetAxis ("Target")<=0.01)))
                camState = CameraModes.Behind;
        }

        //Execute Camera State
        switch (camState)
        {
            case CameraModes.Behind:
                //Calculate direction from camera to Player
                lookDir = characterOffset - this.transform.position;
                lookDir.y = 0;
                lookDir.Normalize();
                //Set Camera Position based on Camera Origin transform
                targetPosition = characterOffset + (cameraOrigin.up * height) - (lookDir * distance);
                break;
            case CameraModes.Target:
                lookDir = cameraOrigin.forward;
                targetPosition = characterOffset + (cameraOrigin.up * height) - (lookDir * distance);
                break;
            case CameraModes.Free:
                lookWeight = Mathf.Lerp (lookWeight,0.0f,Time.deltaTime*lookSpeed);
                Vector3 rigToGoalDirection = Vector3.Normalize(characterOffset - this.transform.position);
                rigToGoalDirection.y = 0f;
                Vector3 rigToGoal = characterOffset - parentRig.position;
                rigToGoal.y = 0f;
                //Pan Camera on Mouse Axis
                if((mouseY < -1f * mouseThreshold) && (mouseY<=inputOld.y) && (Mathf.Abs(mouseX) < mouseThreshold))
                {
                    heightFree = Mathf.Lerp(height,height*heightMultiplier,Mathf.Abs(mouseY));
                    distanceFree = Mathf.Lerp(distance,distance*distanceMulitplier,Mathf.Abs(mouseY));
                    targetPosition = characterOffset + (cameraOrigin.up * heightFree) - (rigToGoalDirection * distanceFree);
                }else if((mouseY > mouseThreshold) && (mouseY>=inputOld.y) && (Mathf.Abs(mouseX)<mouseThreshold)){
                    heightFree = Mathf.Lerp(Mathf.Abs(transform.position.y - characterOffset.y),distanceMin.y,mouseY);
                    distanceFree = Mathf.Lerp(rigToGoal.magnitude,distanceMin.x,mouseY);
                    targetPosition = characterOffset + (cameraOrigin.up * heightFree) - (rigToGoalDirection * distanceFree);
                }
                if(mouseX != 0 || mouseY != 0)
                    savedRig = rigToGoalDirection;
                //Rotate Camera around Player
                parentRig.RotateAround(characterOffset,cameraOrigin.up,(freeRotationDegreePerSecond*(Mathf.Abs(mouseX)>mouseThreshold ? mouseX : 0f)));
                if(targetPosition == Vector3.zero)
                    targetPosition = characterOffset + (cameraOrigin.up * heightFree) - (savedRig * distanceFree);
                break;
        }
        //Smooth its Position & Look At the Camera Origin after checking for Colliders
        cameraCollision(characterOffset, ref targetPosition);
        smoothPosition(this.transform.position,targetPosition);
        transform.LookAt(cameraOrigin);
        inputOld = new Vector2(mouseX,mouseY);
    }