Exemplo n.º 1
0
    private void TriangulateCornerTerracesCliff(
        Vector3 begin, VoronoiCell beginCell,
        Vector3 left, VoronoiCell leftCell,
        Vector3 right, VoronoiCell rightCell)
    {
        float b = 1f / (rightCell.Elevation - beginCell.Elevation);

        b = b < 0 ? -b : b;
        Vector3 boundary      = Vector3.Lerp(VoronoiMetrics.Perturb(begin), VoronoiMetrics.Perturb(right), b);
        Color   boundaryColor = Color.Lerp(beginCell.Color, rightCell.Color, b);

        TriangulateBoundaryTriangle(begin, beginCell, left, leftCell, boundary, boundaryColor);

        if (leftCell.GetEdgeType(rightCell) == VoronoiEdgeType.Slope)
        {
            TriangulateBoundaryTriangle(left, leftCell, right, rightCell, boundary, boundaryColor);
        }
        else
        {
            Terrain.AddTriangleUnperturbed(VoronoiMetrics.Perturb(left), VoronoiMetrics.Perturb(right), boundary);
            Terrain.AddTriangleColor(leftCell.Color, rightCell.Color, boundaryColor);
        }
    }