Пример #1
0
        /// <summary>
        /// get a point on the curve at value t in worldspace
        /// </summary>
        /// <param name="t"></param>
        /// <returns></returns>
        public Vector3 GetPoint(float t)
        {
            //if our time is a value equal to or greater than 1, return the last curve
            int i;

            if (t >= 1f)
            {
                t = 1f;
                i = points.Length - 4;
            }
            else
            {
                t  = Mathf.Clamp01(t) * CurveCount; //scale our t in proportion to the number of curves we have
                i  = (int)t;
                t -= i;                             //reduce t to get the fractional value
                i *= 3;                             //multiply by 3 (the number of points in a curve) to get the actua point
            }
            return(transform.TransformPoint(Bezier.GetPoint(points[i], points[i + 1], points[i + 2], points[i + 3], t)));
        }
Пример #2
0
 /// <summary>
 /// get a point on the curve at value t in worldspace
 /// </summary>
 /// <param name="t"></param>
 /// <returns></returns>
 public Vector3 GetPoint(float t)
 {
     return(transform.TransformPoint(Bezier.GetPoint(points[0], points[1], points[2], points[3], t)));
 }