Beispiel #1
0
 public ICameraController ActiveCameraControllerForView()
 {
     var camMode = _camMode;
     if (_cameraImpls[(int)camMode] == null)
     {
         switch (camMode)
         {
             case CameraMode.Fps:
                 _cameraImpls[(int)camMode] = new FpsCameraController();
                 break;
             case CameraMode.X:
             case CameraMode.Y:
             case CameraMode.Z:
             case CameraMode.Orbit:
                 var orbit = new OrbitCameraController(camMode);
                 _cameraImpls[(int)CameraMode.X] = orbit;
                 _cameraImpls[(int)CameraMode.Y] = orbit;
                 _cameraImpls[(int)CameraMode.Z] = orbit;
                 _cameraImpls[(int)CameraMode.Orbit] = orbit;
                 break;
             case CameraMode.Pick:
                 _cameraImpls[(int)camMode] = new PickingCameraController();
                 break;
             default:
                 Debug.Assert(false);
                 break;
         }
     }
     return _cameraImpls[(int)camMode];
 }
Beispiel #2
0
        public ICameraController ActiveCameraControllerForView()
        {
            var camMode = _camMode;

            if (_cameraImpls[(int)camMode] == null)
            {
                switch (camMode)
                {
                case CameraMode.Fps:
                    _cameraImpls[(int)camMode] = new FpsCameraController(_fovy, _scenePartMode);
                    break;

                case CameraMode.X:
                case CameraMode.Y:
                case CameraMode.Z:
                case CameraMode.Orbit:
                    var orbit = new OrbitCameraController(camMode, _fovy, _scenePartMode);
                    _cameraImpls[(int)CameraMode.X]     = orbit;
                    _cameraImpls[(int)CameraMode.Y]     = orbit;
                    _cameraImpls[(int)CameraMode.Z]     = orbit;
                    _cameraImpls[(int)CameraMode.Orbit] = orbit;
                    break;

                case CameraMode.HMD:
                case CameraMode.Cont1:
                case CameraMode.Cont2:
                    var vrcont = new PickingCameraController(camMode, _fovy, _scenePartMode);
                    _cameraImpls[(int)CameraMode.HMD]   = vrcont;
                    _cameraImpls[(int)CameraMode.Cont1] = vrcont;
                    _cameraImpls[(int)CameraMode.Cont2] = vrcont;
                    break;

                default:
                    Debug.Assert(false);
                    break;
                }
            }
            return(_cameraImpls[(int)camMode]);
        }
Beispiel #3
0
        public void ChangeCameraModeForView(CameraMode cameraMode)
        {
            if(_camMode == cameraMode)
            {
                return;
            }

            var oldCam = _cameraImpls[(int) _camMode];

            // when changing to the picking camera mode, preserve the old view matrix
            if (cameraMode == CameraMode.Pick)
            {
                Debug.Assert(oldCam != null);
                if (_cameraImpls[(int)cameraMode] == null)
                {
                    _cameraImpls[(int)cameraMode] = new PickingCameraController();
                }
                var picker = (PickingCameraController)_cameraImpls[(int)cameraMode];
                picker.SetView(oldCam.GetView());
            }

            _camMode = cameraMode;

            // special handling to switch the orbit camera controller between the x,y,z and full orbit modes
            if (cameraMode == CameraMode.Z || cameraMode == CameraMode.Y || cameraMode == CameraMode.X || cameraMode == CameraMode.Orbit)
            {
                if (_cameraImpls[(int)CameraMode.Orbit] == null)
                {
                    return;
                }

                var orbit = _cameraImpls[(int)CameraMode.Orbit] as OrbitCameraController;
                Debug.Assert(orbit != null);

                orbit.SetOrbitOrConstrainedMode(cameraMode);
            } 
        }
Beispiel #4
0
 public ICameraController ActiveCameraControllerForView()
 {
     var camMode = _camMode;
     if (_cameraImpls[(int)camMode] == null)
     {
         switch (camMode)
         {
             case CameraMode.Fps:
                 _cameraImpls[(int)camMode] = new FpsCameraController();
                 break;
             case CameraMode.X:
             case CameraMode.Y:
             case CameraMode.Z:
             case CameraMode.Orbit:
                 var orbit = new OrbitCameraController(camMode);
                 _cameraImpls[(int)CameraMode.X] = orbit;
                 _cameraImpls[(int)CameraMode.Y] = orbit;
                 _cameraImpls[(int)CameraMode.Z] = orbit;
                 _cameraImpls[(int)CameraMode.Orbit] = orbit;
                 break;
             case CameraMode.Pick:
                 _cameraImpls[(int)camMode] = new PickingCameraController();
                 break;
             default:
                 Debug.Assert(false);
                 break;
         }
     }
     return _cameraImpls[(int)camMode];
 }
Beispiel #5
0
        public void ChangeCameraModeForView(CameraMode cameraMode)
        {
            if(_camMode == cameraMode)
            {
                return;
            }

            var oldCam = _cameraImpls[(int) _camMode];

            // when changing to the picking camera mode, preserve the old view matrix
            if (cameraMode == CameraMode.Pick)
            {
                Debug.Assert(oldCam != null);
                if (_cameraImpls[(int)cameraMode] == null)
                {
                    _cameraImpls[(int)cameraMode] = new PickingCameraController();
                }
                var picker = (PickingCameraController)_cameraImpls[(int)cameraMode];
                picker.SetView(oldCam.GetView());
            }

            _camMode = cameraMode;

            // special handling to switch the orbit camera controller between the x,y,z and full orbit modes
            if (cameraMode == CameraMode.Z || cameraMode == CameraMode.Y || cameraMode == CameraMode.X || cameraMode == CameraMode.Orbit)
            {
                if (_cameraImpls[(int)CameraMode.Orbit] == null)
                {
                    return;
                }

                var orbit = _cameraImpls[(int)CameraMode.Orbit] as OrbitCameraController;
                Debug.Assert(orbit != null);

                orbit.SetOrbitOrConstrainedMode(cameraMode);
            } 
        }