//A building with a twist, a little like Turning Torso in Sweden. SIZE = 1.0; FLOORS = 54; //should be a multiple of 6 //textures white = new UniformTexture(); white.diffuseColor.setRGB(0.8,0.8,0.8); window = new UniformTexture(); window.diffuseColor.setRGB(0.5,0.5,0.5); window.specularity = 0.6f; window.shininess = 1.0f; steel = new UniformTexture(); steel.diffuseColor.setRGB(0.7,0.35,0.35); void unit(double yoffset, int angle) //a unit of 6 floors, twisted anlge degrees { int i; double x,th; var box, pos; yoffset = yoffset+1.25*SIZE; box = new Cube(7.9*SIZE,5.9*SIZE,7.9*SIZE); box.setTexture(window, window.getDefaultMapping(box)); pos = new Vec3(0,yoffset+3*SIZE,0); script.addObject(box, new CoordinateSystem(pos, 0,angle,0)); for (i=0;i<7;i++) { box = new Cube(8*SIZE,0.5*SIZE,8*SIZE); box.setTexture(white, white.getDefaultMapping(box)); pos = new Vec3(0,yoffset+i*SIZE,0); script.addObject(box, new CoordinateSystem(pos, 0,angle,0)); } for (i=-3;i<4;i++) { box = new Cube(0.5*SIZE,6*SIZE,8*SIZE); box.setTexture(white, white.getDefaultMapping(box)); x = (i+0)*SIZE; th = Math.PI*angle/180; pos = new Vec3(x*Math.cos(th),yoffset+3*SIZE,x*Math.sin(th)); script.addObject(box, new CoordinateSystem(pos, 0,angle,0)); } for (i=-3;i<4;i++) { box = new Cube(8*SIZE,6*SIZE,0.5*SIZE); box.setTexture(white, white.getDefaultMapping(box)); x = (i+0)*SIZE; th = Math.PI*(angle+90)/180; pos = new Vec3(x*Math.cos(th),yoffset+3*SIZE,x*Math.sin(th)); script.addObject(box, new CoordinateSystem(pos, 0,angle,0)); } //exterior framework fm = new Vec3[3]; th = Math.PI*(angle+45)/180; x = 5.6; fm[0] = new Vec3(x*SIZE*Math.cos(th), yoffset+6*SIZE, x*SIZE*Math.sin(th)); th = Math.PI*(angle-45)/180; fm[1] = new Vec3(6.5*SIZE*Math.cos(th), yoffset, 6.5*SIZE*Math.sin(th));; th = Math.PI*(angle-135)/180; fm[2] = new Vec3(x*SIZE*Math.cos(th), yoffset+6*SIZE, x*SIZE*Math.sin(th));; work = new Tube(fm,0.3*SIZE,0,0); work.setTexture(steel, steel.getDefaultMapping(work)); script.addObject(work, new CoordinateSystem(new Vec3(), 0,0,0)); fm = new Vec3[3]; th = Math.PI*(angle+45)/180; x = 5.6; fm[0] = new Vec3(x*SIZE*Math.cos(th), yoffset+0*SIZE, x*SIZE*Math.sin(th)); th = Math.PI*(angle-45)/180; fm[1] = new Vec3(6.5*SIZE*Math.cos(th), yoffset+0*SIZE, 6.5*SIZE*Math.sin(th));; th = Math.PI*(angle-135)/180; fm[2] = new Vec3(x*SIZE*Math.cos(th), yoffset+0*SIZE, x*SIZE*Math.sin(th));; work = new Tube(fm,0.3*SIZE,0,0); work.setTexture(steel, steel.getDefaultMapping(work)); script.addObject(work, new CoordinateSystem(new Vec3(), 0,0,0)); } //put it all together box = new Cube(0.4*SIZE,SIZE,0.4*SIZE); box.setTexture(white, white.getDefaultMapping(box)); pos = new Vec3(3.75*SIZE,0.5*SIZE,3.75*SIZE); script.addObject(box, new CoordinateSystem(pos, 0,0,0)); pos = new Vec3(3.75*SIZE,0.5*SIZE,-3.75*SIZE); script.addObject(box, new CoordinateSystem(pos, 0,0,0)); pos = new Vec3(-3.75*SIZE,0.5*SIZE,3.75*SIZE); script.addObject(box, new CoordinateSystem(pos, 0,0,0)); pos = new Vec3(-3.75*SIZE,0.5*SIZE,-3.75*SIZE); script.addObject(box, new CoordinateSystem(pos, 0,0,0)); data = new Vec3[FLOORS/6+1]; double r, th; for (int i=0;i