Example #1
0
 public void OnDrawGizmos()
 {
     if (this.points.Length >= 3)
     {
         for (int i = 0; i < this.points.Length; i++)
         {
             if (this.points[i] == null)
             {
                 return;
             }
         }
         for (int j = 0; j < this.points.Length; j++)
         {
             int     num         = this.points.Length;
             Vector3 normalized  = ((this.points[(j + 1) % num].position - this.points[j].position).normalized - (this.points[(j - 1 + num) % num].position - this.points[j].position).normalized).normalized;
             Vector3 normalized2 = ((this.points[(j + 2) % num].position - this.points[(j + 1) % num].position).normalized - (this.points[(j + num) % num].position - this.points[(j + 1) % num].position).normalized).normalized;
             Vector3 from        = this.points[j].position;
             for (int k = 1; k <= 100; k++)
             {
                 Vector3 vector = AstarMath.CubicBezier(this.points[j].position, this.points[j].position + normalized * this.tangentLengths, this.points[(j + 1) % num].position - normalized2 * this.tangentLengths, this.points[(j + 1) % num].position, (float)k / 100f);
                 Gizmos.DrawLine(from, vector);
                 from = vector;
             }
         }
     }
 }
Example #2
0
    public void OnDrawGizmos()
    {
        if (points.Length >= 3)
        {
            for (int i = 0; i < points.Length; i++)
            {
                if (points[i] == null)
                {
                    return;
                }
            }

            for (int pt = 0; pt < points.Length; pt++)
            {
                int     c      = points.Length;
                Vector3 inTang = ((points[(pt + 1) % c].position - points[pt + 0].position).normalized - (points[(pt - 1 + c) % c].position - points[pt + 0].position).normalized).normalized;

                Vector3 outTang = ((points[(pt + 2) % c].position - points[(pt + 1) % c].position).normalized - (points[(pt - 0 + c) % c].position - points[(pt + 1) % c].position).normalized).normalized;

                Vector3 pp = points[pt].position;

                for (int i = 1; i <= 100; i++)
                {
                    Vector3 p = AstarMath.CubicBezier(points[pt].position, points[pt].position + inTang * tangentLengths, points[(pt + 1) % c].position - outTang * tangentLengths, points[(pt + 1) % c].position, i / 100.0f);
                    Gizmos.DrawLine(pp, p);
                    pp = p;
                }
            }
        }
    }
Example #3
0
    private Vector3 Plot(float t)
    {
        int     num         = this.points.Length;
        int     num2        = Mathf.FloorToInt(t);
        Vector3 normalized  = ((this.points[(num2 + 1) % num].position - this.points[num2 % num].position).normalized - (this.points[(num2 - 1 + num) % num].position - this.points[num2 % num].position).normalized).normalized;
        Vector3 normalized2 = ((this.points[(num2 + 2) % num].position - this.points[(num2 + 1) % num].position).normalized - (this.points[(num2 + num) % num].position - this.points[(num2 + 1) % num].position).normalized).normalized;

        Debug.DrawLine(this.points[num2 % num].position, this.points[num2 % num].position + normalized * this.tangentLengths, Color.red);
        Debug.DrawLine(this.points[(num2 + 1) % num].position - normalized2 * this.tangentLengths, this.points[(num2 + 1) % num].position, Color.green);
        return(AstarMath.CubicBezier(this.points[num2 % num].position, this.points[num2 % num].position + normalized * this.tangentLengths, this.points[(num2 + 1) % num].position - normalized2 * this.tangentLengths, this.points[(num2 + 1) % num].position, t - (float)num2));
    }
Example #4
0
    Vector3 Plot(float t)
    {
        Vector3 inTang, outTang;


        int c  = points.Length;
        int pt = Mathf.FloorToInt(t);

        inTang = ((points[(pt + 1) % c].position - points[(pt + 0) % c].position).normalized - (points[(pt - 1 + c) % c].position - points[(pt + 0) % c].position).normalized).normalized;

        outTang = ((points[(pt + 2) % c].position - points[(pt + 1) % c].position).normalized - (points[(pt - 0 + c) % c].position - points[(pt + 1) % c].position).normalized).normalized;

        Debug.DrawLine(points[pt % c].position, points[pt % c].position + inTang * tangentLengths, Color.red);
        Debug.DrawLine(points[(pt + 1) % c].position - outTang * tangentLengths, points[(pt + 1) % c].position, Color.green);

        return(AstarMath.CubicBezier(points[pt % c].position, points[pt % c].position + inTang * tangentLengths, points[(pt + 1) % c].position - outTang * tangentLengths, points[(pt + 1) % c].position, t - pt));
    }