/// <summary> /// スケールや再分割度の設定 /// </summary> private void Evaluate(float par) { float scale = scaleCurve.Evaluate(par); int division = (int)divisionCurve.Evaluate(par); float t = tCurve.Evaluate(par); ConvexPolygon p = polygonObject.Origin.Scaled(transform.position, scale); //polygonObject.UpdatePolygon(AngleSubdivisionOperation.Execute(p, division)); polygonObject.UpdatePolygon(LerpSubdivisionOperation.Execute(p, division, t)); }
private void Update() { List <Vector2> sites = new List <Vector2>(siteTranses.Select(elem => (Vector2)elem.position)); //ボロノイ図の作成 areaPolygon = ConvexPolygon.SquarePolygon(10f); voronoiGenerator = new VoronoiDiagramGenerator(); List <ConvexPolygon> regions = voronoiGenerator.Execute(areaPolygon, sites); List <Vector3> vertices; for (int i = 0; i < lines.Count; ++i) { lineFactory.DeleteLine(lines[i]); } //lines.Clear(); for (int i = 0; i < regions.Count; ++i) { ConvexPolygon region = regions[i]; if (drawRegionLine) { vertices = region.GetVertices3Copy(); vertices.Add(vertices[0]); lines.Add(lineFactory.CreateLine(vertices)); } //描画 Mesh mesh = null; if (angled) { mesh = AngleSubdivisionOperation.Execute(region, 170f).Scale(sites[i], 0.9f).ToAltMesh(); } else { mesh = LerpSubdivisionOperation.Execute(region, i, lerpT).Scale(sites[i], 0.9f).ToAltMesh(); } UnityEngine.Graphics.DrawMesh(mesh, Matrix4x4.identity, mat, 0); } }