Ejemplo n.º 1
0
    void TriangulateCornerTerracesCliff(Vector3 bottomVertex, Cell bottomCell, Vector3 leftVertex, Cell leftCell,
                                        Vector3 rightVertex, Cell rightCell)
    {
        var terraceBindingVertex =
            Vector3.Lerp(Metrics.Perturb(bottomVertex), Metrics.Perturb(rightVertex), 1f / Math.Abs(rightCell.Elevation - bottomCell.Elevation));
        var terraceBindingColor = Color.Lerp(bottomCell.Color, rightCell.Color,
                                             1f / Math.Abs(rightCell.Elevation - bottomCell.Elevation));

        TriangulateBoundaryTriangle(bottomVertex, bottomCell, leftVertex, leftCell,
                                    terraceBindingVertex, terraceBindingColor);

        if (leftCell.GetEdgeType(rightCell) == HexagonEdgeType.Slope)
        {
            TriangulateBoundaryTriangle(leftVertex, leftCell, rightVertex, rightCell, terraceBindingVertex, terraceBindingColor);
        }
        else
        {
            terrain.AddTriangleUnperturbed(Metrics.Perturb(leftVertex), Metrics.Perturb(rightVertex), terraceBindingVertex);
            terrain.AddTriangleColor(leftCell.Color, rightCell.Color, terraceBindingColor);
        }
    }
Ejemplo n.º 2
0
    void AddWallWedge(Vector3 closeVertex, Vector3 farVertex, Vector3 point)
    {
        closeVertex = Metrics.Perturb(closeVertex);
        farVertex   = Metrics.Perturb(farVertex);
        point       = Metrics.Perturb(point);

        var center    = Metrics.WallLerp(closeVertex, farVertex);
        var thickness = Metrics.WallThicknessOffset(closeVertex, farVertex);

        Vector3 vertex3, vertex4;
        var     pointTop = point;

        point.y = center.y;

        var vertex1 = vertex3 = center - thickness;
        var vertex2 = vertex4 = center + thickness;

        vertex3.y = vertex4.y = pointTop.y = center.y + Metrics.WallHeight;
        walls.AddQuadUnperturbed(vertex1, point, vertex3, pointTop);
        walls.AddQuadUnperturbed(point, vertex2, pointTop, vertex4);
        walls.AddTriangleUnperturbed(pointTop, vertex3, vertex4);
    }