I’m trying to achieve something which should be fairly easy, but after checking the forums I still can’t get it to work: making 3D-objects to rotate in hires imagery in Processing (v3 in this case, v4 doesn’t seem to work) by using a PGraphics object. Everything works, except the rotating part, hence the obvious.
I tried all kinds of variations with begin/endDraw(), rotating the screen instead g, wondering why I have to declare g anyway since it’s a global variable anyway (in JAVA2D mode at least), using another PGraphics object instead of global g, using push/pop etc. I get the hires image as expected, except for the boxes which are fixed in position, not rotating at all. What am I doing wrong?
int w=3000, h=3000;
PGraphics g;
void setup() {
g = createGraphics(w, h, P3D);
size(1000, 1000, P3D);
background(#ffffff);
}
void draw() {
g.beginDraw();
g.rotate(.01*frameCount); // this should slowly rotate the boxes, but it doesn't!
g.fill(#aa33ff+frameCount);
g.stroke(#ffffff);
g.strokeWeight(5);
g.endDraw(); // I only get hires output with end/beginDraw before drawing boxes
g.beginDraw();
g.translate(int(random(w)), int(random(h)));
g.box(random(100));
g.endDraw();
image(g, 0, 0, width, height);
}
void keyPressed() {
if (key==' ') {
g.save("hires.png");
}
}