public override void OnSwitchToActive(LCamera oldCamera)
        {
            base.OnSwitchToActive(oldCamera);

            Camera.Position = FollowKart.RootNode.ConvertWorldToLocalPosition(oldCamera.CameraNode._getDerivedPosition());
            Camera.Orientation = FollowKart.RootNode.ConvertWorldToLocalOrientation(oldCamera.CameraNode._getDerivedOrientation());
        }
Beispiel #2
0
        public override void OnSwitchToActive(LCamera oldCamera)
        {
            base.OnSwitchToActive(oldCamera);

            Camera.Position = oldCamera.CameraNode._getDerivedPosition();
            Camera.Orientation = oldCamera.CameraNode._getDerivedOrientation();
        }
Beispiel #3
0
        /// <summary>
        ///  set the offset to zero so when we switch back to being active, we don't start zooming off
        /// </summary>
        public override void OnSwitchToInactive(LCamera newCamera)
        {
            base.OnSwitchToInactive(newCamera);

            Offset = Vector3.ZERO;
            moveMultiplier = DEFAULT_MOVE_MULTIPLIER;
            turnMultiplier = DEFAULT_TURN_MULTIPLIER;
        }
Beispiel #4
0
        /// <summary>
        /// make the camera jump to wherever the kart is
        /// </summary>
        public override void OnSwitchToActive(LCamera oldCamera)
        {
            base.OnSwitchToActive(oldCamera);

            var kart = LKernel.GetG<PlayerManager>().MainPlayer.Kart;
            CameraNode.Position = kart.ActualPosition;
            CameraNode.Orientation = kart.ActualOrientation;

            CameraNode.Translate(new Vector3(0, Settings.Default.CameraNodeYOffset, Settings.Default.CameraNodeZOffset), Node.TransformSpace.TS_LOCAL);
            CameraNode.LookAt(kart.ActualPosition, Node.TransformSpace.TS_WORLD);
        }
        /// <summary>
        /// Registers a new camera. This camera must not've already been registered.
        /// If we aren't using a camera yet, this will switch our rendering to use it.
        /// </summary>
        public void RegisterCamera(LCamera newCamera)
        {
            if (cameras.Contains(newCamera)) {
                throw new ArgumentException("Tried to register a camera that was already registered!", "newCamera");
            }
            else if (cameras.Any(c => c.Name == newCamera.Name)) {
                throw new ArgumentException("There is already a camera registered with that name!", "newCamera");
            }
            else {
                cameras.Add(newCamera);

                if (CurrentCamera == null)
                    SwitchCurrentCamera(newCamera);

                if (OnCameraRegistration != null)
                    OnCameraRegistration(newCamera);
            }
        }
        /// <summary>
        /// Switch rendering to another camera. This camera must've already been created and registered.
        /// </summary>
        public void SwitchCurrentCamera(LCamera newCamera)
        {
            if (cameras.Contains(newCamera)) {
                // run this before we switch cameras
                if (OnPreCameraSwitch != null)
                    OnPreCameraSwitch(newCamera);

                // notify the old camera that it is no longer active
                if (CurrentCamera != null)
                    CurrentCamera.OnSwitchToInactive(newCamera);

                var oldCamera = CurrentCamera;
                CurrentCamera = newCamera;
                LKernel.GetG<Viewport>().Camera = newCamera.Camera;

                // notify the new camera that it is active
                newCamera.OnSwitchToActive(oldCamera);

                // run this after we switch cameras
                if (OnPostCameraSwitch != null)
                    OnPostCameraSwitch(newCamera);
            }
            else {
                throw new ApplicationException("Tried to switch to a camera that wasn't registered to the CameraManager!");
            }
        }
 /// <summary>
 /// Disposes all of our cameras and clears our list
 /// </summary>
 void OnLevelUnload(LevelChangedEventArgs eventArgs)
 {
     foreach (LCamera cam in cameras) {
         cam.Dispose();
     }
     cameras.Clear();
     CurrentCamera = null;
 }
        public override void OnSwitchToActive(LCamera oldCamera)
        {
            base.OnSwitchToActive(oldCamera);

            TargetNode.Position = CameraNode.Position;
        }
Beispiel #9
0
 /// <summary>
 /// Is ran when we switch cameras and this one was previously the active camera but isn't any more.
 /// </summary>
 public virtual void OnSwitchToInactive(LCamera newCamera)
 {
     IsActive = false;
     LKernel.GetG<Root>().FrameStarted -= UpdateCamera;
 }
Beispiel #10
0
 /// <summary>
 /// Is ran when we switch cameras and this one becomes the active camera.
 /// </summary>
 public virtual void OnSwitchToActive(LCamera oldCamera)
 {
     IsActive = true;
     LKernel.GetG<Root>().FrameStarted += UpdateCamera;
 }
 /// <summary>
 /// Before we switch cameras we need to disable all compositors
 /// </summary>
 void OnPreCameraSwitch(LCamera cam)
 {
     CompositorManager.Singleton.SetCompositorEnabled(v, "Bloom", false);
 }
 /// <summary>
 /// And afterwards we re-enable them again
 /// </summary>
 void OnPostCameraSwitch(LCamera cam)
 {
     CompositorManager.Singleton.SetCompositorEnabled(v, "Bloom", true);
 }