示例#1
0
        /// <summary>
        /// Creates a new LensSettings, copying the values from the
        /// supplied Camera
        /// </summary>
        /// <param name="fromCamera">The Camera from which the FoV, near
        /// and far clip planes will be copied.</param>
        public static LensSettings FromCamera(Camera fromCamera)
        {
            LensSettings lens = Default;

            if (fromCamera != null)
            {
                lens.FieldOfView      = fromCamera.fieldOfView;
                lens.OrthographicSize = fromCamera.orthographicSize;
                lens.NearClipPlane    = fromCamera.nearClipPlane;
                lens.FarClipPlane     = fromCamera.farClipPlane;
#if UNITY_2018_2_OR_NEWER
                lens.LensShift = fromCamera.lensShift;
#endif
                lens.SnapshotCameraReadOnlyProperties(fromCamera);
            }
            return(lens);
        }
示例#2
0
        /// <summary>
        /// Create a camera state based on the current transform of this vcam
        /// </summary>
        /// <param name="worldUp">Current World Up direction, as provided by the brain</param>
        /// <param name="lens">Lens settings to serve as base, will be combined with lens from brain, if any</param>
        /// <returns></returns>
        protected CameraState PullStateFromVirtualCamera(Vector3 worldUp, ref LensSettings lens)
        {
            CameraState state = CameraState.Default;

            state.RawPosition    = TargetPositionCache.GetTargetPosition(transform);
            state.RawOrientation = TargetPositionCache.GetTargetRotation(transform);
            state.ReferenceUp    = worldUp;

            CinemachineBrain brain = CinemachineCore.Instance.FindPotentialTargetBrain(this);

            if (brain != null)
            {
                lens.SnapshotCameraReadOnlyProperties(brain.OutputCamera);
            }

            state.Lens = lens;
            return(state);
        }
示例#3
0
        /// <summary>
        /// Creates a new LensSettings, copying the values from the
        /// supplied Camera
        /// </summary>
        /// <param name="fromCamera">The Camera from which the FoV, near
        /// and far clip planes will be copied.</param>
        public static LensSettings FromCamera(Camera fromCamera)
        {
            LensSettings lens = Default;

            if (fromCamera != null)
            {
                lens.FieldOfView      = fromCamera.fieldOfView;
                lens.OrthographicSize = fromCamera.orthographicSize;
                lens.NearClipPlane    = fromCamera.nearClipPlane;
                lens.FarClipPlane     = fromCamera.farClipPlane;
#if UNITY_2018_2_OR_NEWER
                lens.LensShift = fromCamera.lensShift;
#endif
                lens.SnapshotCameraReadOnlyProperties(fromCamera);

#if CINEMACHINE_HDRP
                if (lens.IsPhysicalCamera)
                {
                    var pc = new HDPhysicalCamera();
#if UNITY_2019_2_OR_NEWER
                    fromCamera.TryGetComponent <HDAdditionalCameraData>(out var hda);
#else
                    var hda = fromCamera.GetComponent <HDAdditionalCameraData>();
#endif
                    if (hda != null)
                    {
                        pc = hda.physicalParameters;
                    }
                    lens.Iso            = pc.iso;
                    lens.ShutterSpeed   = pc.shutterSpeed;
                    lens.Aperture       = pc.aperture;
                    lens.BladeCount     = pc.bladeCount;
                    lens.Curvature      = pc.curvature;
                    lens.BarrelClipping = pc.barrelClipping;
                    lens.Anamorphism    = pc.anamorphism;
                }
#endif
            }
            return(lens);
        }