//A building with a double convex footprint. SIZE = 1.0; FLOORS = 75; //textures window = new UniformTexture(); window.diffuseColor.setRGB(0.2,0.2,0.2); window.specularity = 0.5f; window.shininess = 1.0f; blue = new UniformTexture(); blue.diffuseColor.setRGB(0.2,0.2,0.5); gray = new UniformTexture(); gray.diffuseColor.setRGB(0.4,0.4,0.4); Object3D unit(double height, double r) { var bb, cyl; Vec3 pos; bb = new Cylinder(height+.1,r,r,1.0f); cyl = new Cylinder(height,r,r,1.0f); pos = new Vec3(0,0,10*SIZE); one = new ObjectInfo(bb, new CoordinateSystem(pos, 0,0,0), "one"); pos = new Vec3(0,0,-10*SIZE); two = new ObjectInfo(cyl, new CoordinateSystem(pos, 0,0,0), "two"); lens = new CSGObject(one, two, 1); return (lens.convertToTriangleMesh(0.1)); } main = unit(FLOORS*SIZE,20*SIZE); main.setTexture(window, window.getDefaultMapping(main)); pos = new Vec3(0,FLOORS*SIZE/2,0); script.addObject(main, new CoordinateSystem(pos, 0,0,0)); top = unit(6*SIZE,20*SIZE); top.setTexture(gray, gray.getDefaultMapping(top)); pos = new Vec3(0,FLOORS*SIZE+3*SIZE,0); script.addObject(top, new CoordinateSystem(pos, 0,0,0)); flat = unit(0.2*SIZE,20.2*SIZE); flat.setTexture(blue, blue.getDefaultMapping(flat)); for (i=0;i<=FLOORS;i++) { pos = new Vec3(0,i*SIZE,0); script.addObject(flat, new CoordinateSystem(pos, 0,0,0)); } //verticals /*for (i=-17;i<18;i++) { kk = Math.sqrt(20*20-i*i)-10; box = new Cube(0.2*SIZE,(FLOORS+2)*SIZE,2*kk*SIZE+0.2*SIZE); box.setTexture(blue, blue.getDefaultMapping(box)); pos = new Vec3(i*SIZE,(FLOORS+2)*SIZE/2,0); script.addObject(box, new CoordinateSystem(pos, 0,0,0)); }*/ for (i=-16;i<17;i++) { box = new Cube(0.3*SIZE,(FLOORS+2)*SIZE,0.3*SIZE); box.setTexture(gray, gray.getDefaultMapping(box)); th = Math.PI/2 + Math.PI*i/50; z = SIZE*20*Math.sin(th)-10*SIZE; pos = new Vec3(SIZE*20*Math.cos(th),(FLOORS+2)*SIZE/2,z); script.addObject(box, new CoordinateSystem(pos, 0,th*180/Math.PI,0)); pos = new Vec3(SIZE*20*Math.cos(th),(FLOORS+2)*SIZE/2,-z); script.addObject(box, new CoordinateSystem(pos, 0,-th*180/Math.PI,0)); } /* box = new Cube(0.5*SIZE,(FLOORS+6)*SIZE,0.5*SIZE); box.setTexture(gray, gray.getDefaultMapping(box)); pos = new Vec3(-17.1*SIZE,(FLOORS+6)*SIZE/2,0); script.addObject(box, new CoordinateSystem(pos, 0,0,0)); pos = new Vec3(17.1*SIZE,(FLOORS+6)*SIZE/2,0); script.addObject(box, new CoordinateSystem(pos, 0,0,0));*/