Ejemplo n.º 1
0
    void Triangulate(HexCell cell)
    {
        Vector3 center = cell.transform.localPosition;

        for (HexDir i = 0; i < HexDir.Size; i++)
        {
            Vector3 v1 = center + HexMetrics.GetFirstSolidDirCorner(i);
            Vector3 v2 = center + HexMetrics.GetSecSolidDirCorner(i);

            AddTriangle(
                center,
                v1,
                v2
                );

            AddTriangleColor(cell.color);

            if (i <= HexDir.SE)
            {
                TriangulateConnection(i, cell, v1, v2);
            }
            //Vector3 v3 = center + HexMetrics.GetFirstDirCorner(i);
            //Vector3 v4 = center + HexMetrics.GetSecDirCorner(i);

            //Vector3 v3 = v1 + HexMetrics.GetBridge(i);
            //Vector3 v4 = v2 + HexMetrics.GetBridge(i);


            //AddQuad(v1, v2, v3, v4);

            ////get cell neighbor
            //HexCell neighbor = cell.GetHexNeighbour(i) ?? cell;// neighbor == null ? cell : neighbor;;

            ////set triangle color
            ////AddQuadColor(cell.color, cell.color, (neighbor.color + cell.color + preneighbor.color) / 3f, (neighbor.color + cell.color + nexneighbor.color) / 3f);
            //AddQuadColor(cell.color, (cell.color + neighbor.color) * 0.5f);


            ////----------------------------Filling the gaps
            //HexCell preneighbor = cell.GetHexNeighbour(HexDirectionExtensions.GetPreviousDir(i)) ?? cell;
            //HexCell nexneighbor = cell.GetHexNeighbour(HexDirectionExtensions.GetNextDir(i)) ?? cell;
            //AddTriangle(v1, center + HexMetrics.GetFirstDirCorner(i), v3);
            //AddTriangleColor(cell.color, (cell.color + preneighbor.color + neighbor.color) / 3f, (cell.color + neighbor.color) * 0.5f);

            //AddTriangle(v2, v4, center + HexMetrics.GetSecDirCorner(i));
            //AddTriangleColor(cell.color, (cell.color + neighbor.color) * 0.5f, (cell.color + nexneighbor.color + neighbor.color) / 3f);
            ////----------------------------Filling the gaps
        }
    }