Beispiel #1
0
    public static void AddUnitTriangle(Mesh mesh)
    {
        int        currentNumVerts = mesh.vertices.Length;
        EditedMesh meshEdit        = new EditedMesh(mesh);

        meshEdit.AddVerts(new List <Vector3>()
        {
            Vector3.zero, new Vector3(-1f, 0f, 0f), new Vector3(0f, 0f, 1f)
        });

        meshEdit.AddTriangles(new List <int>()
        {
            currentNumVerts, currentNumVerts + 1, currentNumVerts + 2
        });
        meshEdit.CopyTo(mesh);
    }
Beispiel #2
0
    // triangle zero, will mean the first triangle (three triangle indecis) are deleted, triangle index 1, the second triangle deleted
    public static void RemoveTriangles(List <int> trianglesToRemove, Mesh mesh)
    {
        EditedMesh meshEdit = new EditedMesh();

        meshEdit.AddVerts(mesh.vertices);
        for (int triangle = 0; triangle < CalculateNumTriangles(mesh); ++triangle)
        {
            if (!trianglesToRemove.Contains(triangle))
            {
                int startingTriangleIndex = triangle * NumVertsPerTriangle;
                meshEdit.triangleIndecis.Add(mesh.triangles[startingTriangleIndex]);
                meshEdit.triangleIndecis.Add(mesh.triangles[startingTriangleIndex + 1]);
                meshEdit.triangleIndecis.Add(mesh.triangles[startingTriangleIndex + 2]);
            }
        }
        meshEdit.CopyTo(mesh);
    }