예제 #1
0
        public void Bezier(Vector3 a, Vector3 b, Color color)
        {
            Vector3 dir = b - a;

            if (dir == Vector3.zero)
            {
                return;
            }

            Vector3 normal   = Vector3.Cross(Vector3.up, dir);
            Vector3 normalUp = Vector3.Cross(dir, normal);

            normalUp  = normalUp.normalized;
            normalUp *= dir.magnitude * 0.1f;

            Vector3 p1c = a + normalUp;
            Vector3 p2c = b + normalUp;

            Vector3 prev = a;

            for (int i = 1; i <= 20; i++)
            {
                float   t = i / 20.0f;
                Vector3 p = AstarSplines.CubicBezier(a, p1c, p2c, b, t);
                Line(prev, p, color);
                prev = p;
            }
        }
예제 #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 = AstarSplines.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;
                }
            }
        }
    }
예제 #3
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 = AstarSplines.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;
             }
         }
     }
 }
예제 #4
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     length     = this.points.Length;
             Vector3 vector5    = this.points[(j + 1) % length].position - this.points[j].position;
             Vector3 vector6    = this.points[((j - 1) + length) % length].position - this.points[j].position;
             Vector3 vector7    = vector5.normalized - vector6.normalized;
             Vector3 normalized = vector7.normalized;
             Vector3 vector8    = this.points[(j + 2) % length].position - this.points[(j + 1) % length].position;
             Vector3 vector9    = this.points[(j + length) % length].position - this.points[(j + 1) % length].position;
             Vector3 vector10   = vector8.normalized - vector9.normalized;
             Vector3 vector2    = vector10.normalized;
             Vector3 position   = this.points[j].position;
             for (int k = 1; k <= 100; k++)
             {
                 Vector3 to = AstarSplines.CubicBezier(this.points[j].position, this.points[j].position + ((Vector3)(normalized * this.tangentLengths)), this.points[(j + 1) % length].position - ((Vector3)(vector2 * this.tangentLengths)), this.points[(j + 1) % length].position, ((float)k) / 100f);
                 Gizmos.DrawLine(position, to);
                 position = to;
             }
         }
     }
 }
예제 #5
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 AstarSplines.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);
		}
예제 #6
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(AstarSplines.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));
    }
예제 #7
0
        private Vector3 Plot(float t)
        {
            int     length     = this.points.Length;
            int     num2       = Mathf.FloorToInt(t);
            Vector3 vector3    = this.points[(num2 + 1) % length].position - this.points[num2 % length].position;
            Vector3 vector4    = this.points[((num2 - 1) + length) % length].position - this.points[num2 % length].position;
            Vector3 vector5    = vector3.normalized - vector4.normalized;
            Vector3 normalized = vector5.normalized;
            Vector3 vector6    = this.points[(num2 + 2) % length].position - this.points[(num2 + 1) % length].position;
            Vector3 vector7    = this.points[(num2 + length) % length].position - this.points[(num2 + 1) % length].position;
            Vector3 vector8    = vector6.normalized - vector7.normalized;
            Vector3 vector2    = vector8.normalized;

            Debug.DrawLine(this.points[num2 % length].position, this.points[num2 % length].position + ((Vector3)(normalized * this.tangentLengths)), Color.red);
            Debug.DrawLine(this.points[(num2 + 1) % length].position - ((Vector3)(vector2 * this.tangentLengths)), this.points[(num2 + 1) % length].position, Color.green);
            return(AstarSplines.CubicBezier(this.points[num2 % length].position, this.points[num2 % length].position + ((Vector3)(normalized * this.tangentLengths)), this.points[(num2 + 1) % length].position - ((Vector3)(vector2 * this.tangentLengths)), this.points[(num2 + 1) % length].position, t - num2));
        }
예제 #8
0
        // Token: 0x06002903 RID: 10499 RVA: 0x001BACF8 File Offset: 0x001B8EF8
        public void Bezier(Vector3 a, Vector3 b, Color color)
        {
            Vector3 vector = b - a;

            if (vector == Vector3.zero)
            {
                return;
            }
            Vector3 rhs     = Vector3.Cross(Vector3.up, vector);
            Vector3 vector2 = Vector3.Cross(vector, rhs).normalized;

            vector2 *= vector.magnitude * 0.1f;
            Vector3 p  = a + vector2;
            Vector3 p2 = b + vector2;
            Vector3 a2 = a;

            for (int i = 1; i <= 20; i++)
            {
                float   t       = (float)i / 20f;
                Vector3 vector3 = AstarSplines.CubicBezier(a, p, p2, b, t);
                this.Line(a2, vector3, color);
                a2 = vector3;
            }
        }