public int[] getNewTriangles(List <Vector3> vertices, FinalStorage storage) { List <int> array = new List <int>(); foreach (FinalFace face in finalFaces) { foreach (Vector3 t in face.getTriangles()) { array.Add(storage.getData(t)); } } return(array.ToArray()); }
public Vector3[] getNewVertices(FinalStorage storage) { List <Vector3> array = new List <Vector3>(); int i = 0; foreach (FinalFace face in finalFaces) { foreach (Face f in face.getFaces()) { Vector3 vert = f.offsetCentroid(face); array.Add(vert); storage.addData(vert, i++); } } return(array.ToArray()); }
Mesh createHexasphere(float size, float offset, int subdivisions) { Mesh mesh = new Mesh(); mesh.name = "Hexasphere"; mesh.indexFormat = subdivisions > 5? UnityEngine.Rendering.IndexFormat.UInt32 : UnityEngine.Rendering.IndexFormat.UInt16; HexagonSphere hex = new HexagonSphere((size - offset) / 2, subdivisions, offset); FinalStorage storage = new FinalStorage(); Vector3[] vertices = hex.getNewVertices(storage); int[] triangles = hex.getNewTriangles(vertices.ToList(), storage); // other performance hog! mesh.vertices = vertices; mesh.triangles = triangles; mesh.normals = hex.getNormals(); return(mesh); }