Пример #1
0
    public static Vector3 SampleAlongSplineSegment(UnityEngine.U2D.Spline spline, int segmentNumber, float t)
    {
        int     b            = (int)Mathf.Repeat(segmentNumber + 1, spline.GetPointCount());
        Vector3 startPoint   = spline.GetPosition(segmentNumber);
        Vector3 startTangent = startPoint + spline.GetRightTangent(segmentNumber);
        Vector3 endPoint     = spline.GetPosition(b);
        Vector3 endTangent   = endPoint + spline.GetLeftTangent(b);

        return(UnityEngine.U2D.BezierUtility.BezierPoint(startPoint, startTangent, endTangent, endPoint, t));
    }
Пример #2
0
    public static List <Vector2> ParameterizeSpline(UnityEngine.U2D.Spline spline, float resolution, bool closed)
    {
        resolution = Mathf.Abs(resolution);
        if (resolution == Mathf.Infinity)
        {
            return(null);
        }
        List <Vector2> path = new List <Vector2>();

        for (int i = 0; i < spline.GetPointCount() - (closed ? 0 : 1); i++)
        {
            for (float t = 0.0f; t < 1; t += 1.0f / resolution)
            {
                path.Add(SampleAlongSplineSegment(spline, i, t));
            }
        }
        return(path);
    }
Пример #3
0
 public void Init()
 {
     grapheNoeuds = new List <NoeudFleuve>();
     ssController = GetComponent <UnityEngine.U2D.SpriteShapeController>();
     spline       = ssController.spline;
 }