We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I can't figure out why these 2 rows of boxes aren't perfectly aligned to one another the way the boxes in the rows are... in other words, why is there a gap between the rows? Any help would be much appreciated. Thanks.
int dim = 50;
void setup() {
size(400, 200, P3D);
background(255);
smooth(4);
}
void draw() {
lights();
fill(255, 128);
stroke(255, 128);
ortho(0, width, 0, height); // same as ortho()
pushMatrix();
translate(100, 100, 0);
rotateX(-PI/6);
rotateY(PI/6);
box(dim);
translate(dim, 0, 0);
box(dim);
translate(dim, 0, 0);
box(dim);
translate(dim, 0, 0);
box(dim);
translate(dim, 0, 0);
box(dim);
popMatrix();
pushMatrix();
translate(100, 100+dim, 0);
rotateX(-PI/6);
rotateY(PI/6);
box(dim);
translate(dim, 0, 0);
box(dim);
translate(dim, 0, 0);
box(dim);
translate(dim, 0, 0);
box(dim);
translate(dim, 0, 0);
box(dim);
popMatrix();
}
Answers
Line 47 dim/2
Thanks for the reply. There is no line 47 in the code so I'm not clear what you're suggesting. Can you please elaborate? Thanks.
The problem is that the 'row-moving translation' should be done after the rotation. See the adapted code. Also, you should really look into for loops. Then you can shorter your code a lot.
Adapted Code
Thank you!