コード例 #1
0
    public void Triangulate()
    {
        terrain.Clear();

        Vector3[] vertices = new Vector3[(GridMetrics.chunkSizeX + 1) * (GridMetrics.chunkSizeZ + 1)];

        for (int i = 0, z = 0; z <= GridMetrics.chunkSizeZ; z++)
        {
            for (int x = 0; x <= GridMetrics.chunkSizeX; x++, i++)
            {
                vertices[i] = new Vector3(x, 0, z);
            }
        }

        int[] triangles = new int[GridMetrics.chunkSizeX * GridMetrics.chunkSizeZ * 6];
        for (int ti = 0, vi = 0, y = 0; y < GridMetrics.chunkSizeZ; y++, vi++)
        {
            for (int x = 0; x < GridMetrics.chunkSizeX; x++, ti += 6, vi++)
            {
                triangles[ti]     = vi;
                triangles[ti + 3] = triangles[ti + 2] = vi + 1;
                triangles[ti + 4] = triangles[ti + 1] = vi + GridMetrics.chunkSizeX + 1;
                triangles[ti + 5] = vi + GridMetrics.chunkSizeX + 2;
            }
        }
        terrain.SetMesh(vertices, triangles, GridMetrics.colors[(int)chunkTypes]);

        for (int i = 0; i < cells.Length; i++)
        {
        }

        terrain.Apply();
    }
コード例 #2
0
    void Triangulate(Cell[] cells)
    {
        terrain.Clear();
        water.Clear();

        for (int i = 0; i < cells.Length; i++)
        {
            Triangulate(cells[i]);
        }

        terrain.Apply();
        water.Apply();
    }
コード例 #3
0
 public void Triangulate(SquareCell[] cells)
 {
     terrain.Clear();
     rivers.Clear();
     roads.Clear();
     water.Clear();
     waterShore.Clear();
     features.Clear();
     for (int i = 0; i < cells.Length; i++)
     {
         AddMeshForSquare(cells[i]);
         AddCliffEdges(cells[i]);
     }
     terrain.Apply();
     rivers.Apply();
     roads.Apply();
     water.Apply();
     waterShore.Apply();
     features.Apply();
 }