/*A brightly colored building with a triangular lattice framework. Optional antenna structures on top.*/ SIZE = 1.0; FLOORS = 34;//even number TOP = true; //true for antenna, false for no antenna window = new UniformTexture(); window.diffuseColor.setRGB(0.5,0.5,0.6); window.specularity = 0.5f; window.shininess = 1.0f; red = new UniformTexture(); red.diffuseColor.setRGB(0.8,0.08,0.08); red.shininess = 0.8f; white = new UniformTexture(); white.diffuseColor.setRGB(0.7,0.7,0.7); //adjust the formula SIZE = SIZE/4.0; 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(32*SIZE,4*SIZE,2*SIZE,28*SIZE); mesh.setTexture(window,window.getDefaultMapping(mesh)); pos = new Vec3(0,0,15*SIZE); script.addObject(mesh, new CoordinateSystem(pos.plus(offset), 0,180,0)); pos = new Vec3(0,8*SIZE,15*SIZE); script.addObject(mesh, new CoordinateSystem(pos.plus(offset), 0,180,180)); pos = new Vec3(0,0,-15*SIZE); script.addObject(mesh, new CoordinateSystem(pos.plus(offset), 0,0,0)); pos = new Vec3(0,8*SIZE,-15*SIZE); script.addObject(mesh, new CoordinateSystem(pos.plus(offset), 0,0,180)); box = new Cube(32*SIZE,8*SIZE,28*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(32.4*SIZE,0.4*SIZE,32.4*SIZE); box.setTexture(red, red.getDefaultMapping(box)); pos = new Vec3(0,8*SIZE,0); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,0,0)); for(i=-4;i<4;i++) { box = new Cube(r*SIZE,0.4*SIZE,32.4*SIZE); box.setTexture(red, red.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(28.2*SIZE,0.4*SIZE,32.4*SIZE); box.setTexture(red, red.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=-4;i<4;i++) { box = new Cube(r*SIZE,0.4*SIZE,32.4*SIZE); box.setTexture(red, red.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(red, red.getDefaultMapping(box)); pos = new Vec3(14*SIZE,4*SIZE,14*SIZE); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,45,0)); pos = new Vec3(-14*SIZE,4*SIZE,14*SIZE); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,45,0)); pos = new Vec3(14*SIZE,4*SIZE,-14*SIZE); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,45,0)); pos = new Vec3(-14*SIZE,4*SIZE,-14*SIZE); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,45,0)); } for (i=0;i