Fill polygon with texture

Jun 25, 2014 at 8:55 PM
How can I make 2D polygon geometry with image texture.

For the rectangle I use two triangle and for texture I added coordinates for triangles:

// triangle ABC

// triangle ACD

mesh.TextureCoordinates.Add(new Point(0, 1)); // point A
mesh.TextureCoordinates.Add(new Point(1, 1)); // point B
mesh.TextureCoordinates.Add(new Point(1, 0)); // point C
mesh.TextureCoordinates.Add(new Point(0, 0)); // point D

var d = new DiffuseMaterial(imgBrush);
mGeometries.Add(new GeometryModel3D(mesh, d));


On this discussion I found functions for create of polygon.
public static MeshGeometry3D FillPolygon(Polygon p)
        List<Point3D> pts3D = new List<Point3D>();
        foreach (var point in p.Points)
            pts3D.Add(new Point3D(point.X, point.Y, 0));
        Polygon3D p3 = new Polygon3D(pts3D);
        return FillPolygon(p3);

    public static MeshGeometry3D FillPolygon(Polygon3D p3)
        var meshBuilder = new MeshBuilder(false, false);

        Polygon polygon = p3.Flatten();
        var triangleIndexes = CuttingEarsTriangulator.Triangulate(polygon.Points);

        meshBuilder.Append(p3.Points, triangleIndexes);

        return meshBuilder.ToMesh();

Polygon drawing right, but I do not know how I do configuration for fill texture on the polygon.
Texture is rectangle image and I wants show shape cut of texture on the polygon.

Thank you very much.