Esempio n. 1
0
    public Vector3[] GetPathOnRightLine(int resolution)
    {
        // Making start node calculate
        if (PreviousPole != null)
        {
            return(StartPole.GetPathOnRightLine(resolution));
        }

        Vector3[] path = new Vector3[resolution + 1];
        for (int i = 0; i < path.Length; i++)
        {
            path[i] = GetPointOnRightLine((1f / resolution) * i);
        }

        return(path);
    }
Esempio n. 2
0
    public Vector3 GetPointOnRightLine(float time)
    {
        // Making start node calculate
        if (PreviousPole != null)
        {
            return(StartPole.GetPointOnRightLine(time));
        }

        // Segment Maths
        time *= (PoleList.Count - 1);
        int   segment = (int)Mathf.Clamp(time, 0, PoleList.Count - 2);
        float t       = time - segment;

        // Curve Maths
        float it  = 1f - t;
        float it2 = it * it;
        float t2  = t * t;

        return(PoleList[segment].RightConnector * (it2 * it) +
               PoleList[segment].ForwardPointRight * (3f * it2 * t) +
               PoleList[segment + 1].BackwardPointRight * (3f * it * t2) +
               PoleList[segment + 1].RightConnector * (t2 * t));
    }