/*A building with promonent corners.*/ FLOORS = 75; SIZE = 1.0; SQRT2 = Math.sqrt(2.0); //a function to make the roof void mesh(double x, double y, double z, double cut, Vec3 p, Texture tex) { x2 = x - cut; z2 = z - cut; vertices = new Vec3[8]; // 8 vertices + 6 faces vertices[0] = new Vec3(-x/2.0, -y/2.0, -z/2.0); vertices[1] = new Vec3(x/2.0, -y/2.0, -z/2.0); vertices[2] = new Vec3(x2/2.0, y/2.0, -z2/2.0); vertices[3] = new Vec3(-x2/2.0, y/2.0, -z2/2.0); vertices[4] = new Vec3(-x/2.0, -y/2.0, z/2.0); vertices[5] = new Vec3(x/2.0, -y/2.0, z/2.0); vertices[6] = new Vec3(x2/2.0, y/2.0, z2/2.0); vertices[7] = new Vec3(-x2/2.0, y/2.0, z2/2.0); //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); mesh.setTexture(tex, tex.getDefaultMapping(mesh)); //p = new Vec3(0.0, 0.0, 0.0); script.addObject(mesh, new CoordinateSystem(p, 0, 0, 0)); } //textures win = new UniformTexture(); win.diffuseColor.setRGB(0.3, 0.3, 0.3); win.specularity = 0.3f; win.shininess = 1.0f; light = new UniformTexture(); light.diffuseColor.setRGB(0.7, 0.7, 0.6); dark = new UniformTexture(); dark.diffuseColor.setRGB(0.2, 0.2, 0.2); //windows box = new Cube(SIZE*20, SIZE*FLOORS, SIZE*20); box.setTexture(win, win.getDefaultMapping(box)); p = new Vec3(0.0, SIZE*FLOORS/2.0, 0.0); script.addObject(box, new CoordinateSystem(p, 0, 0, 0)); //corners box = new Cube(SIZE*2.5, SIZE*(FLOORS+6), SIZE*2.5); box.setTexture(light, light.getDefaultMapping(box)); y = SIZE*FLOORS/2.0+SIZE*3; p = new Vec3(SIZE*9.25, y, SIZE*9.25); script.addObject(box, new CoordinateSystem(p, 0, 0, 0)); p = new Vec3(-SIZE*9.25, y, SIZE*9.25); script.addObject(box, new CoordinateSystem(p, 0, 0, 0)); p = new Vec3(SIZE*9.25, y, -SIZE*9.25); script.addObject(box, new CoordinateSystem(p, 0, 0, 0)); p = new Vec3(-SIZE*9.25, y, -SIZE*9.25); script.addObject(box, new CoordinateSystem(p, 0, 0, 0)); //vertical bars box = new Cube(SIZE*0.3*SQRT2, SIZE*(FLOORS+2), SIZE*0.3*SQRT2); box.setTexture(light, light.getDefaultMapping(box)); for (i=-3; i<=3; i++) { x = i*SIZE*2; z = 10*SIZE; p = new Vec3(x, SIZE*FLOORS/2.0+SIZE, z); script.addObject(box, new CoordinateSystem(p, 0, 45, 0)); p = new Vec3(x, SIZE*FLOORS/2.0+SIZE, -z); script.addObject(box, new CoordinateSystem(p, 0, 45, 0)); p = new Vec3(z, SIZE*FLOORS/2.0+SIZE, x); script.addObject(box, new CoordinateSystem(p, 0, 45, 0)); p = new Vec3(-z, SIZE*FLOORS/2.0+SIZE, -x); script.addObject(box, new CoordinateSystem(p, 0, 45, 0)); } //horizontal bars box = new Cube(SIZE*20.5, SIZE*0.2, SIZE*20.5); box.setTexture(light, light.getDefaultMapping(box)); for (i=0; i