Exemple #1
0
        public void OnDrawGizmos(bool selected)
        {
            this.gizmoDrawing = true;
            Gizmos.color      = new Color(0.615f, 1f, 0.06f, !selected ? 0.7f : 1f);
            if (((this.gizmoVerts == null) || this.AreGizmosDirty()) || (this._obstacleMode != this.obstacleMode))
            {
                this._obstacleMode = this.obstacleMode;
                if (this.gizmoVerts == null)
                {
                    this.gizmoVerts = new List <VInt3[]>();
                }
                else
                {
                    this.gizmoVerts.Clear();
                }
                this.CreateObstacles();
            }
            Matrix4x4 matrix = this.GetMatrix();

            for (int i = 0; i < this.gizmoVerts.Count; i++)
            {
                VInt3[] numArray = this.gizmoVerts[i];
                int     index    = 0;
                for (int j = numArray.Length - 1; index < numArray.Length; j = index++)
                {
                    Vector3 from = matrix.MultiplyPoint3x4((Vector3)numArray[index]);
                    Gizmos.DrawLine(from, matrix.MultiplyPoint3x4((Vector3)numArray[j]));
                }
                if (selected)
                {
                    float num4 = this.Height * 0.001f;
                    int   num5 = 0;
                    for (int k = numArray.Length - 1; num5 < numArray.Length; k = num5++)
                    {
                        Gizmos.DrawLine(matrix.MultiplyPoint3x4((Vector3)numArray[num5]) + ((Vector3)(Vector3.up * num4)), matrix.MultiplyPoint3x4((Vector3)numArray[k]) + ((Vector3)(Vector3.up * num4)));
                        Vector3 introduced17 = matrix.MultiplyPoint3x4((Vector3)numArray[num5]);
                        Gizmos.DrawLine(introduced17, matrix.MultiplyPoint3x4((Vector3)numArray[num5]) + ((Vector3)(Vector3.up * num4)));
                    }
                    int num7 = 0;
                    for (int m = numArray.Length - 1; num7 < numArray.Length; m = num7++)
                    {
                        Vector3 vector     = matrix.MultiplyPoint3x4((Vector3)numArray[m]);
                        Vector3 vector2    = matrix.MultiplyPoint3x4((Vector3)numArray[num7]);
                        Vector3 vector3    = (Vector3)((vector + vector2) * 0.5f);
                        Vector3 vector6    = vector2 - vector;
                        Vector3 normalized = vector6.normalized;
                        if (normalized != Vector3.zero)
                        {
                            Vector3 vector5 = Vector3.Cross(Vector3.up, normalized);
                            Gizmos.DrawLine(vector3, vector3 + vector5);
                            Gizmos.DrawLine(vector3 + vector5, (Vector3)((vector3 + (vector5 * 0.5f)) + (normalized * 0.5f)));
                            Gizmos.DrawLine(vector3 + vector5, (Vector3)((vector3 + (vector5 * 0.5f)) - (normalized * 0.5f)));
                        }
                    }
                }
            }
            this.gizmoDrawing = false;
        }
Exemple #2
0
    /** Draws Gizmos */
    public void OnDrawGizmos(bool selected)
    {
        gizmoDrawing = true;

        Gizmos.color = new Color(0.615f, 1, 0.06f, selected ? 1.0f : 0.7f);

        if (gizmoVerts == null || AreGizmosDirty() || _obstacleMode != obstacleMode)
        {
            _obstacleMode = obstacleMode;

            if (gizmoVerts == null)
            {
                gizmoVerts = new List <Vector3[]>();
            }
            else
            {
                gizmoVerts.Clear();
            }

            CreateObstacles();
        }

        Matrix4x4 m = GetMatrix();

        for (int i = 0; i < gizmoVerts.Count; i++)
        {
            Vector3[] verts = gizmoVerts[i];
            for (int j = 0, q = verts.Length - 1; j < verts.Length; q = j++)
            {
                Gizmos.DrawLine(m.MultiplyPoint3x4(verts[j]), m.MultiplyPoint3x4(verts[q]));
            }

            if (selected && obstacleMode != ObstacleVertexWinding.Both)
            {
                for (int j = 0, q = verts.Length - 1; j < verts.Length; q = j++)
                {
                    Vector3 a = m.MultiplyPoint3x4(verts[q]);
                    Vector3 b = m.MultiplyPoint3x4(verts[j]);

                    Vector3 avg  = (a + b) * 0.5f;
                    Vector3 tang = (b - a).normalized;
                    if (tang == Vector3.zero)
                    {
                        continue;
                    }

                    Vector3 normal = Vector3.Cross(Vector3.up, tang);

                    Gizmos.DrawLine(avg, avg + normal);
                    Gizmos.DrawLine(avg + normal, avg + normal * 0.5f + tang * 0.5f);
                    Gizmos.DrawLine(avg + normal, avg + normal * 0.5f - tang * 0.5f);
                }
            }
        }

        gizmoDrawing = false;
    }
