private void TriangulateWithRiverBeginOrEnd(HexDirection direction, HexCell cell, Vector3 centre, EdgeVertices e) { var m = new EdgeVertices( Vector3.Lerp(centre, e.v1, 0.5f), Vector3.Lerp(centre, e.v5, 0.5f)); m.v3.y = e.v3.y; TriangulateEdgeStrip(m, weights1, cell.Index, e, weights1, cell.Index); TriangulateEdgeFan(centre, m, cell.Index); var reversed = cell.HasIncomingRiver; var indices = new Vector3(cell.Index, cell.Index, cell.Index); TriangulateRiverQuad(m.v2, m.v4, e.v2, e.v4, cell.RiverSurfaceY, 0.6f, reversed, indices); centre.y = m.v2.y = m.v4.y = cell.RiverSurfaceY; Rivers.AddTriangle(centre, m.v2, m.v4); if (reversed) { Rivers.AddTriangleUV(new Vector2(0.5f, 0.4f), new Vector2(1f, 0.2f), new Vector2(0f, 0.2f)); } else { Rivers.AddTriangleUV(new Vector2(0.5f, 0.4f), new Vector2(0f, 0.6f), new Vector2(1f, 0.6f)); } Rivers.AddTriangleCellData(indices, weights1); }
/// <summary> /// Creates the triangles for a side of the hexagon, with river starting or ending this side. /// </summary> void TriangulateWithRiverBeginOrEnd(HexDirection direction, HexCell cell, Vector3 center, EdgeVertices e) { // Edge 1/2 the way from edge and cell center EdgeVertices m = new EdgeVertices( Vector3.Lerp(center, e.v1, 0.5f), Vector3.Lerp(center, e.v5, 0.5f) ); m.v3.y = e.v3.y; // middle at river bed height, but not the center of the cell TriangulateEdgeStrip(m, weights1, cell.Index, e, weights1, cell.Index); TriangulateEdgeFan(center, m, cell.Index); if (!cell.IsUnderwater) // No river water surface underwater, riverbed itself is allowed // River water surface { bool reversed = cell.HasIncomingRiver; Vector3 indices; indices.x = indices.y = indices.z = cell.Index; TriangulateRiverQuad(m.v2, m.v4, e.v2, e.v4, cell.RiverSurfaceY, 0.6f, reversed, indices); // Add first/last water surface triangle for river begin/end center.y = m.v2.y = m.v4.y = cell.RiverSurfaceY; Rivers.AddTriangle(center, m.v2, m.v4); if (reversed) { Rivers.AddTriangleUV(new Vector2(0.5f, 0.4f), new Vector2(1f, 0.2f), new Vector2(0f, 0.2f)); } else { Rivers.AddTriangleUV(new Vector2(0.5f, 0.4f), new Vector2(0f, 0.6f), new Vector2(1f, 0.6f)); } Rivers.AddTriangleCellData(indices, weights1); } }