private void TriangulateWaterfallInWater( Vector3 vertex1, Vector3 vertex2, Vector3 vertex3, Vector3 vertex4, float y1, float y2, float waterY, Vector3 indices, float hexOuterRadius, int wrapSize, MapMeshChunkLayer rivers ) { vertex1.y = vertex2.y = y1; vertex3.y = vertex4.y = y2; vertex1 = HexagonPoint.Perturb( vertex1, hexOuterRadius, wrapSize ); vertex2 = HexagonPoint.Perturb( vertex2, hexOuterRadius, wrapSize ); vertex3 = HexagonPoint.Perturb( vertex3, hexOuterRadius, wrapSize ); vertex4 = HexagonPoint.Perturb( vertex4, hexOuterRadius, wrapSize ); float t = (waterY - y2) / (y1 - y2); vertex3 = Vector3.Lerp(vertex3, vertex1, t); vertex4 = Vector3.Lerp(vertex4, vertex2, t); rivers.AddQuadUnperturbed( vertex1, vertex2, vertex3, vertex4 ); rivers.AddQuadUV(0f, 1f, 0.8f, 1f); rivers.AddQuadHexData(indices, _weights1, _weights2); }
protected void TriangulateRoadSegment( Vector3 vertex1, Vector3 vertex2, Vector3 vertex3, Vector3 vertex4, Vector3 vertex5, Vector3 vertex6, Color weight1, Color weight2, Vector3 indices, float hexOuterRadius, int wrapSize, MapMeshChunkLayer roads ) { roads.AddQuadPerturbed( vertex1, vertex2, vertex4, vertex5, hexOuterRadius, wrapSize ); roads.AddQuadPerturbed( vertex2, vertex3, vertex5, vertex6, hexOuterRadius, wrapSize ); roads.AddQuadUV(0f, 1f, 0f, 0f); roads.AddQuadUV(1f, 0f, 0f, 0f); roads.AddQuadHexData(indices, weight1, weight2); roads.AddQuadHexData(indices, weight1, weight2); }
private void TriangulateRiverQuad( Vector3 vertex1, Vector3 vertex2, Vector3 vertex3, Vector3 vertex4, float y1, float y2, float v, bool reversed, Vector3 indices, float hexOuterRadius, int wrapSize, MapMeshChunkLayer rivers ) { vertex1.y = vertex2.y = y1; vertex3.y = vertex4.y = y2; rivers.AddQuadPerturbed( vertex1, vertex2, vertex3, vertex4, hexOuterRadius, wrapSize ); if (reversed) { rivers.AddQuadUV(1f, 0f, 0.8f - v, 0.6f - v); } else { rivers.AddQuadUV(0f, 1f, v, v + 0.2f); } rivers.AddQuadHexData(indices, _weights1, _weights2); }
private void TriangulateEstuary( EdgeVertices edge1, EdgeVertices edge2, bool incomingRiver, Vector3 waterSourceRelativeHexIndices, float hexOuterRadius, int wrapSize, MapMeshChunkLayer estuaries ) { estuaries.AddQuadPerturbed( edge2.vertex1, edge1.vertex2, edge2.vertex2, edge1.vertex3, hexOuterRadius, wrapSize ); estuaries.AddTrianglePerturbed( edge1.vertex3, edge2.vertex2, edge2.vertex4, hexOuterRadius, wrapSize ); estuaries.AddQuadPerturbed( edge1.vertex3, edge1.vertex4, edge2.vertex4, edge2.vertex5, hexOuterRadius, wrapSize ); estuaries.AddQuadUV( new Vector2(0f, 1f), new Vector2(0f, 0f), new Vector2(1f, 1f), new Vector2(0f, 0f) ); estuaries.AddQuadHexData( waterSourceRelativeHexIndices, _weights2, _weights1, _weights2, _weights1 ); estuaries.AddTriangleHexData(waterSourceRelativeHexIndices, _weights1, _weights2, _weights2); estuaries.AddQuadHexData(waterSourceRelativeHexIndices, _weights1, _weights2); estuaries.AddTriangleUV( new Vector2(0f, 0f), new Vector2(1f, 1f), new Vector2(1f, 1f) ); estuaries.AddQuadUV( new Vector2(0f, 0f), new Vector2(0f, 0f), new Vector2(1f, 1f), new Vector2(0f, 1f) ); if (incomingRiver) { estuaries.AddQuadUV2( new Vector2(1.5f, 1f), new Vector2(0.7f, 1.15f), new Vector2(1f, 0.8f), new Vector2(0.5f, 1.1f) ); estuaries.AddTriangleUV2( new Vector2(0.5f, 1.1f), new Vector2(1f, 0.8f), new Vector2(0f, 0.8f) ); estuaries.AddQuadUV2( new Vector2(0.5f, 1.1f), new Vector2(0.3f, 1.15f), new Vector2(0f, 0.8f), new Vector2(-0.5f, 1f) ); } else { estuaries.AddQuadUV2( new Vector2(-0.5f, -0.2f), new Vector2(0.3f, -0.35f), new Vector2(0f, 0f), new Vector2(0.5f, -0.3f) ); estuaries.AddTriangleUV2( new Vector2(0.5f, -0.3f), new Vector2(0f, 0f), new Vector2(1f, 0f) ); estuaries.AddQuadUV2( new Vector2(0.5f, -0.3f), new Vector2(0.7f, -0.35f), new Vector2(1f, 0f), new Vector2(1.5f, -0.2f) ); } }
private void TriangulateWaterShore( Hex source, Hex target, Vector3 waterSourceRelativeHexIndices, HexDirections direction, Dictionary <HexDirections, Hex> neighbors, HexRiverData riverData, Vector3 center, float hexOuterRadius, int wrapSize, MapMeshChunkLayer waterShore, EdgeVertices edge1, EdgeVertices edge2, float hexInnerDiameter ) { // hex.HasRiverThroughEdge(direction) if (riverData.HasRiverInDirection(direction)) { TriangulateWaterShoreWithRiver( edge1, edge2, riverData.HasIncomingRiverInDirection(direction), waterSourceRelativeHexIndices, hexOuterRadius, wrapSize, waterShore ); } else { waterShore.AddQuadPerturbed( edge1.vertex1, edge1.vertex2, edge2.vertex1, edge2.vertex2, hexOuterRadius, wrapSize ); waterShore.AddQuadPerturbed( edge1.vertex2, edge1.vertex3, edge2.vertex2, edge2.vertex3, hexOuterRadius, wrapSize ); waterShore.AddQuadPerturbed( edge1.vertex3, edge1.vertex4, edge2.vertex3, edge2.vertex4, hexOuterRadius, wrapSize ); waterShore.AddQuadPerturbed( edge1.vertex4, edge1.vertex5, edge2.vertex4, edge2.vertex5, hexOuterRadius, wrapSize ); waterShore.AddQuadUV(0f, 0f, 0f, 1f); waterShore.AddQuadUV(0f, 0f, 0f, 1f); waterShore.AddQuadUV(0f, 0f, 0f, 1f); waterShore.AddQuadUV(0f, 0f, 0f, 1f); waterShore.AddQuadHexData( waterSourceRelativeHexIndices, _weights1, _weights2 ); waterShore.AddQuadHexData( waterSourceRelativeHexIndices, _weights1, _weights2 ); waterShore.AddQuadHexData( waterSourceRelativeHexIndices, _weights1, _weights2 ); waterShore.AddQuadHexData( waterSourceRelativeHexIndices, _weights1, _weights2 ); } Hex nextNeighbor; // hex.GetNeighbor(direction.NextClockwise()); if ( neighbors.TryGetValue( direction.NextClockwise(), out nextNeighbor ) ) { Vector3 center3 = nextNeighbor.Position; if (nextNeighbor.ColumnIndex < source.ColumnIndex - 1) { center3.x += wrapSize * hexInnerDiameter; } else if (nextNeighbor.ColumnIndex > source.ColumnIndex + 1) { center3.x -= wrapSize * hexInnerDiameter; } // Work backward from the shore to obtain the triangle if the neighbor is // underwater, otherwise obtain normal triangle. Vector3 vertex3 = center3 + ( nextNeighbor.IsUnderwater ? HexagonPoint.GetFirstWaterCorner( direction.PreviousClockwise(), hexOuterRadius ) : HexagonPoint.GetFirstSolidCorner( direction.PreviousClockwise(), hexOuterRadius ) ); vertex3.y = center.y; waterShore.AddTrianglePerturbed( edge1.vertex5, edge2.vertex5, vertex3, hexOuterRadius, wrapSize ); waterSourceRelativeHexIndices.z = nextNeighbor.Index; waterShore.AddTriangleHexData( waterSourceRelativeHexIndices, _weights1, _weights2, _weights3 ); waterShore.AddTriangleUV( new Vector2(0f, 0f), new Vector2(0f, 1f), new Vector2(0f, nextNeighbor.IsUnderwater ? 0f : 1f) ); } }