We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi. Is it possible to use more than one camera in 3D? And is it possible without drawing all the shapes again for each camera?
I tried redrawing everything four times:
PGraphics[] pg;
void setup() {
size(1000, 800, P3D);
pg = new PGraphics[4];
for(int i=0; i<pg.length; i++) {
pg[i] = createGraphics(width/2, height/2, P3D);
}
}
void draw() {
for(int i=0; i<pg.length; i++) {
PGraphics p = pg[i];
p.beginDraw();
p.background(80);
p.lights();
p.translate(p.width/2, p.height/2);
p.rotateY((i+1)*frameCount*0.0011);
p.rotateX((i+1)*frameCount*0.0013);
p.stroke(255, 30);
p.fill(#FF0000);
p.box(200, 200, 10);
p.fill(#00FF00);
p.box(200, 10, 200);
p.fill(#0000FF);
p.box(10, 200, 200);
p.endDraw();
image(p, (i % 2) * width/2, (i/2) * height/2);
}
}
But the z-indexes are messed up. Last shape (the blue one) is always on top. There should be 3 crossing planes. Also I think lights() is not working.
I'm on Ubuntu, old Intel graphics. Maybe it works on newer systems?
Thanks!
Answers
looks perfect on my system.
Ok thanks! That means it's my system.
It would be still nice to know if it's possible to just change the camera without redrawing the objects four times. Like in most 3D programs, where you can see Top, Front, Left and Perspective views of the same scene.
Just to warn if any1 is using an old Processing version like me (v2.0.2), that I had to place image() in its own loop
in order not to confuse translation positioning somehow! :|
It's similar inconsistencies I've encountered in this old thread:
http://forum.processing.org/two/discussion/3256/performance-issues-with-background
Hi @GoToLoop, this is not related to the original question, but have you measured execution time improvements related to all the changes you did to the example above? (bit shifting instead of division, using not equals instead of less than, using static finals, etc?) I've often read that the current java compiler does already do those things automatically, and I could not detect improvements when I measured execution time. Those changes had a positive side effect thought. They made me smile :)
While a program is running, Java's runtime continuously analyzes the code in order to see where it can be optimized.
It might succeed or not though! Either way, I've already got many parts optimized for sure! ;)
On a side node, there's no way my fixed code for Processing v2.0.2 can be any speedier than yours,
since I'm using 2 loops in order to avoid the bug! [-(