/// <summary>
    /// Creates geometry for open water (no land neighbors).
    /// </summary>
    void TriangulateOpenWater(HexDirection direction, HexCell cell, HexCell neighbor, Vector3 center)
    {
        // Careful to find the WATER corner not the solid corner
        // Careful to get the WATER bridge
        Vector3 c1 = center + HexMetrics.GetFirstWaterCorner(direction);
        Vector3 c2 = center + HexMetrics.GetSecondWaterCorner(direction);

        Water.AddTriangle(center, c1, c2);

        Vector3 indices;

        indices.x = indices.y = indices.z = cell.Index;
        Water.AddTriangleCellData(indices, weights1);

        if (direction <= HexDirection.SE && neighbor != null)
        {
            Vector3 bridge = HexMetrics.GetWaterBridge(direction);
            Vector3 e1     = c1 + bridge;
            Vector3 e2     = c2 + bridge;

            Water.AddQuad(c1, c2, e1, e2);

            indices.y = neighbor.Index;
            Water.AddQuadCellData(indices, weights1, weights2);

            // The tripple connection triangle for water surface
            if (direction <= HexDirection.E)
            {
                HexCell nextNeighbor = cell.GetNeighbor(direction.Next());
                if (nextNeighbor == null || !nextNeighbor.IsUnderwater)
                {
                    return;
                }
                Water.AddTriangle(c2, e2, c2 + HexMetrics.GetWaterBridge(direction.Next()));

                indices.z = nextNeighbor.Index;
                Water.AddTriangleCellData(indices, weights1, weights2, weights3);
            }
        }
    }
Ejemplo n.º 2
0
        private void TriangulateOpenWater(HexDirection direction, HexCell cell, HexCell neighbour, Vector3 centre)
        {
            var c1 = centre + HexMetrics.GetFirstWaterCorner(direction);
            var c2 = centre + HexMetrics.GetSecondWaterCorner(direction);

            Water.AddTriangle(centre, c1, c2);
            var indices = new Vector3(cell.Index, cell.Index, cell.Index);

            Water.AddTriangleCellData(indices, weights1);

            if (neighbour == null || direction > HexDirection.SE)
            {
                return;
            }

            var bridge = HexMetrics.GetWaterBridge(direction);
            var e1     = c1 + bridge;
            var e2     = c2 + bridge;

            Water.AddQuad(c1, c2, e1, e2);
            indices.y = neighbour.Index;
            Water.AddQuadCellData(indices, weights1, weights2);

            if (direction > HexDirection.E)
            {
                return;
            }

            var nextNeighbour = cell.GetNeighbour(direction.Next());

            if (nextNeighbour == null || !nextNeighbour.IsUnderwater)
            {
                return;
            }

            Water.AddTriangle(c2, e2, c2 + HexMetrics.GetWaterBridge(direction.Next()));
            indices.z = nextNeighbour.Index;
            Water.AddTriangleCellData(indices, weights1, weights2, weights3);
        }