Beispiel #1
0
    private void TriangulateConnection(Vector3 v1, Vector3 v2, HexDirection dir, HexCell cell)
    {
        if (cell.GetNeiborCell(dir) == null)
        {
            return;
        }

        Vector3 birdge = HexMatrics.GetBridge(dir);

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

        HexCell neiborCell   = cell.GetNeiborCell(dir) ?? cell;
        HexCell nextNeighbor = cell.GetNeiborCell(dir.Next()) ?? cell;

        //Debug.Log(neiborCell.Elevation);

        v3.y = v4.y = neiborCell.Elevation * HexMatrics.ElevationStep;

        /*AddQuad(v1, v2, v3, v4);
         * AddQuadColor(cell.CellColor, neiborCell.CellColor);
         */

        TriangulateEdgeTerrace(cell, v1, v2, neiborCell, v3, v4);

        if (dir <= HexDirection.E && nextNeighbor != null)
        {
            Vector3 v5 = v2 + HexMatrics.GetBridge(dir.Next());
            v5.y = nextNeighbor.Elevation * HexMatrics.ElevationStep;
            AddTriangle(v2, v4, v5);
            AddTriangleColor(cell.CellColor, neiborCell.CellColor, nextNeighbor.CellColor);
        }
    }
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
        );
    }