public static void DrawArrow(Vector3 start, Vector3 end, Color color) { var arrowHead = new Vector3[3]; var h = 10f; var w = h / 2f; var forward = (end - start).normalized; var right = Vector3.Cross(Vector3.forward, forward).normalized; arrowHead[0] = start + forward * Vector3.Distance(start, end) / 2f + forward * h / 3f * 2f; arrowHead[1] = start + forward * Vector3.Distance(start, end) / 2f - forward * h / 3f + right * w; arrowHead[2] = start + forward * Vector3.Distance(start, end) / 2f - forward * h / 3f - right * w; Handles.color = color; Handles.DrawAAConvexPolygon(arrowHead); }
private void DrawAgentDiagram(Rect rect, float agentRadius, float agentHeight, float agentClimb, float agentSlope) { if (Event.current.type != EventType.Repaint) { return; } float num = 0.35f; float num2 = 15f; float num3 = rect.height - num2 * 2f; float num4 = Mathf.Min(num3 / (agentHeight + agentRadius * 2f * num), num3 / (agentRadius * 2f)); float num5 = agentHeight * num4; float num6 = agentRadius * num4; float num7 = agentClimb * num4; float num8 = rect.xMin + rect.width * 0.5f; float num9 = rect.yMax - num2 - num6 * num; Vector3[] array = new Vector3[40]; Vector3[] array2 = new Vector3[20]; Vector3[] array3 = new Vector3[20]; for (int i = 0; i < 20; i++) { float f = (float)i / 19f * 3.14159274f; float num10 = Mathf.Cos(f); float num11 = Mathf.Sin(f); array[i] = new Vector3(num8 + num10 * num6, num9 - num5 - num11 * num6 * num, 0f); array[i + 20] = new Vector3(num8 - num10 * num6, num9 + num11 * num6 * num, 0f); array2[i] = new Vector3(num8 - num10 * num6, num9 - num5 + num11 * num6 * num, 0f); array3[i] = new Vector3(num8 - num10 * num6, num9 - num7 + num11 * num6 * num, 0f); } Color color = Handles.color; float xMin = rect.xMin; float num12 = num9 - num7; float num13 = num8 - num3 * 0.75f; float y = num9; float num14 = num8 + num3 * 0.75f; float num15 = num9; float num16 = num14; float num17 = num15; float num18 = rect.xMax - num14; num16 += Mathf.Cos(agentSlope * 0.0174532924f) * num18; num17 -= Mathf.Sin(agentSlope * 0.0174532924f) * num18; Vector3[] points = new Vector3[] { new Vector3(xMin, num9, 0f), new Vector3(num16, num9, 0f) }; Vector3[] points2 = new Vector3[] { new Vector3(xMin, num12, 0f), new Vector3(num13, num12, 0f), new Vector3(num13, y, 0f), new Vector3(num14, num15, 0f), new Vector3(num16, num17, 0f) }; Handles.color = ((!EditorGUIUtility.isProSkin) ? new Color(1f, 1f, 1f, 0.5f) : new Color(0f, 0f, 0f, 0.5f)); Handles.DrawAAPolyLine(2f, points); Handles.color = ((!EditorGUIUtility.isProSkin) ? new Color(0f, 0f, 0f, 0.5f) : new Color(1f, 1f, 1f, 0.5f)); Handles.DrawAAPolyLine(3f, points2); Handles.color = Color.Lerp(new Color(0f, 0.75f, 1f, 1f), new Color(0.5f, 0.5f, 0.5f, 0.5f), 0.2f); Handles.DrawAAConvexPolygon(array); Handles.color = new Color(0f, 0f, 0f, 0.5f); Handles.DrawAAPolyLine(2f, array3); Handles.color = new Color(1f, 1f, 1f, 0.4f); Handles.DrawAAPolyLine(2f, array2); Vector3[] points3 = new Vector3[] { new Vector3(num8, num9 - num5, 0f), new Vector3(num8 + num6, num9 - num5, 0f) }; Handles.color = new Color(0f, 0f, 0f, 0.5f); Handles.DrawAAPolyLine(2f, points3); GUI.Label(new Rect(num8 + num6 + 5f, num9 - num5 * 0.5f - 10f, 150f, 20f), string.Format("H = {0}", agentHeight)); GUI.Label(new Rect(num8, num9 - num5 - num6 * num - 15f, 150f, 20f), string.Format("R = {0}", agentRadius)); GUI.Label(new Rect((xMin + num13) * 0.5f - 20f, num12 - 15f, 150f, 20f), string.Format("{0}", agentClimb)); GUI.Label(new Rect(num14 + 20f, num15 - 15f, 150f, 20f), string.Format("{0}°", agentSlope)); Handles.color = color; }
private void DrawAgentDiagram(Rect rect, float agentRadius, float agentHeight, float agentClimb, float agentSlope) { if (Event.current.type == EventType.Repaint) { float num = agentRadius; float num2 = agentHeight; float num3 = agentClimb; float num4 = 1f; float num5 = 0.35f; float num6 = 15f; float num7 = rect.height - (num6 * 2f); num4 = Mathf.Min((float)(num7 / (num2 + ((num * 2f) * num5))), (float)(num7 / (num * 2f))); num2 *= num4; num *= num4; num3 *= num4; float x = rect.xMin + (rect.width * 0.5f); float y = (rect.yMax - num6) - (num * num5); Vector3[] points = new Vector3[40]; Vector3[] vectorArray2 = new Vector3[20]; Vector3[] vectorArray3 = new Vector3[20]; for (int i = 0; i < 20; i++) { float f = (((float)i) / 19f) * 3.141593f; float num13 = Mathf.Cos(f); float num14 = Mathf.Sin(f); points[i] = new Vector3(x + (num13 * num), (y - num2) - ((num14 * num) * num5), 0f); points[i + 20] = new Vector3(x - (num13 * num), y + ((num14 * num) * num5), 0f); vectorArray2[i] = new Vector3(x - (num13 * num), (y - num2) + ((num14 * num) * num5), 0f); vectorArray3[i] = new Vector3(x - (num13 * num), (y - num3) + ((num14 * num) * num5), 0f); } Color color = Handles.color; float xMin = rect.xMin; float num16 = y - num3; float num17 = x - (num7 * 0.75f); float num18 = y; float num19 = x + (num7 * 0.75f); float num20 = y; float num21 = num19; float num22 = num20; float num23 = rect.xMax - num19; num21 += Mathf.Cos(agentSlope * 0.01745329f) * num23; num22 -= Mathf.Sin(agentSlope * 0.01745329f) * num23; Vector3[] vectorArray4 = new Vector3[] { new Vector3(xMin, y, 0f), new Vector3(num21, y, 0f) }; Vector3[] vectorArray5 = new Vector3[] { new Vector3(xMin, num16, 0f), new Vector3(num17, num16, 0f), new Vector3(num17, num18, 0f), new Vector3(num19, num20, 0f), new Vector3(num21, num22, 0f) }; Handles.color = !EditorGUIUtility.isProSkin ? new Color(1f, 1f, 1f, 0.5f) : new Color(0f, 0f, 0f, 0.5f); Handles.DrawAAPolyLine((float)2f, vectorArray4); Handles.color = !EditorGUIUtility.isProSkin ? new Color(0f, 0f, 0f, 0.5f) : new Color(1f, 1f, 1f, 0.5f); Handles.DrawAAPolyLine((float)3f, vectorArray5); Handles.color = Color.Lerp(new Color(0f, 0.75f, 1f, 1f), new Color(0.5f, 0.5f, 0.5f, 0.5f), 0.2f); Handles.DrawAAConvexPolygon(points); Handles.color = new Color(0f, 0f, 0f, 0.5f); Handles.DrawAAPolyLine((float)2f, vectorArray3); Handles.color = new Color(1f, 1f, 1f, 0.4f); Handles.DrawAAPolyLine((float)2f, vectorArray2); Vector3[] vectorArray6 = new Vector3[] { new Vector3(x, y - num2, 0f), new Vector3(x + num, y - num2, 0f) }; Handles.color = new Color(0f, 0f, 0f, 0.5f); Handles.DrawAAPolyLine((float)2f, vectorArray6); GUI.Label(new Rect((x + num) + 5f, (y - (num2 * 0.5f)) - 10f, 150f, 20f), string.Format("H = {0}", agentHeight)); GUI.Label(new Rect(x, ((y - num2) - (num * num5)) - 15f, 150f, 20f), string.Format("R = {0}", agentRadius)); GUI.Label(new Rect(((xMin + num17) * 0.5f) - 20f, num16 - 15f, 150f, 20f), string.Format("{0}", agentClimb)); GUI.Label(new Rect(num19 + 20f, num20 - 15f, 150f, 20f), string.Format("{0}\x00b0", agentSlope)); Handles.color = color; } }
private void DrawAgentDiagram(Rect rect, float agentRadius, float agentHeight, float agentClimb, float agentSlope) { if (Event.current.type != EventType.Repaint) { return; } float num1 = agentRadius; float num2 = agentHeight; float num3 = agentClimb; float num4 = 0.35f; float num5 = 15f; float num6 = rect.height - num5 * 2f; float num7 = Mathf.Min(num6 / (num2 + num1 * 2f * num4), num6 / (num1 * 2f)); float num8 = num2 * num7; float num9 = num1 * num7; float num10 = num3 * num7; float x1 = rect.xMin + rect.width * 0.5f; float y1 = (float)((double)rect.yMax - (double)num5 - (double)num9 * (double)num4); Vector3[] vector3Array1 = new Vector3[40]; Vector3[] vector3Array2 = new Vector3[20]; Vector3[] vector3Array3 = new Vector3[20]; for (int index = 0; index < 20; ++index) { float f = (float)((double)index / 19.0 * 3.14159274101257); float num11 = Mathf.Cos(f); float num12 = Mathf.Sin(f); vector3Array1[index] = new Vector3(x1 + num11 * num9, (float)((double)y1 - (double)num8 - (double)num12 * (double)num9 * (double)num4), 0.0f); vector3Array1[index + 20] = new Vector3(x1 - num11 * num9, y1 + num12 * num9 * num4, 0.0f); vector3Array2[index] = new Vector3(x1 - num11 * num9, (float)((double)y1 - (double)num8 + (double)num12 * (double)num9 * (double)num4), 0.0f); vector3Array3[index] = new Vector3(x1 - num11 * num9, (float)((double)y1 - (double)num10 + (double)num12 * (double)num9 * (double)num4), 0.0f); } Color color = Handles.color; float xMin = rect.xMin; float y2 = y1 - num10; float x2 = x1 - num6 * 0.75f; float y3 = y1; float x3 = x1 + num6 * 0.75f; float y4 = y1; float num13 = x3; float num14 = y4; float num15 = rect.xMax - x3; float x4 = num13 + Mathf.Cos(agentSlope * ((float)Math.PI / 180f)) * num15; float y5 = num14 - Mathf.Sin(agentSlope * ((float)Math.PI / 180f)) * num15; Vector3[] vector3Array4 = new Vector3[2] { new Vector3(xMin, y1, 0.0f), new Vector3(x4, y1, 0.0f) }; Vector3[] vector3Array5 = new Vector3[5] { new Vector3(xMin, y2, 0.0f), new Vector3(x2, y2, 0.0f), new Vector3(x2, y3, 0.0f), new Vector3(x3, y4, 0.0f), new Vector3(x4, y5, 0.0f) }; Handles.color = !EditorGUIUtility.isProSkin ? new Color(1f, 1f, 1f, 0.5f) : new Color(0.0f, 0.0f, 0.0f, 0.5f); Handles.DrawAAPolyLine(2f, vector3Array4); Handles.color = !EditorGUIUtility.isProSkin ? new Color(0.0f, 0.0f, 0.0f, 0.5f) : new Color(1f, 1f, 1f, 0.5f); Handles.DrawAAPolyLine(3f, vector3Array5); Handles.color = Color.Lerp(new Color(0.0f, 0.75f, 1f, 1f), new Color(0.5f, 0.5f, 0.5f, 0.5f), 0.2f); Handles.DrawAAConvexPolygon(vector3Array1); Handles.color = new Color(0.0f, 0.0f, 0.0f, 0.5f); Handles.DrawAAPolyLine(2f, vector3Array3); Handles.color = new Color(1f, 1f, 1f, 0.4f); Handles.DrawAAPolyLine(2f, vector3Array2); Vector3[] vector3Array6 = new Vector3[2] { new Vector3(x1, y1 - num8, 0.0f), new Vector3(x1 + num9, y1 - num8, 0.0f) }; Handles.color = new Color(0.0f, 0.0f, 0.0f, 0.5f); Handles.DrawAAPolyLine(2f, vector3Array6); GUI.Label(new Rect((float)((double)x1 + (double)num9 + 5.0), (float)((double)y1 - (double)num8 * 0.5 - 10.0), 150f, 20f), string.Format("H = {0}", (object)agentHeight)); GUI.Label(new Rect(x1, (float)((double)y1 - (double)num8 - (double)num9 * (double)num4 - 15.0), 150f, 20f), string.Format("R = {0}", (object)agentRadius)); GUI.Label(new Rect((float)(((double)xMin + (double)x2) * 0.5 - 20.0), y2 - 15f, 150f, 20f), string.Format("{0}", (object)agentClimb)); GUI.Label(new Rect(x3 + 20f, y4 - 15f, 150f, 20f), string.Format("{0}°", (object)agentSlope)); Handles.color = color; }
public static void DrawAgentDiagram(Rect rect, float agentRadius, float agentHeight, float agentClimb, float agentSlope) { if (Event.current.type == EventType.Repaint) { float num = 0.35f; float num2 = 20f; float num3 = 10f; float num4 = rect.height - (num2 + num3); float num5 = Mathf.Min(num4 / (agentHeight + agentRadius * 2f * num), num4 / (agentRadius * 2f)); float num6 = agentHeight * num5; float num7 = agentRadius * num5; float num8 = agentClimb * num5; float num9 = rect.xMin + rect.width * 0.5f; float num10 = rect.yMax - num3 - num7 * num; Vector3[] array = new Vector3[40]; Vector3[] array2 = new Vector3[20]; Vector3[] array3 = new Vector3[20]; for (int i = 0; i < 20; i++) { float f = (float)i / 19f * 3.14159274f; float num11 = Mathf.Cos(f); float num12 = Mathf.Sin(f); array[i] = new Vector3(num9 + num11 * num7, num10 - num6 - num12 * num7 * num, 0f); array[i + 20] = new Vector3(num9 - num11 * num7, num10 + num12 * num7 * num, 0f); array2[i] = new Vector3(num9 - num11 * num7, num10 - num6 + num12 * num7 * num, 0f); array3[i] = new Vector3(num9 - num11 * num7, num10 - num8 + num12 * num7 * num, 0f); } Color color = Handles.color; float xMin = rect.xMin; float num13 = num10 - num8; float num14 = num9 - num4 * 0.75f; float y = num10; float num15 = num9 + num4 * 0.75f; float num16 = num10; float num17 = num15; float num18 = num16; float num19 = Mathf.Min(rect.xMax - num15, num6); num17 += Mathf.Cos(agentSlope * 0.0174532924f) * num19; num18 -= Mathf.Sin(agentSlope * 0.0174532924f) * num19; Vector3[] points = new Vector3[] { new Vector3(xMin, num10, 0f), new Vector3(num17, num10, 0f) }; Vector3[] points2 = new Vector3[] { new Vector3(xMin, num13, 0f), new Vector3(num14, num13, 0f), new Vector3(num14, y, 0f), new Vector3(num15, num16, 0f), new Vector3(num17, num18, 0f) }; Handles.color = ((!EditorGUIUtility.isProSkin) ? new Color(1f, 1f, 1f, 0.5f) : new Color(0f, 0f, 0f, 0.5f)); Handles.DrawAAPolyLine(2f, points); Handles.color = ((!EditorGUIUtility.isProSkin) ? new Color(0f, 0f, 0f, 0.5f) : new Color(1f, 1f, 1f, 0.5f)); Handles.DrawAAPolyLine(3f, points2); Handles.color = Color.Lerp(new Color(0f, 0.75f, 1f, 1f), new Color(0.5f, 0.5f, 0.5f, 0.5f), 0.2f); Handles.DrawAAConvexPolygon(array); Handles.color = new Color(0f, 0f, 0f, 0.5f); Handles.DrawAAPolyLine(2f, array3); Handles.color = new Color(1f, 1f, 1f, 0.4f); Handles.DrawAAPolyLine(2f, array2); Vector3[] points3 = new Vector3[] { new Vector3(num9, num10 - num6, 0f), new Vector3(num9 + num7, num10 - num6, 0f) }; Handles.color = new Color(0f, 0f, 0f, 0.5f); Handles.DrawAAPolyLine(2f, points3); GUI.Label(new Rect(num9 + num7 + 5f, num10 - num6 * 0.5f - 10f, 150f, 20f), string.Format("H = {0}", agentHeight)); GUI.Label(new Rect(num9, num10 - num6 - num7 * num - 15f, 150f, 20f), string.Format("R = {0}", agentRadius)); GUI.Label(new Rect((xMin + num14) * 0.5f - 20f, num13 - 15f, 150f, 20f), string.Format("{0}", agentClimb)); GUI.Label(new Rect(num15 + 20f, num16 - 15f, 150f, 20f), string.Format("{0}°", agentSlope)); Handles.color = color; } }