class Gbox { End pr1, pr2; Colr icol; Dim idim; Pos ipos; Boxinfo boxinfo1, boxinfo2; Rspecs iroofspecs; float irot; int done = 0; int scaledim = 200; Gbox() { ipos = new Pos(randpos(scaledim*2), randpos(scaledim*2), randpos(scaledim*2)); idim = new Dim(randsz(scaledim*3), randsz(scaledim*3), randsz(scaledim*3)); icol = new Colr(random(100)+100, random(100)+100, random(100)); irot = random(2); iroofspecs = new Rspecs( idim.w, // width idim.d // depth ); boxinfo1 = new Boxinfo(ipos, idim, icol, iroofspecs, irot); boxinfo2 = new Boxinfo(ipos, idim, icol, iroofspecs, irot); pr1 = chooseEnd(boxinfo1, 1); pr2 = chooseEnd(boxinfo2, -1); } End chooseEnd(Boxinfo info, float end) { float r = random(3); if (r < 1) { // Hipend // Gableend // GableHipend return new Hipend(info, end); } else if (r < 2) { return new Gableend(info, end); } else { return new GableHipend(info, end); } } void displayboth() { pr1.display(); pr2.display(); join(pr1, pr2); //noStroke(); //roofjoin(pr1, pr2); } void growboth() { if (pr1.done == 0) { pr1.grow(); pr2.grow(); } else { done = pr1.done; } } void join(End pr1, End pr2) { //stroke(255,0,0); float[] tex = new float[2]; fill(icol.r, icol.g, icol.b); pushMatrix(); translate(pr1.pos.x, height/3, pr1.pos.z); if (pr1.rot < 1) { rotateY(radians(90)); } beginShape(); /* textureMode(NORMALIZED); tint(random(100)+100, random(100)+100, random(100)); //tint(0,255,255); texture(a); for(int i = 0; i < pr1.sideA.length; i++) { tex = texex(i); vertex(pr1.sideA[i].x, pr1.sideA[i].y, pr1.sideA[i].z, tex[0], tex[1]); } for(int j = pr2.sideA.length-1; j >= 0; j--) { tex = texex(3-j); vertex(pr2.sideA[j].x, pr2.sideA[j].y, pr2.sideA[j].z, tex[0], tex[1]); } */ // same as above w/out texture (u and v) for(int i = 0; i < pr1.sideA.length; i++) { vertex(pr1.sideA[i].x, pr1.sideA[i].y, pr1.sideA[i].z); } for(int j = pr2.sideA.length-1; j >= 0; j--) { vertex(pr2.sideA[j].x, pr2.sideA[j].y, pr2.sideA[j].z); } endShape(CLOSE); beginShape(); /* textureMode(NORMALIZED); texture(a); for(int i = 0; i < pr1.sideB.length; i++) { // 0, 1 tex = texex(i); vertex(pr1.sideB[i].x, pr1.sideB[i].y, pr1.sideB[i].z, tex[0], tex[1]); } for(int j = pr2.sideB.length-1; j >= 0; j--) { // 1, 0 tex = texex(3-j); vertex(pr2.sideB[j].x, pr2.sideB[j].y, pr2.sideB[j].z, tex[0], tex[1]); } */ // same as above w/out texture (u and v) for(int i = 0; i < pr1.sideB.length; i++) { // 0, 1 vertex(pr1.sideB[i].x, pr1.sideB[i].y, pr1.sideB[i].z); } for(int j = pr2.sideB.length-1; j >= 0; j--) { // 1, 0 vertex(pr2.sideB[j].x, pr2.sideB[j].y, pr2.sideB[j].z); } endShape(CLOSE); popMatrix(); } float[] texex(int iint) { float[] tex = { 0, 0 }; switch(iint) { case 1: tex[1] = 1; break; case 2: tex[0] = 1; tex[1] = 1; break; case 3: tex[0] = 1; break; } return tex; } void roofjoin(End pr1, End pr2) { stroke(255,0,0); fill(80); pushMatrix(); translate(pr1.pos.x, height/3, pr1.pos.z); // translate(0, height/3, 0); if (pr1.rot < 1) { rotateY(radians(90)); } pushMatrix(); translate(0, -pr1.dim.h, 0); /* for(int i = 0; i < pr1.roofA.length; i++) { vertex(pr1.roofA[i].x, pr1.roofA[i].y, pr1.roofA[i].z); } for(int j = pr2.roofA.length-1; j >= 0; j--) { vertex(pr2.roofA[j].x, pr2.roofA[j].y, pr2.roofA[j].z); } endShape(CLOSE); beginShape(); for(int i = 0; i < pr1.roofB.length; i++) { vertex(pr1.roofB[i].x, pr1.roofB[i].y, pr1.roofB[i].z); } for(int j = pr2.roofB.length-1; j >= 0; j--) { vertex(pr2.roofB[j].x, pr2.roofB[j].y, pr2.roofB[j].z); } */ //beginShape(); //endShape(CLOSE); popMatrix(); popMatrix(); } float randpos(float b) { return (random(b/40)*40) - b/2; } float randsz(float b) { return (random(b/40)*40) + 40; } }