We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi everyone !
I'm trying to export some PDF pictures from this code :
import processing.pdf.*;
boolean record;
int cols, rows;
int scale = 15;
int w = 1200;
int h = 900;
float flying = 0;
float[][] terrain;
//-------------------------------------------------------//
void setup() {
size(600, 600, P3D);
cols = w / scale;
rows = h / scale;
terrain = new float[cols][rows];
}
//-------------------------------------------------------//
void draw() {
if(record) {
beginRecord(PDF, "Visuel-####.pdf");
}
flying -= 0.005;
float yoff = flying;
for (int y = 0; y < rows; y++) {
float xoff = 0;
for (int x = 0; x < cols; x++) {
terrain[x][y] = map(noise(xoff, yoff), 0, 1, -50, 50);
xoff += 0.1;
}
yoff += 0.1;
}
background(255);
stroke(0);
noFill();
translate(width/2, height/2);
rotateX(PI/2.05);
translate(-w/2, -h/2);
for (int y = 0; y < rows-1; y++) {
beginShape(TRIANGLE_STRIP);
for (int x = 0; x < cols; x++) {
vertex(x*scale, y*scale, terrain[x][y]);
vertex(x*scale, (y+1)*scale, terrain[x][y+1]);
}
endShape();
}
if(record) {
endRecord();
record=false;
}
}
void mousePressed() {
record = true;
}
But I have some problems : the files are created but they are empty white pictures ! Is this link to the fact the code is including P3D ? Someone can help ?
Thanks !
Tanguy
Answers
it says in the error box
"rotateX() can only be used with a renderer that supports 3D, such as P3D.
vertex() with x, y, and z coordinates can only be used with a renderer that supports 3D, such as P3D. Use a version without a z-coordinate instead."
this is a clue...
https://processing.org/reference/libraries/pdf/index.html
this has an example of exporting from 3d, using beginRaw, but it might not look like you expect (ime it's bad at depth)
Hi Koogs,
Thanks ! It's working. My fault , I didn't read enought about PDF library.
Have a good day !