/// <summary>
        /// Returns the local position of the camera along the spline used to connect the
        /// three camera rigs. Does not take into account the current heading of the
        /// camera (or its target)
        /// </summary>
        /// <param name="t">The t-value for the camera on its spline. Internally clamped to
        /// the value [0,1]</param>
        /// <returns>The local offset (back + up) of the camera WRT its target based on the
        /// supplied t-value</returns>
        public Vector3 GetLocalPositionForCameraFromInput(float t)
        {
            UpdateCachedSpline();
            int n = 1;

            if (t > 0.5f)
            {
                t -= 0.5f;
                n  = 2;
            }
            Vector3 pos = SplineHelpers.Bezier3(
                t * 2f, m_CachedKnots[n], m_CachedCtrl1[n], m_CachedCtrl2[n], m_CachedKnots[n + 1]);

            pos *= Mathf.Max(0, m_RadialAxis.Value);
            return(pos);
        }
Пример #2
0
        public Vector3 GetLocalPositionForCameraFromInput(float t)
        {
            if (this.mOrbitals == null)
            {
                return(Vector3.zero);
            }
            this.UpdateCachedSpline();
            int num = 1;

            if (t > 0.5f)
            {
                t  -= 0.5f;
                num = 2;
            }
            return(SplineHelpers.Bezier3(t * 2f, this.m_CachedKnots[num], this.m_CachedCtrl1[num], this.m_CachedCtrl2[num], this.m_CachedKnots[num + 1]));
        }
Пример #3
0
        /// <summary>
        /// Returns the local position of the camera along the spline used to connect the
        /// three camera rigs. Does not take into account the current heading of the
        /// camera (or its target)
        /// </summary>
        /// <param name="t">The t-value for the camera on its spline. Internally clamped to
        /// the value [0,1]</param>
        /// <returns>The local offset (back + up) of the camera WRT its target based on the
        /// supplied t-value</returns>
        public Vector3 GetLocalPositionForCameraFromInput(float t)
        {
            //UnityEngine.Profiling.Profiler.BeginSample("CinemachineFreeLook.GetLocalPositionForCameraFromInput");
            if (mOrbitals == null)
            {
                //UnityEngine.Profiling.Profiler.EndSample();
                return(Vector3.zero);
            }
            UpdateCachedSpline();
            int n = 1;

            if (t > 0.5f)
            {
                t -= 0.5f;
                n  = 2;
            }
            //UnityEngine.Profiling.Profiler.EndSample();
            return(SplineHelpers.Bezier3(
                       t * 2f, m_CachedKnots[n], m_CachedCtrl1[n], m_CachedCtrl2[n], m_CachedKnots[n + 1]));
        }
Пример #4
0
        public override Vector3 EvaluatePosition(float pos)
        {
            Vector3 position = Vector3.zero;

            if (this.m_Waypoints.Length != 0)
            {
                this.UpdateControlPoints();
                int num;
                int num2;
                pos = this.GetBoundingIndices(pos, out num, out num2);
                if (num == num2)
                {
                    position = this.m_Waypoints[num].position;
                }
                else
                {
                    position = SplineHelpers.Bezier3(pos - (float)num, this.m_Waypoints[num].position, this.m_ControlPoints1[num].position, this.m_ControlPoints2[num].position, this.m_Waypoints[num2].position);
                }
            }
            return(base.transform.TransformPoint(position));
        }
Пример #5
0
        /// <summary>Get a worldspace position of a point along the path</summary>
        /// <param name="pos">Position along the path.  Need not be normalized.</param>
        /// <returns>World-space position of the point along at path at pos</returns>
        public override Vector3 EvaluatePosition(float pos)
        {
            Vector3 result = Vector3.zero;

            if (m_Waypoints.Length > 0)
            {
                UpdateControlPoints();
                int indexA, indexB;
                pos = GetBoundingIndices(pos, out indexA, out indexB);
                if (indexA == indexB)
                {
                    result = m_Waypoints[indexA].position;
                }
                else
                {
                    result = SplineHelpers.Bezier3(pos - indexA,
                                                   m_Waypoints[indexA].position, m_ControlPoints1[indexA].position,
                                                   m_ControlPoints2[indexA].position, m_Waypoints[indexB].position);
                }
            }
            return(transform.TransformPoint(result));
        }
Пример #6
0
 /// <summary>Get a worldspace position of a point along the path</summary>
 /// <param name="pos">Postion along the path.  Need not be normalized.</param>
 /// <returns>World-space position of the point along at path at pos</returns>
 public override Vector3 EvaluatePosition(float pos)
 {
     Vector3 result = new Vector3();
     if (m_Waypoints.Length == 0)
         result = transform.position;
     else
     {
         int indexA, indexB;
         pos = GetBoundingIndices(pos, out indexA, out indexB);
         if (indexA == indexB)
             result = m_Waypoints[indexA].position;
         else
         {
             // interpolate
             Waypoint wpA = m_Waypoints[indexA];
             Waypoint wpB = m_Waypoints[indexB];
             result = SplineHelpers.Bezier3(pos - indexA,
                 m_Waypoints[indexA].position, wpA.position + wpA.tangent,
                 wpB.position - wpB.tangent, wpB.position);
         }
     }
     return transform.TransformPoint(result);
 }