/*A typical cathederal. Spire and tower roofs optional.*/ SIZE = 1.0; SPIRE = true;//has a spire over the crossing ROOF = true;//has pointed roofs over the front towers SQRT2 = Math.sqrt(2); //textures stone = new UniformTexture(); stone.diffuseColor.setRGB(0.6,0.5,0.4); lead = new UniformTexture(); lead.diffuseColor.setHSV(45,0.2f,0.4f); TriangleMesh spike(double xsize, double ysize) { //a rectangular pyramid (no bottom) double a = xsize/2; Vec3[] data = {new Vec3(a,0,a), new Vec3(-a,0,a), new Vec3(-a,0,-a), new Vec3(a,0,-a), new Vec3(0,ysize,0)}; int[][] faces = {{0,4,1}, {1,4,2}, {2,4,3}, {3,4,0} }; TriangleMesh out = new TriangleMesh(data, faces); out.smoothingMethod = 0; return(out); } void buttress(Vec3 p, double angle, boolean both) { //a flying buttress Mat4 rotate = Mat4.yrotation(angle*Math.PI/180); Mat4 move = Mat4.translation(p.x,p.y,p.z); Object3D aa = new Cube(SIZE,4*SIZE,10*SIZE); Object3D bb = new Cylinder(2*SIZE,10*SIZE,10*SIZE,1.0f); Vec3 pos = new Vec3(0,2*SIZE,0); one = new ObjectInfo(aa, new CoordinateSystem(pos, 0,0,0), "one"); pos = new Vec3(0,-7*SIZE,0); two = new ObjectInfo(bb, new CoordinateSystem(pos, 0,0,90), "two"); lens = new CSGObject(one, two, 2); lens = lens.convertToTriangleMesh(0.05); lens.setSmoothingMethod(0); lens.setTexture(stone, stone.getDefaultMapping(lens)); if (both){ pp = new Vec3(0,10*SIZE,-6*SIZE); spock = new CoordinateSystem(pp, 16,0,0); spock.transformCoordinates(rotate); spock.transformCoordinates(move); script.addObject(lens, spock); } pp = new Vec3(0,10*SIZE,6*SIZE); spock = new CoordinateSystem(pp, -16,0,0); spock.transformCoordinates(rotate); spock.transformCoordinates(move); script.addObject(lens, spock); Object3D box = new Cube(1.1*SIZE,12*SIZE,2*SIZE); box.setTexture(stone, stone.getDefaultMapping(box)); pp = new Vec3(0,6*SIZE,12*SIZE); spock = new CoordinateSystem(pp, 0,0,0); spock.transformCoordinates(rotate); spock.transformCoordinates(move); script.addObject(box, spock); if (both) {pp = new Vec3(0,6*SIZE,-12*SIZE); spock = new CoordinateSystem(pp, 0,0,0); spock.transformCoordinates(rotate); spock.transformCoordinates(move); script.addObject(box, spock); } cone = new Cylinder(3*SIZE,0.5*SIZE,0.5*SIZE,0.0f); cone.setTexture(stone, stone.getDefaultMapping(cone)); pp = new Vec3(0,13.5*SIZE,12.45*SIZE); spock = new CoordinateSystem(pp, 0,0,0); spock.transformCoordinates(rotate); spock.transformCoordinates(move); script.addObject(cone, spock); if (both) {pp = new Vec3(0,13.5*SIZE,-12.45*SIZE); spock = new CoordinateSystem(pp, 0,0,0); spock.transformCoordinates(rotate); spock.transformCoordinates(move); script.addObject(cone, spock); } box = new Cube(1.1*SIZE,16.2*SIZE,1.1*SIZE); box.setTexture(stone, stone.getDefaultMapping(box)); pp = new Vec3(0,8.1*SIZE,8*SIZE); spock = new CoordinateSystem(pp, 0,45,0); spock.transformCoordinates(rotate); spock.transformCoordinates(move); script.addObject(box, spock); pp = new Vec3(0,17.7*SIZE,8*SIZE); spock = new CoordinateSystem(pp, 0,45,0); spock.transformCoordinates(rotate); spock.transformCoordinates(move); script.addObject(cone, spock); if (both) {pp= new Vec3(0,8.1*SIZE,-8*SIZE); spock = new CoordinateSystem(pp, 0,45,0); spock.transformCoordinates(rotate); spock.transformCoordinates(move); script.addObject(box, spock); pp = new Vec3(0,17.7*SIZE,-8*SIZE); spock = new CoordinateSystem(pp, 0,45,0); spock.transformCoordinates(rotate); spock.transformCoordinates(move); script.addObject(cone, spock); } } //long axis box = new Cube(50*SIZE,16*SIZE,16*SIZE); box.setTexture(stone, stone.getDefaultMapping(box)); pos = new Vec3(-5*SIZE,8*SIZE,0); script.addObject(box, new CoordinateSystem(pos, 0,0,0)); box = new Cube(50*SIZE,5*SIZE,24*SIZE); box.setTexture(stone, stone.getDefaultMapping(box)); pos = new Vec3(-5*SIZE,2.5*SIZE,0); script.addObject(box, new CoordinateSystem(pos, 0,0,0)); box = new Cube(0.5*SIZE,8*SQRT2*SIZE,8*SQRT2*SIZE); box.setTexture(stone, stone.getDefaultMapping(box)); pos = new Vec3(-29.75*SIZE,16*SIZE,0); script.addObject(box, new CoordinateSystem(pos, 45,0,0)); box = new Cube(49.5*SIZE,7.8*SQRT2*SIZE,7.8*SQRT2*SIZE); box.setTexture(lead, lead.getDefaultMapping(box)); pos = new Vec3(-4.75*SIZE,16*SIZE,0); script.addObject(box, new CoordinateSystem(pos, 45,0,0)); box = new Cube(50*SIZE,3.8*SQRT2*SIZE,3.8*SQRT2*SIZE); box.setTexture(lead, lead.getDefaultMapping(box)); pos = new Vec3(-5*SIZE,5*SIZE,8*SIZE); script.addObject(box, new CoordinateSystem(pos, 45,0,0)); pos = new Vec3(-5*SIZE,5*SIZE,-8*SIZE); script.addObject(box, new CoordinateSystem(pos, 45,0,0)); //buttresses for (i=-24;i<-8;i=i+4) { pos = new Vec3(i*SIZE,0,0); buttress(pos, 0, true); } for (i=12;i<24;i=i+4) { pos = new Vec3(i*SIZE,0,0); buttress(pos, 0, true); } for (i=1;i<=8;i++) { pos = new Vec3(20*SIZE,0,0); buttress(pos, 22.5*i, false); } pos = new Vec3(0,0,12*SIZE); buttress(pos, 90, true); pos = new Vec3(0,0,-12*SIZE); buttress(pos, 90, true); //short axis box = new Cube(16*SIZE,16*SIZE,30*SIZE); box.setTexture(stone, stone.getDefaultMapping(box)); pos = new Vec3(0,8*SIZE,0); script.addObject(box, new CoordinateSystem(pos, 0,0,0)); box = new Cube(8*SQRT2*SIZE,8*SQRT2*SIZE,0.5*SIZE); box.setTexture(stone, stone.getDefaultMapping(box)); pos = new Vec3(0,16*SIZE,-14.75*SIZE); script.addObject(box, new CoordinateSystem(pos, 0,0,45)); pos = new Vec3(0,16*SIZE,14.75*SIZE); script.addObject(box, new CoordinateSystem(pos, 0,0,45)); box = new Cube(7.8*SQRT2*SIZE,7.8*SQRT2*SIZE,29.5*SIZE); box.setTexture(lead, lead.getDefaultMapping(box)); pos = new Vec3(0,16*SIZE,0); script.addObject(box, new CoordinateSystem(pos, 0,0,45)); //towers for (j=-1;j<=1;j=j+2) { box = new Cube(8*SIZE,25*SIZE,8*SIZE); box.setTexture(stone, stone.getDefaultMapping(box)); pos = new Vec3(-30*SIZE,12.5*SIZE,j*8*SIZE); script.addObject(box, new CoordinateSystem(pos, 0,0,0)); if (ROOF) { sp = spike(7.7*SIZE,22*SIZE); sp.setTexture(lead, lead.getDefaultMapping(sp)); pos = new Vec3(-30*SIZE,25*SIZE,j*8*SIZE); script.addObject(sp, new CoordinateSystem(pos, 0,0,0)); } } //spire if (SPIRE) { box = new Cube(3.1*SIZE,4.4*SIZE,3.1*SIZE); box.setTexture(stone, stone.getDefaultMapping(box)); pos = new Vec3(0,23*SIZE,0); script.addObject(box, new CoordinateSystem(pos, 0,0,0)); sp = spike(3*SIZE,20*SIZE); sp.setTexture(lead, lead.getDefaultMapping(sp)); pos = new Vec3(0,25*SIZE,0); script.addObject(sp, new CoordinateSystem(pos, 0,0,0)); } //apse cc = new Cylinder(16*SIZE,8*SIZE,8*SIZE,1.0f); cc.setTexture(stone, stone.getDefaultMapping(cc)); pos = new Vec3(20*SIZE,8*SIZE,0); script.addObject(cc, new CoordinateSystem(pos, 0,0,0)); cc = new Cylinder(5*SIZE,12*SIZE,12*SIZE,1.0f); cc.setTexture(stone, stone.getDefaultMapping(cc)); pos = new Vec3(20*SIZE,2.5*SIZE,0); script.addObject(cc, new CoordinateSystem(pos, 0,0,0)); cc = new Cylinder(7.8*SIZE,7.8*SIZE,7.8*SIZE,0.0f); cc.setTexture(lead, lead.getDefaultMapping(cc)); pos = new Vec3(20*SIZE,19.9*SIZE,0); script.addObject(cc, new CoordinateSystem(pos, 0,0,0)); cc = new Cylinder(12*SIZE,11.8*SIZE,11.8*SIZE,0.0f); cc.setTexture(lead, lead.getDefaultMapping(cc)); pos = new Vec3(20*SIZE,11*SIZE,0); script.addObject(cc, new CoordinateSystem(pos, 0,0,0));