コード例 #1
0
    private void TriangulateCornerTerraces(
        Vector3 begin, VoronoiCell beginCell,
        Vector3 left, VoronoiCell leftCell,
        Vector3 right, VoronoiCell rightCell)
    {
        Vector3 v3 = VoronoiMetrics.TerraceLerp(begin, left, 1);
        Vector3 v4 = VoronoiMetrics.TerraceLerp(begin, right, 1);
        Color   c3 = VoronoiMetrics.TerraceLerp(beginCell.Color, leftCell.Color, 1);
        Color   c4 = VoronoiMetrics.TerraceLerp(beginCell.Color, rightCell.Color, 1);

        Terrain.AddTriangle(begin, v3, v4);
        Terrain.AddTriangleColor(beginCell.Color, c3, c4);

        for (int i = 2; i < VoronoiMetrics.TerraceSteps; ++i)
        {
            Vector3 v1 = v3;
            Vector3 v2 = v4;
            Color   c1 = c3;
            Color   c2 = c4;
            v3 = VoronoiMetrics.TerraceLerp(begin, left, i);
            v4 = VoronoiMetrics.TerraceLerp(begin, right, i);
            c3 = VoronoiMetrics.TerraceLerp(beginCell.Color, leftCell.Color, i);
            c4 = VoronoiMetrics.TerraceLerp(beginCell.Color, rightCell.Color, i);
            Terrain.AddQuad(v1, v2, v3, v4);
            Terrain.AddQuadColor(c1, c2, c3, c4);
        }

        Terrain.AddQuad(v3, v4, left, right);
        Terrain.AddQuadColor(c3, c4, leftCell.Color, rightCell.Color);
    }
コード例 #2
0
ファイル: EdgeVertices.cs プロジェクト: Kishotta/Kardashev
    public static EdgeVertices TerraceLerp(EdgeVertices a, EdgeVertices b, int step)
    {
        EdgeVertices result;

        result.V1 = VoronoiMetrics.TerraceLerp(a.V1, b.V1, step);
        result.V2 = VoronoiMetrics.TerraceLerp(a.V2, b.V2, step);
        result.V3 = VoronoiMetrics.TerraceLerp(a.V3, b.V3, step);
        result.V4 = VoronoiMetrics.TerraceLerp(a.V4, b.V4, step);
        result.V5 = VoronoiMetrics.TerraceLerp(a.V5, b.V5, step);
        return(result);
    }
コード例 #3
0
    private void TriangulateEdgeTerraces(
        EdgeVertices begin, VoronoiCell beginCell,
        EdgeVertices end, VoronoiCell endCell, bool hasRoad)
    {
        EdgeVertices e2 = EdgeVertices.TerraceLerp(begin, end, 1);
        Color        c2 = VoronoiMetrics.TerraceLerp(beginCell.Color, endCell.Color, 1);

        TriangulateEdgeStrip(begin, beginCell.Color, e2, c2, hasRoad);

        for (int i = 2; i < VoronoiMetrics.TerraceSteps; ++i)
        {
            EdgeVertices e1 = e2;
            Color        c1 = c2;
            e2 = EdgeVertices.TerraceLerp(begin, end, i);
            c2 = VoronoiMetrics.TerraceLerp(beginCell.Color, endCell.Color, i);
            TriangulateEdgeStrip(e1, c1, e2, c2, hasRoad);
        }

        TriangulateEdgeStrip(e2, c2, end, endCell.Color, hasRoad);
    }
コード例 #4
0
    private void TriangulateBoundaryTriangle(
        Vector3 begin, VoronoiCell beginCell,
        Vector3 left, VoronoiCell leftCell,
        Vector3 boundary, Color boundaryColor)
    {
        Vector3 v2 = VoronoiMetrics.Perturb(VoronoiMetrics.TerraceLerp(begin, left, 1));
        Color   c2 = VoronoiMetrics.TerraceLerp(beginCell.Color, leftCell.Color, 1);

        Terrain.AddTriangleUnperturbed(VoronoiMetrics.Perturb(begin), v2, boundary);
        Terrain.AddTriangleColor(beginCell.Color, c2, boundaryColor);

        for (int i = 2; i < VoronoiMetrics.TerraceSteps; ++i)
        {
            Vector3 v1 = v2;
            Color   c1 = c2;
            v2 = VoronoiMetrics.Perturb(VoronoiMetrics.TerraceLerp(begin, left, i));
            c2 = VoronoiMetrics.TerraceLerp(beginCell.Color, leftCell.Color, i);
            Terrain.AddTriangleUnperturbed(v1, v2, boundary);
            Terrain.AddTriangleColor(c1, c2, boundaryColor);
        }

        Terrain.AddTriangleUnperturbed(v2, VoronoiMetrics.Perturb(left), boundary);
        Terrain.AddTriangleColor(c2, leftCell.Color, boundaryColor);
    }