private void Start() { bezierDrawer = GetComponent <BezierDrawer>(); bSplineDrawer = GetComponent <BSplineDrawer>(); selectCurve(true); tarScale = Camera.main.orthographicSize; startPos = Camera.main.ScreenToWorldPoint(Input.mousePosition); }
/// <summary> /// GL绘制曲线和多边形 /// </summary> private void OnPostRender() { GL.Begin(GL.LINE_STRIP); for (int i = 0; i < vertexs.Length; i++) { GL.Color(vertexs[i].color); GL.Vertex(vertexs[i].pos); } GL.End(); if (isShowPolygon) { GL.Begin(GL.LINE_STRIP); for (int i = 0; i < pointManager.points.Count; i++) { GL.Color(new Color(0.9f, 0.0f, 0.0f, 0.5f)); GL.Vertex(pointManager.points[i].transform.position); } //if (pointManager.points.Count > 0) //{ // GL.Color(Color.red); // GL.Vertex(pointManager.points[0].transform.position); //} GL.End(); } if (isShowConvexHull) { GL.Begin(GL.LINE_STRIP); for (int i = 0; i < pointManager.convexHull.Count; i++) { GL.Color(new Color(0.0f, 0.65f, 0.0f, 1.0f)); GL.Vertex(pointManager.convexHull[i]); } if (pointManager.convexHull.Count > 0) { GL.Color(new Color(0.0f, 0.65f, 0.0f, 1.0f)); GL.Vertex(pointManager.convexHull[0]); } GL.End(); } if (pointManager.IsAddRect) { BSplineDrawer.DrawVirtualLine(pointManager.dragRect.position, new Vector2(pointManager.dragRect.width, pointManager.dragRect.y), Color.red, 0.1f); BSplineDrawer.DrawVirtualLine(pointManager.dragRect.position, new Vector2(pointManager.dragRect.x, pointManager.dragRect.height), Color.red, 0.1f); BSplineDrawer.DrawVirtualLine(pointManager.dragRect.size, new Vector2(pointManager.dragRect.width, pointManager.dragRect.y), Color.red, 0.1f); BSplineDrawer.DrawVirtualLine(pointManager.dragRect.size, new Vector2(pointManager.dragRect.x, pointManager.dragRect.height), Color.red, 0.1f); } }
private void OnPostRender() { //GL.Begin(GL.LINE_STRIP); //GL.Color(Color.gray); //GL.Vertex(new Vector3(-1.5f, 0, 0)); //GL.Color(Color.gray); //GL.Vertex(new Vector3(0, 0, 0)); //GL.Color(Color.gray); //GL.Vertex(new Vector3(1.5f, 0, 0)); //GL.Color(Color.gray); //GL.Vertex(new Vector3(0, 0, 0)); //GL.Color(Color.gray); //GL.Vertex(new Vector3(0, 1.5f, 0)); //GL.Color(Color.gray); //GL.Vertex(new Vector3(0, -1.5f, 0)); //GL.End(); BSplineDrawer.DrawVirtualLine(new Vector3(-0.8f, 0, 0), new Vector3(0.8f, 0, 0), Color.magenta, 0.03f); BSplineDrawer.DrawVirtualLine(new Vector3(0, -0.8f, 0), new Vector3(0, 0.8f, 0), Color.magenta, 0.03f); }