I'm currently trying to extrude PShape
that was created with an SVG file from Adobe Illustrator. My current approach + image is posted below:
- Create the base image shape
- Create a copy of the base image with
z
offset Connect each vertex from both shapes and make it a
QUAD_STRIP
PShape group = createShape(GROUP); //1. Create the base image shape PShape s = createShape(0); //Base Shape //2. Create a copy of the base image with `z` offset PShape s2 = createShape(offset); //3. Connect each vertex from both shapes and make it a `QUAD_STRIP` PShape connect = connectShapes(s, s2, offset); group.addChild(s); group.addChild(s2); group.addChild(connect); shape(group, 0, 0, size, size); PShape createShape(int offset){ PShape s = loadShape("logo.svg"); s.translate(0,0,offset); return s; } PShape connectShapes(PShape normal, PShape extruded, int offset){ PShape normalChild = normal.getChild(0); PShape extrudedChild = extruded.getChild(0); println("normalChild.getVertexCount(): " + normalChild.getVertexCount()); println("extrudedChild.getVertexCount(): " + extrudedChild.getVertexCount()); PShape s = createShape(); s.beginShape(QUAD_STRIP); for (int i = 0; i < normalChild.getVertexCount(); i++) { PVector n = normalChild.getVertex(i); PVector e = extrudedChild.getVertex(i); s.vertex(n.x, n.y, 0); s.vertex(e.x, e.y, offset); } s.endShape(); return s; }
What I'm trying to mimic...
What my code is doing...
UPDATE:
Added SVG source