Пример #1
0
        /// <summary>Notification that this virtual camera is going live.
        /// Base class implementation does nothing.</summary>
        /// <param name="fromCam">The camera being deactivated.  May be null.</param>
        /// <param name="worldUp">Default world Up, set by the CinemachineBrain</param>
        /// <param name="deltaTime">Delta time for time-based effects (ignore if less than or equal to 0)</param>
        /// <returns>True if the vcam should do an internal update as a result of this call</returns>
        public override bool OnTransitionFromCamera(
            ICinemachineCamera fromCam, Vector3 worldUp, float deltaTime,
            ref CinemachineVirtualCameraBase.TransitionParams transitionParams)
        {
            m_HorizontalRecentering.DoRecentering(ref m_HorizontalAxis, -1, 0);
            m_VerticalRecentering.DoRecentering(ref m_VerticalAxis, -1, 0);
            m_HorizontalRecentering.CancelRecentering();
            m_VerticalRecentering.CancelRecentering();
            if (fromCam != null && transitionParams.m_InheritPosition)
            {
                Vector3 up = VcamState.ReferenceUp;
                Quaternion targetRot = fromCam.State.RawOrientation;
                Vector3 fwd = Vector3.forward;
                Transform parent = VirtualCamera.transform.parent;
                if (parent != null)
                    fwd = parent.rotation * fwd;

                m_HorizontalAxis.Value = 0;
                m_HorizontalAxis.Reset();
                Vector3 targetFwd = targetRot * Vector3.forward;
                Vector3 a = fwd.ProjectOntoPlane(up);
                Vector3 b = targetFwd.ProjectOntoPlane(up);
                if (!a.AlmostZero() && !b.AlmostZero())
                    m_HorizontalAxis.Value = Vector3.SignedAngle(a, b, up);

                m_VerticalAxis.Value = 0;
                m_VerticalAxis.Reset();
                fwd = Quaternion.AngleAxis(m_HorizontalAxis.Value, up) * fwd;
                Vector3 right = Vector3.Cross(up, fwd);
                if (!right.AlmostZero())
                    m_VerticalAxis.Value = Vector3.SignedAngle(fwd, targetFwd, right);
                return true;
            }
            return false;
        }
Пример #2
0
 /// <summary>Notification that this virtual camera is going live.
 /// Base class implementation does nothing.</summary>
 /// <param name="fromCam">The camera being deactivated.  May be null.</param>
 /// <param name="worldUp">Default world Up, set by the CinemachineBrain</param>
 /// <param name="deltaTime">Delta time for time-based effects (ignore if less than or equal to 0)</param>
 /// <returns>True if the vcam should do an internal update as a result of this call</returns>
 public override bool OnTransitionFromCamera(
     ICinemachineCamera fromCam, Vector3 worldUp, float deltaTime,
     ref CinemachineVirtualCameraBase.TransitionParams transitionParams)
 {
     if (fromCam != null && transitionParams.m_InheritPosition)
     {
         transform.rotation = fromCam.State.RawOrientation;
         return(true);
     }
     return(false);
 }
Пример #3
0
 /// <summary>Notification that this virtual camera is going live.
 /// Base class implementation does nothing.</summary>
 /// <param name="fromCam">The camera being deactivated.  May be null.</param>
 /// <param name="worldUp">Default world Up, set by the CinemachineBrain</param>
 /// <param name="deltaTime">Delta time for time-based effects (ignore if less than or equal to 0)</param>
 /// <returns>True if the vcam should do an internal update as a result of this call</returns>
 public override bool OnTransitionFromCamera(
     ICinemachineCamera fromCam, Vector3 worldUp, float deltaTime,
     ref CinemachineVirtualCameraBase.TransitionParams transitionParams)
 {
     if (fromCam != null && fromCam.Follow == FollowTarget &&
         m_BindingMode != CinemachineTransposer.BindingMode.SimpleFollowWithWorldUp &&
         transitionParams.m_InheritPosition)
     {
         m_XAxis.Value = GetAxisClosestValue(fromCam.State.RawPosition, worldUp);
         return(true);
     }
     return(false);
 }
