//A building with the same basic structure as the Hearst Building in New York City. SIZE = 1.0; LEVELS = 9;//total height in floors is LEVELS*8+5 window = new UniformTexture(); window.diffuseColor.setRGB(0.5,0.5,0.6); window.specularity = 0.5f; window.shininess = 1.0f; white = new UniformTexture(); white.diffuseColor.setRGB(0.8,0.8,0.8); white.shininess = 0.8f; TriangleMesh triangle(double xsize, double ysize, double zsize, double top) { //a triangular with the top chopped off, width of the top cut is top double x = xsize/2; double y = ysize; double z = zsize/2; double x2 = top/2; vertices = new Vec3[8]; // 8 vertices + 6 faces vertices[0] = new Vec3(-x, 0.0, -z); vertices[1] = new Vec3(x, 0.0, -z);// vertices[2] = new Vec3(x2, y, -z);// vertices[3] = new Vec3(-x2, y, -z); vertices[4] = new Vec3(-x, 0.0, z); vertices[5] = new Vec3(x, 0.0, z);// vertices[6] = new Vec3(x, y, z);// vertices[7] = new Vec3(-x, y, z); //triangular faces int[][] faces = {{ 0, 3, 2}, { 0, 2, 1}, { 0, 1, 5}, { 0, 5, 4}, { 0, 4, 7}, {0, 7, 3}, { 6, 5, 1}, { 6, 1, 2}, { 6, 2, 3}, { 6, 3, 7}, { 6, 7, 4}, {6, 4, 5}}; mesh = new TriangleMesh(vertices, faces); mesh.setSmoothingMethod(0); return(mesh); } void level(double yoffset) { int i; double r, x; offset = new Vec3(0,yoffset,0); mesh = triangle(16*SIZE,4*SIZE,2*SIZE,12*SIZE); mesh.setTexture(window,window.getDefaultMapping(mesh)); pos = new Vec3(0,0,7*SIZE); script.addObject(mesh, new CoordinateSystem(pos.plus(offset), 0,180,0)); pos = new Vec3(0,8*SIZE,7*SIZE); script.addObject(mesh, new CoordinateSystem(pos.plus(offset), 0,180,180)); pos = new Vec3(0,0,-7*SIZE); script.addObject(mesh, new CoordinateSystem(pos.plus(offset), 0,0,0)); pos = new Vec3(0,8*SIZE,-7*SIZE); script.addObject(mesh, new CoordinateSystem(pos.plus(offset), 0,0,180)); box = new Cube(16*SIZE,8*SIZE,12*SIZE); box.setTexture(window, window.getDefaultMapping(box)); pos = new Vec3(0,4*SIZE,0); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,0,0)); r = 4.675; box = new Cube(16.4*SIZE,0.4*SIZE,16.4*SIZE); box.setTexture(white, white.getDefaultMapping(box)); pos = new Vec3(0,8*SIZE,0); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,0,0)); for(i=-2;i<2;i++) { box = new Cube(r*SIZE,0.4*SIZE,16.4*SIZE); box.setTexture(white, white.getDefaultMapping(box)); pos = new Vec3(4*i*SIZE+3*SIZE,2*SIZE,0); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,0,63.4)); pos = new Vec3(4*i*SIZE+1*SIZE,2*SIZE,0); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,0,-63.4)); pos = new Vec3(0,2*SIZE,4*i*SIZE+3*SIZE); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,90,63.4)); pos = new Vec3(0,2*SIZE,4*i*SIZE+1*SIZE); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,90,-63.4)); } box = new Cube(12.2*SIZE,0.4*SIZE,16.4*SIZE); box.setTexture(white, white.getDefaultMapping(box)); pos = new Vec3(0,4*SIZE,0); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,0,0)); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,90,0)); for(i=-2;i<2;i++) { box = new Cube(r*SIZE,0.4*SIZE,16.4*SIZE); box.setTexture(white, white.getDefaultMapping(box)); pos = new Vec3(4*i*SIZE+1*SIZE,6*SIZE,0); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,0,63.4)); pos = new Vec3(4*i*SIZE+3*SIZE,6*SIZE,0); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,0,-63.4)); pos = new Vec3(0,6*SIZE,4*i*SIZE+1*SIZE); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,90,63.4)); pos = new Vec3(0,6*SIZE,4*i*SIZE+3*SIZE); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,90,-63.4)); } //bar on corner x = 2*Math.sqrt(2)+0.25; box = new Cube(x*SIZE,0.3*SIZE,x*SIZE); box.setTexture(white, white.getDefaultMapping(box)); pos = new Vec3(6*SIZE,4*SIZE,6*SIZE); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,45,0)); pos = new Vec3(-6*SIZE,4*SIZE,6*SIZE); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,45,0)); pos = new Vec3(6*SIZE,4*SIZE,-6*SIZE); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,45,0)); pos = new Vec3(-6*SIZE,4*SIZE,-6*SIZE); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,45,0)); //floors for (i=1;i<4;i++) { x = 16-1*i; box = new Cube(x*SIZE,0.07*SIZE,16.05*SIZE); box.setTexture(white, white.getDefaultMapping(box)); pos = new Vec3(0,i*SIZE,0); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,0,0)); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,90,0)); pos = new Vec3(0,(i-0.2)*SIZE,0); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,0,0)); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,90,0)); pos = new Vec3(0,(8-i)*SIZE,0); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,0,0)); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,90,0)); pos = new Vec3(0,(8-i-0.2)*SIZE,0); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,0,0)); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,90,0)); //floors on corners x = i/2.0*Math.sqrt(2)+0.05; box = new Cube(x*SIZE,0.07*SIZE,x*SIZE); box.setTexture(white, white.getDefaultMapping(box)); x = 8 - i/2.0; pos = new Vec3(x*SIZE,i*SIZE,x*SIZE); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,45,0)); pos = new Vec3(-x*SIZE,i*SIZE,x*SIZE); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,45,0)); pos = new Vec3(x*SIZE,i*SIZE,-x*SIZE); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,45,0)); pos = new Vec3(-x*SIZE,i*SIZE,-x*SIZE); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,45,0)); pos = new Vec3(x*SIZE,(8-i)*SIZE,x*SIZE); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,45,0)); pos = new Vec3(-x*SIZE,(8-i)*SIZE,x*SIZE); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,45,0)); pos = new Vec3(x*SIZE,(8-i)*SIZE,-x*SIZE); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,45,0)); pos = new Vec3(-x*SIZE,(8-i)*SIZE,-x*SIZE); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,45,0)); } } void top(double yoffset) { int i; double r, x; offset = new Vec3(0,yoffset,0); mesh = triangle(16*SIZE,4*SIZE,2*SIZE,12*SIZE); mesh.setTexture(window,window.getDefaultMapping(mesh)); pos = new Vec3(0,0,7*SIZE); script.addObject(mesh, new CoordinateSystem(pos.plus(offset), 0,180,0)); pos = new Vec3(0,0,-7*SIZE); script.addObject(mesh, new CoordinateSystem(pos.plus(offset), 0,0,0)); box = new Cube(16*SIZE,4*SIZE,12*SIZE); box.setTexture(window, window.getDefaultMapping(box)); pos = new Vec3(0,2*SIZE,0); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,0,0)); r = 4.675; /*box = new Cube(16.4*SIZE,0.4*SIZE,16.4*SIZE); box.setTexture(white, white.getDefaultMapping(box)); pos = new Vec3(0,8*SIZE,0); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,0,0));*/ for(i=-2;i<2;i++) { box = new Cube(r*SIZE,0.4*SIZE,16.4*SIZE); box.setTexture(white, white.getDefaultMapping(box)); pos = new Vec3(4*i*SIZE+3*SIZE,2*SIZE,0); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,0,63.4)); pos = new Vec3(4*i*SIZE+1*SIZE,2*SIZE,0); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,0,-63.4)); pos = new Vec3(0,2*SIZE,4*i*SIZE+3*SIZE); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,90,63.4)); pos = new Vec3(0,2*SIZE,4*i*SIZE+1*SIZE); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,90,-63.4)); } box = new Cube(12.2*SIZE,0.4*SIZE,16.4*SIZE); box.setTexture(white, white.getDefaultMapping(box)); pos = new Vec3(0,4*SIZE,0); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,0,0)); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,90,0)); //bar on corner x = 2*Math.sqrt(2)+0.25; box = new Cube(x*SIZE,0.3*SIZE,x*SIZE); box.setTexture(white, white.getDefaultMapping(box)); pos = new Vec3(6*SIZE,4*SIZE,6*SIZE); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,45,0)); pos = new Vec3(-6*SIZE,4*SIZE,6*SIZE); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,45,0)); pos = new Vec3(6*SIZE,4*SIZE,-6*SIZE); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,45,0)); pos = new Vec3(-6*SIZE,4*SIZE,-6*SIZE); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,45,0)); //floors for (i=1;i<4;i++) { x = 16-1*i; box = new Cube(x*SIZE,0.07*SIZE,16.05*SIZE); box.setTexture(white, white.getDefaultMapping(box)); pos = new Vec3(0,i*SIZE,0); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,0,0)); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,90,0)); pos = new Vec3(0,(i-0.2)*SIZE,0); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,0,0)); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,90,0)); //floors on corners x = i/2.0*Math.sqrt(2)+0.05; box = new Cube(x*SIZE,0.07*SIZE,x*SIZE); box.setTexture(white, white.getDefaultMapping(box)); x = 8 - i/2.0; pos = new Vec3(x*SIZE,i*SIZE,x*SIZE); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,45,0)); pos = new Vec3(-x*SIZE,i*SIZE,x*SIZE); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,45,0)); pos = new Vec3(x*SIZE,i*SIZE,-x*SIZE); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,45,0)); pos = new Vec3(-x*SIZE,i*SIZE,-x*SIZE); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,45,0)); } } for (i=0;i