//Three towers on a common base. SIZE = 1.0; FLOORS = 67; BASE = 5;//number of floors for the base //textures window = new UniformTexture(); window.diffuseColor.setRGB(0.6,0.6,0.6); window.specularity = 0.5f; window.shininess = 1.0f; grn = new UniformTexture(); grn.diffuseColor.setRGB(0.1,0.7,0.1); white = new UniformTexture(); white.diffuseColor.setRGB(0.7,0.7,0.7); void tower(double xpos, double zpos, int height) { //makes a tower at the specified location var c, box; int i; double th,x,r; Vec3 pos, offset; offset = new Vec3(xpos,0,zpos); c = new Cylinder(height*SIZE,5*SIZE,5*SIZE,1.0f); c.setTexture(window, window.getDefaultMapping(c)); pos = new Vec3(0,height*SIZE/2,0); script.addObject(c, new CoordinateSystem(pos.plus(offset), 0,0,0)); c = new Cylinder(0.4*SIZE,5.3*SIZE,5.3*SIZE,0.94f); c.setTexture(grn, grn.getDefaultMapping(c)); for (i=BASE;i<=height;i++) { pos = new Vec3(0,i*SIZE,0); script.addObject(c, new CoordinateSystem(pos.plus(offset), 0,0,180)); } th = 180.0/13; box = new Cube(0.25*SIZE,height*SIZE,10.1*SIZE); box.setTexture(white, white.getDefaultMapping(box)); pos = new Vec3(0,height*SIZE/2,0); for (i=0;i<13;i++) { script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,i*th,0)); } //top of tower for (i=0;i<4;i++) { x = 5-1.25*i; r = (x-0.75)/x; if (r<=0.5) r=0.5; c = new Cylinder(SIZE*1.5,x,x,(float)r); if (i%2==0) c.setTexture(white, white.getDefaultMapping(c)); else c.setTexture(grn, grn.getDefaultMapping(c)); pos = new Vec3(0,(height+0.75)*SIZE+1.5*i*SIZE,0); script.addObject(c, new CoordinateSystem(pos.plus(offset), 0,0,180)); } c = new Cylinder(9*SIZE,0.2*SIZE,0.2*SIZE,0.8); c.setTexture(white, white.getDefaultMapping(c)); pos = new Vec3(0,(height+10.5)*SIZE,0); script.addObject(c, new CoordinateSystem(pos.plus(offset), 0,0,0)); } //put it all together tower(-11*SIZE,3*SIZE,FLOORS); tower(2*SIZE,-7*SIZE,FLOORS*4/5); tower(12*SIZE,7*SIZE,FLOORS*3/5); box = new Cube(35*SIZE,BASE*SIZE,30*SIZE); box.setTexture(window, window.getDefaultMapping(box)); pos = new Vec3(0,BASE*SIZE/2,0); script.addObject(box, new CoordinateSystem(pos, 0,0,0)); box = new Cube(35.3*SIZE,0.3*SIZE,30.3*SIZE); box.setTexture(white, white.getDefaultMapping(box)); for (i=1;i<=BASE;i++) { pos = new Vec3(0,i*SIZE,0); script.addObject(box, new CoordinateSystem(pos, 0,0,0)); } box = new Cube(35.3*SIZE,BASE*SIZE,0.1*SIZE); box.setTexture(white, white.getDefaultMapping(box)); for (i=-29;i<30;i++) { pos = new Vec3(0,BASE*SIZE/2,0.5*i*SIZE); script.addObject(box, new CoordinateSystem(pos, 0,0,0)); } box = new Cube(0.1*SIZE,BASE*SIZE,30.3*SIZE); box.setTexture(white, white.getDefaultMapping(box)); for (i=-34;i<35;i++) { pos = new Vec3(0.5*i*SIZE,BASE*SIZE/2,0); script.addObject(box, new CoordinateSystem(pos, 0,0,0)); }