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); }
private void AddWallSegment( Vector3 nearLeft, Vector3 farLeft, Vector3 nearRight, Vector3 farRight, float hexOuterRadius, int wrapSize, bool addTower = false ) { nearLeft = HexagonPoint.Perturb( nearLeft, hexOuterRadius, wrapSize ); farLeft = HexagonPoint.Perturb( farLeft, hexOuterRadius, wrapSize ); nearRight = HexagonPoint.Perturb( nearRight, hexOuterRadius, wrapSize ); farRight = HexagonPoint.Perturb( farRight, hexOuterRadius, wrapSize ); Vector3 left = HexagonPoint.WallLerp(nearLeft, farLeft); Vector3 right = HexagonPoint.WallLerp(nearRight, farRight); Vector3 leftThicknessOffset = HexagonPoint.WallThicknessOffset(nearLeft, farLeft); Vector3 rightThicknessOffset = HexagonPoint.WallThicknessOffset(nearRight, farRight); float leftTop = left.y + HexagonPoint.wallHeight; float rightTop = right.y + HexagonPoint.wallHeight; Vector3 vertex1; Vector3 vertex2; Vector3 vertex3; Vector3 vertex4; vertex1 = vertex3 = left - leftThicknessOffset; vertex2 = vertex4 = right - rightThicknessOffset; vertex3.y = leftTop; vertex4.y = rightTop; walls.AddQuadUnperturbed(vertex1, vertex2, vertex3, vertex4); Vector3 top1 = vertex3; Vector3 top2 = vertex4; vertex1 = vertex3 = left + leftThicknessOffset; vertex2 = vertex4 = right + rightThicknessOffset; vertex3.y = leftTop; vertex4.y = rightTop; walls.AddQuadUnperturbed(vertex2, vertex1, vertex4, vertex3); walls.AddQuadUnperturbed(top1, top2, vertex3, vertex4); if (addTower) { Transform towerInstance = Instantiate(wallTower); towerInstance.transform.localPosition = (left + right) * 0.5f; Vector3 rightDirection = right - left; rightDirection.y = 0f; towerInstance.transform.right = rightDirection; towerInstance.SetParent(_container, false); } }