Reputation: 6627
I am trying to display SVG files in 3D with Processing.org using either the OPENGL or P3D libraries. The issue, documented here (and other places: 1, 2, and an undesirable library hack), is that these renderers to not support complex shapes (those with holes or complicated breaks).
Is there an alternative to SVG for the graphics, or another library I could use?
Below are image files and code samples. This first image uses the default renderer:
This image uses OPENGL 3D library. You can see it struggles to reproduce the SVG files.
I've posted a zip of this sketch with images and code below. Uncomment the OPENGL line and comment the default line to see the problem.
import processing.opengl.*;
float wh = 0;
void setup() {
//size(600, 600, OPENGL); // use OPENGL
size(600, 600); // use default library
background(255);
smooth();
}
void draw() {
wh = random(40, 200);
PShape s;
String file = "gear" + ceil(random(0, 12)) + ".svg";
s = loadShape(file);
shape(s, random(-20, width), random(-20, height), wh, wh);
}
Upvotes: 2
Views: 3747
Reputation: 45
http://www.hypeframework.org The Hype Framework, there is some cool tutorials on skillshare.com
Upvotes: 0
Reputation: 46
You can use Geomerative library which works fine with the OPENGL renderer. You can find it right there: http://www.ricardmarxer.com/geomerative/
This is your provided example adapted to work with Geomerative that works fine with OPENGL:
import geomerative.*;
import processing.opengl.*;
float wh = 0;
void setup() {
size(600, 600, OPENGL);
RG.init( this );
background(255);
smooth();
}
void draw() {
wh = random(40, 200);
RShape s;
String file = "gear" + ceil(random(0, 12)) + ".svg";
s = RG.loadShape(file);
pushMatrix();
translate(random(-20, width), random(-20, height));
s.draw();
popMatrix();
}
Upvotes: 3