//A building based on The Ark in North Sydney (aka Coca-Cola Place). SIZE = 1.0; FLOORS = 41; //should be an odd number greater than 5 WIDTH = 60; //should be even number //textures window = new UniformTexture(); window.diffuseColor.setRGB(0.5,0.5,0.5); window.specularity = 0.6f; window.shininess = 1.0f; light = new UniformTexture(); light.diffuseColor.setRGB(0.7,0.7,0.7); light.specularity = 0.4f; light.shininess = 1.0f; conc = new UniformTexture(); conc.diffuseColor.setRGB(0.6,0.5,0.4); gray = new UniformTexture(); gray.diffuseColor.setRGB(0.5,0.5,0.5); //first 5 floors box = new Cube(SIZE*(WIDTH-6.1),SIZE*5,SIZE*13.9); box.setTexture(window, window.getDefaultMapping(box)); pos = new Vec3(0,SIZE*2.5,0); script.addObject(box, new CoordinateSystem(pos, 0,0,0)); for (i=-6;i<7;i++) { box = new Cube(SIZE*(WIDTH-6),SIZE*5,0.1*SIZE); box.setTexture(conc, conc.getDefaultMapping(box)); pos = new Vec3(0,2.5*SIZE,i*SIZE); script.addObject(box, new CoordinateSystem(pos, 0,0,0)); } for (i=-(WIDTH-6)/2+1;i<(WIDTH-6)/2;i++) { box = new Cube(0.1*SIZE,SIZE*5,14*SIZE); box.setTexture(conc, conc.getDefaultMapping(box)); pos = new Vec3(i*SIZE,2.5*SIZE,0); script.addObject(box, new CoordinateSystem(pos, 0,0,0)); } for (i=0;i<5;i++) { box = new Cube((WIDTH-6)*SIZE,SIZE*0.1,14*SIZE); box.setTexture(conc, conc.getDefaultMapping(box)); pos = new Vec3(0,i*SIZE,0); script.addObject(box, new CoordinateSystem(pos, 0,0,0)); } //pillars c = new Cylinder(5*SIZE,0.25*SIZE,0.25*SIZE,1.0f); c.setTexture(conc, conc.getDefaultMapping(c)); for (i=-4;i<=4;i=i+2) { x = SIZE*(WIDTH-1.5)/2.0; pos = new Vec3(x,2.5*SIZE,i*SIZE); script.addObject(c, new CoordinateSystem(pos, 0,0,0)); pos = new Vec3(-x,2.5*SIZE,i*SIZE); script.addObject(c, new CoordinateSystem(pos, 0,0,0)); } //upper floors box = new Cube((WIDTH-0.05)*SIZE,(FLOORS-5.05)*SIZE,13.95*SIZE); box.setTexture(window, window.getDefaultMapping(box)); pos = new Vec3(0,SIZE*(FLOORS-5)/2 +5*SIZE,0); script.addObject(box, new CoordinateSystem(pos, 0,0,0)); for (i=-6;i<7;i++) { box = new Cube(SIZE*WIDTH,(FLOORS-5)*SIZE,0.1*SIZE); box.setTexture(conc, conc.getDefaultMapping(box)); pos = new Vec3(0,SIZE*(FLOORS-5)/2 +5*SIZE,i*SIZE); script.addObject(box, new CoordinateSystem(pos, 0,0,0)); } for (i=-WIDTH/2+1;i5) k = 0.6*SIZE; box = new Cube(WIDTH*SIZE+k,0.1*SIZE,14*SIZE+k); box.setTexture(conc, conc.getDefaultMapping(box)); pos = new Vec3(0,i*SIZE,0); script.addObject(box, new CoordinateSystem(pos, 0,0,0)); if (i>5) { pos = new Vec3(0,(i-0.3)*SIZE,0); script.addObject(box, new CoordinateSystem(pos, 0,0,0)); } } //between the bend and the rest of the building p = 1.0-2.0/FLOORS; y = p*SIZE*FLOORS/2; z = p*SIZE*FLOORS/30+2*SIZE; z2 = 2*SIZE; vert = new Vec3[6]; vert[0] = new Vec3(0,-y,z); vert[1] = new Vec3(0, 0,z2); vert[2] = new Vec3(0, y,z); vert[3] = new Vec3(0, y,0); vert[4] = new Vec3(0, 0,0); vert[5] = new Vec3(0,-y,0); int[][] faces = { {0,1,5}, {1,4,5}, {1,2,4}, {2,3,4} }; mesh = new TriangleMesh(vert, faces); mesh.setSmoothingMethod(0); mesh.setTexture(light, light.getDefaultMapping(mesh)); pos = new Vec3((WIDTH/2-2)*SIZE,SIZE*FLOORS/2+3*SIZE,6*SIZE); script.addObject(mesh, new CoordinateSystem(pos, 0,0,0)); pos = new Vec3(-(WIDTH/2-2)*SIZE,SIZE*FLOORS/2+3*SIZE,6*SIZE); script.addObject(mesh, new CoordinateSystem(pos, 0,0,0)); box = new Cube((WIDTH-4)*SIZE,4*SIZE,2*SIZE); box.setTexture(light, light.getDefaultMapping(box)); pos = new Vec3(0,FLOORS*SIZE,7*SIZE); script.addObject(box, new CoordinateSystem(pos, 0,0,0)); pos = new Vec3(0,6*SIZE,7*SIZE); script.addObject(box, new CoordinateSystem(pos, 0,0,0)); box = new Cube((WIDTH-4)*SIZE,0.01*SIZE,2*SIZE); box.setTexture(light, light.getDefaultMapping(box)); pos = new Vec3(0,FLOORS*SIZE+2*SIZE,z+5*SIZE); script.addObject(box, new CoordinateSystem(pos, 0,0,0)); pos = new Vec3(0,4*SIZE,z+5*SIZE); script.addObject(box, new CoordinateSystem(pos, 0,0,0)); //the bent wall x = SIZE*WIDTH/2; y = SIZE*FLOORS/2; z = SIZE*FLOORS/30; vert = new Vec3[6]; vert[0] = new Vec3(-x,-y,z); vert[1] = new Vec3(-x, 0,0); vert[2] = new Vec3(-x, y,z); vert[3] = new Vec3( x, y,z); vert[4] = new Vec3( x, 0,0); vert[5] = new Vec3( x,-y,z); int[][] faces = { {0,1,5}, {1,4,5}, {1,2,4}, {2,3,4} }; mesh = new TriangleMesh(vert, faces); mesh.setSmoothingMethod(0); mesh.setTexture(light, light.getDefaultMapping(mesh)); pos = new Vec3(0,SIZE*FLOORS/2+3*SIZE,8*SIZE); script.addObject(mesh, new CoordinateSystem(pos, 0,0,0)); //t = new Tube(vert, 0.1*SIZE,0,1); //t.setTexture(conc, conc.getDefaultMapping(t)); //script.addObject(t, new CoordinateSystem(pos, 0,0,0)); //floors on bent wall for (i=0;i<=FLOORS/2;i++) { p = 1.0 - i*2.0/FLOORS; data = new Vec3[2]; data[0] = new Vec3(-x,-y*p,z*p); data[1] = new Vec3( x,-y*p,z*p); t = new Tube(data, 0.1*SIZE,0,0); t.setTexture(gray, gray.getDefaultMapping(t)); script.addObject(t, new CoordinateSystem(pos, 0,0,0)); data = new Vec3[2]; data[0] = new Vec3(-x,y*p,z*p); data[1] = new Vec3( x,y*p,z*p); t = new Tube(data, 0.1*SIZE,0,0); t.setTexture(gray, gray.getDefaultMapping(t)); script.addObject(t, new CoordinateSystem(pos, 0,0,0)); } data = new Vec3[3]; data[0] = new Vec3(0,-y,z); data[1] = new Vec3(0,0,0); data[2] = new Vec3(0,y,z); t = new Tube(data, 0.1*SIZE,0,0); t.setTexture(gray, gray.getDefaultMapping(t)); for(i=-WIDTH/2;i<=WIDTH/2;i++) { pos = new Vec3(i*SIZE,SIZE*FLOORS/2+3*SIZE,8*SIZE); script.addObject(t, new CoordinateSystem(pos, 0,0,0)); } //vertical things on bent wall d = WIDTH/8.0; k = FLOORS/21.0; for (i=0;i<7;i++) { box = new Cube(0.5*SIZE*k,SIZE*FLOORS*0.6,0.5*SIZE*k); box.setTexture(conc, conc.getDefaultMapping(box)); vv = Math.round(Math.abs(d*(i-3))); vv = Math.signum(i-3)*vv; pos = new Vec3(vv*SIZE,SIZE*FLOORS/2+3*SIZE,8*SIZE); script.addObject(box, new CoordinateSystem(pos, 0,45,0)); }