示例#1
0
        public static void Triangulate <V>(Tesselator <V> tess, Outline <V> outline, vToLoc <V, double[]> vertexToLocation)
        {
            bool inContour = false;

            tess.BeginPolygon();

            for (int i = 0; i < outline.Size; ++i)
            {
                if (outline.Types[i] == Outline <V> .PathType.MoveTo) // new contour
                {
                    if (inContour)
                    {
                        tess.EndContour();
                    }
                    tess.BeginContour();
                    inContour = true;
                }

                V v = outline.Path[i];
                tess.AddVertex(vertexToLocation(v), v);
            }

            if (inContour)
            {
                tess.EndContour();
            }

            tess.EndPolygon();
        }
示例#2
0
        public static Mesh Triangulate(Tesselator <Vertex> tess, Polygon p)
        {
            tess.BeginPolygon();

            foreach (Contour c in p.Contours)
            {
                tess.BeginContour();

                foreach (Vertex v in c.path)
                {
                    tess.AddVertex(v.location, v);
                }

                tess.EndContour();
            }
            tess.EndPolygon();

            return(new Mesh(tess.Vertice, tess.Indices));
        }