void DrawHeightCurve() { SubstanceGenerator.Curve c = generator.heightCurve; if (active == 0) { GL.Color(c.color); } else { GL.Color(c.color * 0.5f); } Vertex3(c.p[0]); for (int j = 1; j < c.p.Count - 1; j++) { Vertex3(c.p[j]); Vertex3(c.p[j]); } Vertex3(c.p[c.p.Count - 1]); if (active == 0) { for (int j = 0; j < c.points.Count; j++) { DrawPoint(c.points[j]); } } }
void DrawCurve(int i) { SubstanceGenerator.Curve c = generator.curves[i]; if (i == active) { GL.Color(c.color); } else { GL.Color(c.color * 0.5f); } Vertex3(c.p[0]); for (int j = 1; j < c.p.Count - 1; j++) { Vertex3(c.p[j]); Vertex3(c.p[j]); } Vertex3(c.p[c.p.Count - 1]); if (i == active) { for (int j = 0; j < c.points.Count; j++) { DrawPoint(c.points[j]); } } }
void DrawCurve(int i) { SubstanceGenerator.Curve c = generator.curves[i]; GL.Color(c.color); Vertex3(0, c.y[0], 0); for (int x = 1; x < 100; x++) { Vertex3(x * 0.01f, c.y[x], 0); Vertex3(x * 0.01f, c.y[x], 0); } Vertex3(1, c.y[100], 0); }
void DrawHeightCurve() { SubstanceGenerator.Curve c = generator.heightCurve; GL.Color(c.color); Vertex3(0, c.y[0], 0); for (int x = 1; x < 100; x++) { Vertex3(x * 0.01f, c.y[x], 0); Vertex3(x * 0.01f, c.y[x], 0); } Vertex3(1, c.y[100], 0); }
void DrawCurvePanel() { bool activeVisible = true; curvePanelSize = 0.8f * Mathf.Min(Screen.width, Screen.height - 210f) - 40f; Rect rect = GUILayoutUtility.GetRect(curvePanelSize, curvePanelSize); rect.x = 20f; rect.y = 20f; if (Event.current.type == EventType.Repaint) { GUI.BeginClip(rect); GL.PushMatrix(); GL.Clear(true, false, Color.black); mat.SetPass(0); GL.Begin(GL.LINES); GL.Color(Color.black); Vertex3(0, 0, 0); Vertex3(0, 1, 0); Vertex3(0, 1, 0); Vertex3(1, 1, 0); Vertex3(1, 1, 0); Vertex3(1, 0, 0); Vertex3(1, 0, 0); Vertex3(0, 0, 0); if (active == 0) { activeVisible = generator.heightCurveVisible; for (int i = 1; i < SubstanceTable.substances.Count; i++) { if (generator.state[i] == SubstanceGenerator.SubstanceState.Visible) { DrawCurve(i); } } DrawHeightCurve(); } else { DrawHeightCurve(); for (int i = 1; i < SubstanceTable.substances.Count; i++) { if (generator.state[i] == SubstanceGenerator.SubstanceState.Visible && i != active) { DrawCurve(i); } } if (generator.state[active] == SubstanceGenerator.SubstanceState.Visible) { DrawCurve(active); } else { activeVisible = false; } } GL.End(); GL.PopMatrix(); GUI.EndClip(); } EditorGUI.indentLevel++; GUILayout.Space(20f); GUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Active curve: ", GUILayout.Width(100f)); active = EditorGUILayout.IntField(active, GUILayout.Width(40f)); if (GUILayout.Button("<", GUILayout.Width(20f))) { active--; } if (GUILayout.Button(">", GUILayout.Width(20f))) { active++; } active = Mathf.Clamp(active, 0, SubstanceTable.substances.Count - 1); EditorGUILayout.LabelField(active == 0 ? "Height Curve" : SubstanceTable.substances[active].name); GUILayout.EndHorizontal(); if (!activeVisible) { EditorGUILayout.LabelField("Active curve is not visible"); } GUILayout.Space(5f); if (activePoint.exist) { activePoint.i = EditorGUILayout.IntField("Current Point", activePoint.i); SubstanceGenerator.Curve c = active == 0 ? generator.heightCurve : generator.curves[active]; activePoint.i = Mathf.Clamp(activePoint.i, 0, c.points.Count - 1); EditorGUI.indentLevel++; EditorGUI.BeginChangeCheck(); c.points[activePoint.i].pos = EditorGUILayout.Vector2Field("Position", c.points[activePoint.i].pos); c.points[activePoint.i].dir = EditorGUILayout.Vector2Field("Tangent Direction", c.points[activePoint.i].dir); if (EditorGUI.EndChangeCheck()) { c.Recalculate(); } EditorGUI.indentLevel--; } else { EditorGUILayout.LabelField("No active point"); } EditorGUI.indentLevel--; GUILayout.Space(10f); if (GUILayout.Button("Save")) { Save(); } }