I Have a mesh which I want to break it it smaller pieces.
I am doing that buy creating new submeshes which each contains X(random) triangles like this:
…
int loop_vertices = 3 + (X- 1);
int[] indices = M.GetTriangles(submesh);
for (int i = 0; i < indices.Length; i += loop_vertices)
{
Vector3[] newVerts = new Vector3[loop_vertices];
Vector3[] newNormals = new Vector3[loop_vertices];
Vector2[] newUvs = new Vector2[loop_vertices];
for (int n = 0; n < loop_vertices; n++)
{
int index = indices[i + n];
newVerts[n] = verts[index];
newUvs[n] = uvs[index];
newNormals[n] = normals[index];
}
mesh.triangles=????????
}
…
How can i create the mesh.triangles array programmatically?