예제 #1
0
        protected override Vector3 GetPointInternal(float normalizedDistance)
        {
            float totalDistance = normalizedDistance * (NumPoints - 1);

            int point1Index = Mathf.FloorToInt(totalDistance);

            point1Index -= (point1Index % 3);
            float subDistance = (totalDistance - point1Index) / 3;

            int point2Index = 0;
            int point3Index = 0;
            int point4Index = 0;

            if (!loops)
            {
                if (point1Index + 3 >= NumPoints)
                {
                    return(points[NumPoints - 1].Point);
                }
                if (point1Index < 0)
                {
                    return(points[0].Point);
                }

                point2Index = point1Index + 1;
                point3Index = point1Index + 2;
                point4Index = point1Index + 3;
            }
            else
            {
                point2Index = (point1Index + 1) % (NumPoints - 1);
                point3Index = (point1Index + 2) % (NumPoints - 1);
                point4Index = (point1Index + 3) % (NumPoints - 1);
            }

            Vector3 point1 = points[point1Index].Point;
            Vector3 point2 = points[point2Index].Point;
            Vector3 point3 = points[point3Index].Point;
            Vector3 point4 = points[point4Index].Point;

            return(LineUtils.InterpolateBezeirPoints(point1, point2, point3, point4, subDistance));
        }
예제 #2
0
 protected override Vector3 GetPointInternal(float normalizedDistance)
 {
     return(LineUtils.InterpolateBezeirPoints(points.Point1, points.Point2, points.Point3, points.Point4, normalizedDistance));
 }