Skip to content

Instantly share code, notes, and snippets.

@larsberg
Created August 1, 2014 21:53
Show Gist options
  • Save larsberg/4b80d84e81562b6024ee to your computer and use it in GitHub Desktop.
Save larsberg/4b80d84e81562b6024ee to your computer and use it in GitHub Desktop.

Revisions

  1. larsberg created this gist Aug 1, 2014.
    22 changes: 22 additions & 0 deletions Svg2Mesh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    static void addSvgToMesh(string dir, ofMesh& m)
    {
    ofxSVG svg;
    svg.load(dir);

    for ( auto i=0; i<svg.getNumPath(); i++ )
    {
    auto& path = svg.getPathAt(i);
    path.simplify();

    auto pm = path.getTessellation();
    if(pm.getIndices().size())
    {
    auto& v = pm.getVertices();
    for(auto& i: pm.getIndices()) m.addVertex(v[i]);
    }
    else
    {
    for(auto& v: pm.getVertices()) m.addVertex(v);
    }
    }
    }