Exemple #1
0
    void TriangulateEdgeStrip(TriMesh mesh, EdgeVertices e1, Color c1, EdgeVertices e2, Color c2, bool isRiverInDir)
    {
        mesh.AddQuad(e1.v1, e1.v2, e2.v1, e2.v2);
        mesh.AddQuadColor(c1, c2);


        if (isRiverInDir)
        {
            Vector3 t = new Vector3(0, TriMetrics.waterElevationOffset, 0);
            rivers.AddQuad(e1.v2 + t, e1.v4 + t, e2.v2 + t, e2.v4 + t);
            rivers.AddQuadColor(Color.blue, Color.blue);
        }
        else
        {
            mesh.AddQuad(e1.v2, e1.v4, e2.v2, e2.v4);
            mesh.AddQuadColor(c1, c2);
        }
        mesh.AddQuad(e1.v4, e1.v5, e2.v4, e2.v5);
        mesh.AddQuadColor(c1, c2);
    }
Exemple #2
0
    void TriangulateWithRiver(TriCell cell, TriDirection direction, Vector3 center, EdgeVertices edge, Color color)
    {
        Vector3 riverOffset = new Vector3(0, TriMetrics.streamBedElevationOffset - TriMetrics.waterElevationOffset, 0);
        Vector3 nextCorner, prevCorner;

        nextCorner = (center + edge.v1) / 2f;
        prevCorner = (center + edge.v5) / 2f;
        Vector3 underCenter = center, underNextCorner = nextCorner, underPrevCorner = prevCorner;

        underCenter.y     += TriMetrics.streamBedElevationOffset;
        underNextCorner.y += TriMetrics.streamBedElevationOffset;
        underPrevCorner.y += TriMetrics.streamBedElevationOffset;

        EdgeVertices underEdge = edge;

        underEdge.v1.y += TriMetrics.streamBedElevationOffset;
        underEdge.v2.y += TriMetrics.streamBedElevationOffset;
        underEdge.v3.y += TriMetrics.streamBedElevationOffset;
        underEdge.v4.y += TriMetrics.streamBedElevationOffset;
        underEdge.v5.y += TriMetrics.streamBedElevationOffset;

        terrain.AddTriangle(nextCorner, edge.v1, edge.v2);
        terrain.AddTriangle(prevCorner, edge.v4, edge.v5);
        terrain.AddTriangle(underCenter, underEdge.v2, underEdge.v4);
        terrain.AddTriangleColor(color);
        terrain.AddTriangleColor(color);
        terrain.AddTriangleColor(color);

        if (!cell.IsUnderwater)
        {
            rivers.AddTriangle(underCenter - riverOffset, underEdge.v2 - riverOffset, underEdge.v4 - riverOffset);
            rivers.AddTriangleColor(Color.blue);
        }

        if (cell.HasRiverThroughEdge(direction.Next()))
        {
            terrain.AddTriangle(underEdge.v4, underPrevCorner, underCenter);
            terrain.AddTriangleColor(color);
            if (!cell.IsUnderwater)
            {
                rivers.AddTriangle(underEdge.v4 - riverOffset, underPrevCorner - riverOffset, underCenter - riverOffset);
                rivers.AddTriangleColor(Color.blue);
            }

            terrain.AddQuad(underPrevCorner, prevCorner, underEdge.v4, edge.v4);
            terrain.AddQuadColor(color, color);
        }
        else
        {
            terrain.AddTriangle(center, edge.v4, prevCorner);
            terrain.AddQuad(underCenter, center, underEdge.v4, edge.v4);
            terrain.AddTriangleColor(color);
            terrain.AddQuadColor(color, color);
        }
        if (cell.HasRiverThroughEdge(direction.Previous()))
        {
            terrain.AddTriangle(underEdge.v2, underCenter, underNextCorner);
            terrain.AddTriangleColor(color);

            if (!cell.IsUnderwater)
            {
                rivers.AddTriangle(underEdge.v2 - riverOffset, underCenter - riverOffset, underNextCorner - riverOffset);
                rivers.AddTriangleColor(Color.blue);
            }
            terrain.AddQuad(underEdge.v2, edge.v2, underNextCorner, nextCorner);
            terrain.AddQuadColor(color, color);
        }
        else
        {
            terrain.AddTriangle(center, nextCorner, edge.v2);
            terrain.AddQuad(underEdge.v2, edge.v2, underCenter, center);
            terrain.AddTriangleColor(color);
            terrain.AddQuadColor(color, color);
        }
    }