//A building made up of two lens shaped sections. SIZE = 1.0; FLOORS = 84;//multiple of 6 //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.4,0.4,0.4); 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)); } void tower(double xpos, double zpos, int flrs) { offset = new Vec3(xpos, 0, zpos); main = unit(flrs*SIZE,20*SIZE); main.setTexture(window, window.getDefaultMapping(main)); pos = new Vec3(0,flrs*SIZE/2,0); script.addObject(main, new CoordinateSystem(pos.plus(offset), 0,0,0)); top = unit(6*SIZE,20*SIZE); top.setTexture(gray, gray.getDefaultMapping(top)); pos = new Vec3(0,flrs*SIZE+3*SIZE,0); script.addObject(top, new CoordinateSystem(pos.plus(offset), 0,0,0)); flat = unit(0.2*SIZE,20.2*SIZE); flat.setTexture(blue, blue.getDefaultMapping(flat)); for (i=0;i<=flrs;i++) { pos = new Vec3(0,i*SIZE,0); script.addObject(flat, new CoordinateSystem(pos.plus(offset), 0,0,0)); } //verticals for (i=-16;i<17;i++) { box = new Cube(0.3*SIZE,(flrs+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),(flrs+2)*SIZE/2,z); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,th*180/Math.PI,0)); pos = new Vec3(SIZE*20*Math.cos(th),(flrs+2)*SIZE/2,-z); script.addObject(box, new CoordinateSystem(pos.plus(offset), 0,-th*180/Math.PI,0)); } } tower(0,0,FLOORS); tower(-18/SIZE,-10*SIZE,FLOORS*5/6); cy = new Cylinder(30*SIZE,0.4*SIZE,0.4*SIZE,0.8f); cy.setTexture(gray, gray.getDefaultMapping(cy)); pos = new Vec3(-13*SIZE,(FLOORS+21)*SIZE,0); script.addObject(cy, new CoordinateSystem(pos, 0,0,0));