pdf export & ortho()
in
Core Library Questions
•
1 year ago
Hi!
I want to make a PDF export of a 3d scene in ortho view.
It works so far, but somehow the display order in the PDF it totally wrong.
(left: screenshot of the sketch, right: pdf-output)
Any idea, how to fix that??
I tried to play around with scaling the view in x, y & z (z.B.scale(-1, 1 1)), but that didn't work.
this is the code of the sketch.
I took the PDF stuff out of the processing example:
I want to make a PDF export of a 3d scene in ortho view.
It works so far, but somehow the display order in the PDF it totally wrong.
(left: screenshot of the sketch, right: pdf-output)
Any idea, how to fix that??
I tried to play around with scaling the view in x, y & z (z.B.scale(-1, 1 1)), but that didn't work.
this is the code of the sketch.
I took the PDF stuff out of the processing example:
- import processing.pdf.*;
import processing.opengl.*;
boolean record;
boolean[][][] filled;
void setup() {
size(1000, 1000, P3D); smooth();
strokeWeight(1);
ortho(0, width, 0, height,-10, 10);
filled = new boolean[10][10][5];
for (int i = 0; i < filled.length; i++)
for (int j = 0; j < filled[0].length; j++)
for (int k = 0; k < filled[0][0].length; k++)
if (random(1) < 0.4) filled[i][j][k] = true;
}
void draw() {
if (mousePressed) record = true;
if (record) {// set up PGraphicsPDF for use with beginRaw()
PGraphicsPDF pdf = (PGraphicsPDF)beginRaw(PDF, "pdf_complex_out.pdf");
//pdf.ortho(0, width, 0, height, 1000, -1000);
// set default Illustrator stroke styles and paint background rect.
pdf.strokeJoin(MITER);
pdf.strokeCap(SQUARE);
pdf.fill(255);
pdf.noStroke();
pdf.rect(0,0, width,height);
strokeWeight(1);
}
background(255); directionalLight(255, 255, 255, 1, 4, -3); ambientLight(155, 155, 155);
translate(width, height, 0);
rotateX(-PI/6);
rotateY(PI/3);
scale(2);
for (int i = 0; i < filled.length; i++)
for (int j = 0; j < filled[0].length; j++)
for (int k = 0; k < filled[0][0].length; k++) {
if (filled[i][j][k]){
pushMatrix();
translate(i * 10, j * 10, k * 10);
//scale(-1, 1, 1);
box(10);
popMatrix();
} else {
}
}
if (record) {record = false; endRaw();}
}
3