Пример #4
0
 /// <summary>Notification that this virtual camera is going live.
 /// Base class implementation does nothing.</summary>
 /// <param name="fromCam">The camera being deactivated.  May be null.</param>
 /// <param name="worldUp">Default world Up, set by the CinemachineBrain</param>
 /// <param name="deltaTime">Delta time for time-based effects (ignore if less than or equal to 0)</param>
 /// <param name="transitionParams">Transition settings for this vcam</param>
 /// <returns>True if the vcam should do an internal update as a result of this call</returns>
 public override bool OnTransitionFromCamera(
     ICinemachineCamera fromCam, Vector3 worldUp, float deltaTime,
     ref CinemachineVirtualCameraBase.TransitionParams transitionParams)
 {
     if (fromCam != null && transitionParams.m_InheritPosition &&
         !CinemachineCore.Instance.IsLiveInBlend(VirtualCamera))
     {
         m_PreviousCameraPosition = fromCam.State.RawPosition;
         m_prevRotation           = fromCam.State.RawOrientation;
         InheritingPosition       = true;
         return(true);
     }
     return(false);
 }
Пример #5
0
 /// <summary>Notification that this virtual camera is going live.
 /// Base class implementation does nothing.</summary>
 /// <param name="fromCam">The camera being deactivated.  May be null.</param>
 /// <param name="worldUp">Default world Up, set by the CinemachineBrain</param>
 /// <param name="deltaTime">Delta time for time-based effects (ignore if less than or equal to 0)</param>
 /// <returns>True if the vcam should do an internal update as a result of this call</returns>
 public override bool OnTransitionFromCamera(
     ICinemachineCamera fromCam, Vector3 worldUp, float deltaTime,
     ref CinemachineVirtualCameraBase.TransitionParams transitionParams)
 {
     m_HorizontalRecentering.DoRecentering(ref m_HorizontalAxis, -1, 0);
     m_VerticalRecentering.DoRecentering(ref m_VerticalAxis, -1, 0);
     m_HorizontalRecentering.CancelRecentering();
     m_VerticalRecentering.CancelRecentering();
     if (fromCam != null && transitionParams.m_InheritPosition)
     {
         SetAxesForRotation(fromCam.State.RawOrientation);
         return(true);
     }
     return(false);
 }
 /// <summary>Notification that this virtual camera is going live.
 /// Base class implementation does nothing.</summary>
 /// <param name="fromCam">The camera being deactivated.  May be null.</param>
 /// <param name="worldUp">Default world Up, set by the CinemachineBrain</param>
 /// <param name="deltaTime">Delta time for time-based effects (ignore if less than or equal to 0)</param>
 /// <param name="transitionParams">Transition settings for this vcam</param>
 /// <returns>True if the vcam should do an internal update as a result of this call</returns>
 public override bool OnTransitionFromCamera(
     ICinemachineCamera fromCam, Vector3 worldUp, float deltaTime,
     ref CinemachineVirtualCameraBase.TransitionParams transitionParams)
 {
     m_RecenterToTargetHeading.DoRecentering(ref m_XAxis, -1, 0);
     m_RecenterToTargetHeading.CancelRecentering();
     if (fromCam != null && //&& fromCam.Follow == FollowTarget
         m_BindingMode != CinemachineTransposer.BindingMode.SimpleFollowWithWorldUp &&
         transitionParams.m_InheritPosition &&
         !CinemachineCore.Instance.IsLiveInBlend(VirtualCamera))
     {
         m_XAxis.Value = GetAxisClosestValue(fromCam.State.RawPosition, worldUp);
         return(true);
     }
     return(false);
 }
 /// <summary>Notification that this virtual camera is going live.
 /// Base class implementation does nothing.</summary>
 /// <param name="fromCam">The camera being deactivated.  May be null.</param>
 /// <param name="worldUp">Default world Up, set by the CinemachineBrain</param>
 /// <param name="deltaTime">Delta time for time-based effects (ignore if less than or equal to 0)</param>
 /// <returns>True if the vcam should do an internal update as a result of this call</returns>
 public virtual bool OnTransitionFromCamera(
     ICinemachineCamera fromCam, Vector3 worldUp, float deltaTime,
     ref CinemachineVirtualCameraBase.TransitionParams transitionParams)
 {
     return(false);
 }