Beispiel #1
0
    void Triangulate(HexDirection direction, HexCell cell)
    {
        Vector3 center = cell.transform.localPosition;
        Vector3 v1     = center + HexMatrics.GetFirstSolidCorner(direction);
        Vector3 v2     = center + HexMatrics.GetSecondSolidCorner(direction);

        AddTriangle(center, v1, v2);
        AddTriangleColor(cell.color);

        Vector3 v3 = center + HexMatrics.GetFirstCorner(direction);
        Vector3 v4 = center + HexMatrics.GetSecondCorner(direction);

        AddQuad(v1, v2, v3, v4);

        HexCell prevNeighbor = cell.GetNeighbor(direction.Previous()) ?? cell;
        HexCell neighbor     = cell.GetNeighbor(direction) ?? cell;
        HexCell nextNeighbor = cell.GetNeighbor(direction.Next()) ?? cell;

        AddQuadColor(
            cell.color,
            cell.color,
            (cell.color + prevNeighbor.color + neighbor.color) / 3f,
            (cell.color + neighbor.color + nextNeighbor.color) / 3f
            );
    }
Beispiel #2
0
    void Triangulate(HexDirection direction, HexCell cell)
    {
        Vector3 center = cell.transform.localPosition;
        Vector3 v1     = center + HexMatrics.GetFirstSolidCorner(direction);
        Vector3 v2     = center + HexMatrics.GetSecondSolidCorner(direction);


        AddTriangle(center, v1, v2);
        AddTriangleColor(cell.color);

        Vector3 bridge = HexMatrics.GetBridge(direction);

        Vector3 v3 = v1 + bridge;
        Vector3 v4 = v2 + bridge;

        AddQuad(v1, v2, v3, v4);

        HexCell prevNeighbor = cell.GetNeighbor(direction.Previous()) ?? cell;
        HexCell neighbor     = cell.GetNeighbor(direction) ?? cell;
        HexCell nextneighbor = cell.GetNeighbor(direction.Next()) ?? cell;


        Color bridgeColor = (cell.color + neighbor.color) * 0.5f;

        AddQuadColor(cell.color, bridgeColor);

        AddTriangle(v1, center + HexMatrics.GetFirstCorner(direction), v3);
        AddTriangleColor
        (
            cell.color,
            (cell.color + prevNeighbor.color + neighbor.color) / 3f,
            bridgeColor
        );

        AddTriangle(v2, v4, center + HexMatrics.GetSecondCorner(direction));
        AddTriangleColor
        (
            cell.color,
            bridgeColor,
            (cell.color + nextneighbor.color + neighbor.color) / 3f
        );
    }