Starting to play with importing an obj file using loadShape() and rendering it as a wireframe.
Now comes the tricky part… how to do ‘hidden line removal’ (similar to back-face detection, culling… still sorting out exact term here). Essentially, can someone point me in the right direction for doing this filtering or know of a solution from a previous forum discussion? I’ve found a handful of PDFs and presentations presenting algorithms that go over my head in terms of applying within this context… a few such links are:
http://www.cs.brandeis.edu/~cs155/Lecture_14.pdf
http://csis.pace.edu/~marchese/CG_Rev/Lect9New/cg_l9new.htm
http://underpop.free.fr/j/java/developing-games-in-java/1592730051_ch09lev1sec1.html
Here’s the base code for viewing the obj/PShape as a wireframe.
Wondering if/how screenX/Y/Z might play a role to solve this?
// obj file instance
PShape obj;
public void setup() {
size(512, 512, P3D);
// load object
obj = loadShape("teapot.obj");
}
public void draw() {
background(0);
translate(width/2, height/2);
scale(2);
rotateZ(PI);
rotateY(radians(frameCount));
noFill();
stroke(255);
int children = obj.getChildCount();
beginShape();
for (int i = 0; i < children; i++) {
PShape child = obj.getChild(i);
for (int j = 0; j < child.getVertexCount(); j++) {
PVector v = child.getVertex(j);
vertex(v.x, v.y, v.z);
}
}
endShape();
}