Exemple #3
0
        /// <summary>Draws Gizmos</summary>
        public void OnDrawGizmos(bool selected)
        {
            gizmoDrawing = true;

            Gizmos.color = new Color(0.615f, 1, 0.06f, selected ? 1.0f : 0.7f);
            var movementPlane = RVOSimulator.active != null ? RVOSimulator.active.movementPlane : MovementPlane.XZ;
            var up            = movementPlane == MovementPlane.XZ ? Vector3.up : -Vector3.forward;

            if (gizmoVerts == null || AreGizmosDirty() || _obstacleMode != obstacleMode)
            {
                _obstacleMode = obstacleMode;

                if (gizmoVerts == null)
                {
                    gizmoVerts = new List <Vector3[]>();
                }
                else
                {
                    gizmoVerts.Clear();
                }

                CreateObstacles();
            }

            Matrix4x4 m = GetMatrix();

            for (int i = 0; i < gizmoVerts.Count; i++)
            {
                Vector3[] verts = gizmoVerts[i];
                for (int j = 0, q = verts.Length - 1; j < verts.Length; q = j++)
                {
                    Gizmos.DrawLine(m.MultiplyPoint3x4(verts[j]), m.MultiplyPoint3x4(verts[q]));
                }

                if (selected)
                {
                    for (int j = 0, q = verts.Length - 1; j < verts.Length; q = j++)
                    {
                        Vector3 a = m.MultiplyPoint3x4(verts[q]);
                        Vector3 b = m.MultiplyPoint3x4(verts[j]);

                        if (movementPlane != MovementPlane.XY)
                        {
                            Gizmos.DrawLine(a + up * Height, b + up * Height);
                            Gizmos.DrawLine(a, a + up * Height);
                        }

                        Vector3 avg  = (a + b) * 0.5f;
                        Vector3 tang = (b - a).normalized;
                        if (tang == Vector3.zero)
                        {
                            continue;
                        }

                        Vector3 normal = Vector3.Cross(up, tang);

                        Gizmos.DrawLine(avg, avg + normal);
                        Gizmos.DrawLine(avg + normal, avg + normal * 0.5f + tang * 0.5f);
                        Gizmos.DrawLine(avg + normal, avg + normal * 0.5f - tang * 0.5f);
                    }
                }
            }

            gizmoDrawing = false;
        }
Exemple #4
0
		/** Draws Gizmos */
		public void OnDrawGizmos (bool selected) {
			gizmoDrawing = true;
			
			Gizmos.color = new Color (0.615f,1,0.06f,selected ? 1.0f : 0.7f);
			
			if (gizmoVerts == null || AreGizmosDirty() || _obstacleMode != obstacleMode) {
				_obstacleMode = obstacleMode;
				
				if (gizmoVerts == null) gizmoVerts = new List<Vector3[]>();
				else gizmoVerts.Clear ();
				
				CreateObstacles ();
			}
			
			Matrix4x4 m = GetMatrix();
			
			for (int i=0;i<gizmoVerts.Count;i++) {
				Vector3[] verts = gizmoVerts[i];
				for (int j=0,q=verts.Length-1;j<verts.Length;q=j++) {
					
					Gizmos.DrawLine (m.MultiplyPoint3x4(verts[j]),m.MultiplyPoint3x4(verts[q]));
					
				}
				
				if (selected && obstacleMode != ObstacleVertexWinding.Both) {
					for (int j=0,q=verts.Length-1;j<verts.Length;q=j++) {
						Vector3 a = m.MultiplyPoint3x4(verts[q]);
						Vector3 b = m.MultiplyPoint3x4(verts[j]);
						
						Vector3 avg = (a + b) * 0.5f;
						Vector3 tang = (b - a).normalized;
						if (tang == Vector3.zero) continue;
						
						Vector3 normal = Vector3.Cross (Vector3.up,tang);
						
						Gizmos.DrawLine (avg,avg+normal);
						Gizmos.DrawLine (avg+normal,avg+normal*0.5f+tang*0.5f);
						Gizmos.DrawLine (avg+normal,avg+normal*0.5f-tang*0.5f);
					}
				}
			}
			
			gizmoDrawing = false;
		}