IEnumerator BuildMeshes() { yield return(null); for (int i = 0; i < fracturePoints.Count; i++) { if (i != gizmoPolyIndex && gizmoPolyIndex != -1) { continue; } Polygon3D poly = new Polygon3D(fracturePoints[i][0], fracturePoints[i][1], fracturePoints[i][2]); //Polygon3D poly = new Polygon3D(fracturePoints[i]); MeshFilter filt = mc3D.createMesh(poly); for (int j = 3; j < fracturePoints[i].Count; j++) { while (!Input.GetMouseButtonUp(1)) { yield return(null); } Debug.Log("poly " + i + " : add point (" + fracturePoints[i][j].x + ", " + fracturePoints[i][j].y + ", " + fracturePoints[i][j].z + ") number of vertices : " + poly.points.Count + "/" + fracturePoints[i].Count); poly.addPoint(fracturePoints[i][j]); mc3D.updateMesh(poly, filt); yield return(null); } } }
public void addNewPoint(Vector3 point) { Debug.Log("add new point"); MoveNewPoint(point); convexHull.addPoint(point); points.Add(point); meshCreator.updateMesh(convexHull, meshCreator.meshes[0]); pointsTR.Add(Instantiate <GameObject>(newPointTR)); pointsTR[pointsTR.Count - 1].transform.localScale *= 0.5f; pointsTR[pointsTR.Count - 1].transform.position = newPoint; pointsTR[pointsTR.Count - 1].GetComponent <Renderer>().material.color = new Color(0, 1, 0, 0.5f); }