/*An Angkor Wat style tower at low resolution, available in single color or two colors.*/ SIZE = 1.0; TWOCOLOR = true; //textures stone = new UniformTexture(); stone.diffuseColor.setRGB(0.6,0.6,0.6); if (TWOCOLOR) { red = new UniformTexture(); red.diffuseColor.setRGB(0.8,0.5,0.5); } else { red = stone; } //a "circular" layer of the tower void layer(double scale, double height, Vec3 pos) { c = new Cube(5*scale,height,5*scale); c.setTexture(stone, stone.getDefaultMapping(c)); script.addObject(c, new CoordinateSystem(pos, 0, 0, 0)); c = new Cube(3.8*scale,height,5.8*scale); c.setTexture(stone, stone.getDefaultMapping(c)); script.addObject(c, new CoordinateSystem(pos, 0, 0, 0)); c = new Cube(5.8*scale,height,3.8*scale); c.setTexture(stone, stone.getDefaultMapping(c)); script.addObject(c, new CoordinateSystem(pos, 0, 0, 0)); c = new Cube(3*scale,height,6.75*scale); c.setTexture(stone, stone.getDefaultMapping(c)); script.addObject(c, new CoordinateSystem(pos, 0, 0, 0)); c = new Cube(6.75*scale,height,3*scale); c.setTexture(stone, stone.getDefaultMapping(c)); script.addObject(c, new CoordinateSystem(pos, 0, 0, 0)); c = new Cube(2*scale,height,7*scale); c.setTexture(stone, stone.getDefaultMapping(c)); script.addObject(c, new CoordinateSystem(pos, 0, 0, 0)); c = new Cube(7*scale,height,2*scale); c.setTexture(stone, stone.getDefaultMapping(c)); script.addObject(c, new CoordinateSystem(pos, 0, 0, 0)); } //decorations on the tower void decorate(double scale, Vec3 pos) { ball = new Sphere(0.2,0.6,0.2); ball.setTexture(red, red.getDefaultMapping(ball)); //square Vec3 aa = new Vec3(2.5*scale, 0, 2.5*scale); script.addObject(ball, new CoordinateSystem(aa.plus(pos), 0, 0, 0)); aa = new Vec3(-2.5*scale, 0, 2.5*scale); script.addObject(ball, new CoordinateSystem(aa.plus(pos), 0, 0, 0)); aa = new Vec3(-2.5*scale, 0, -2.5*scale); script.addObject(ball, new CoordinateSystem(aa.plus(pos), 0, 0, 0)); aa = new Vec3(2.5*scale, 0, -2.5*scale); script.addObject(ball, new CoordinateSystem(aa.plus(pos), 0, 0, 0)); //sides aa = new Vec3(1*scale, 0, 3.5*scale); script.addObject(ball, new CoordinateSystem(aa.plus(pos), 0, 0, 0)); aa = new Vec3(-1*scale, 0, 3.5*scale); script.addObject(ball, new CoordinateSystem(aa.plus(pos), 0, 0, 0)); aa = new Vec3(1*scale, 0, -3.5*scale); script.addObject(ball, new CoordinateSystem(aa.plus(pos), 0, 0, 0)); aa = new Vec3(-1*scale, 0, -3.5*scale); script.addObject(ball, new CoordinateSystem(aa.plus(pos), 0, 0, 0)); aa = new Vec3(3.5*scale, 0, 1*scale); script.addObject(ball, new CoordinateSystem(aa.plus(pos), 0, 0, 0)); aa = new Vec3(-3.5*scale, 0, 1*scale); script.addObject(ball, new CoordinateSystem(aa.plus(pos), 0, 0, 0)); aa = new Vec3(3.5*scale, 0, -1*scale); script.addObject(ball, new CoordinateSystem(aa.plus(pos), 0, 0, 0)); aa = new Vec3(-3.5*scale, 0, -1*scale); script.addObject(ball, new CoordinateSystem(aa.plus(pos), 0, 0, 0)); //more sides box = new Cube(0.2,1.5,1.5); box.setTexture(stone, stone.getDefaultMapping(box)); aa = new Vec3(3.5*scale-0.1, 0, 0); script.addObject(box, new CoordinateSystem(aa.plus(pos), 45, 0, 0)); aa = new Vec3(-3.5*scale+0.1, 0, 0); script.addObject(box, new CoordinateSystem(aa.plus(pos), 45, 0, 0)); aa = new Vec3(0, 0, 3.5*scale-0.1); script.addObject(box, new CoordinateSystem(aa.plus(pos), 45, 90, 0)); aa = new Vec3(0, 0, -3.5*scale+0.1); script.addObject(box, new CoordinateSystem(aa.plus(pos), 45, 90, 0)); } yy = 1*SIZE; double[] data = {2, 1.9, 1.8, 1.6, 1.2}; for (int i=0;i<5;i++) { pos = new Vec3(0,yy,0); ss = data[i]*SIZE; layer(ss,2*SIZE,pos); yy = yy + 1.1*SIZE; for (int j=0;j<4;j++) { pos = new Vec3(0,yy,0); layer(ss+0.05*SIZE,0.2,pos); yy = yy + 0.2*SIZE; pos = new Vec3(0,yy,0); layer(ss,0.2,pos); yy = yy + 0.2; } yy = yy + 0.4*SIZE; pos = new Vec3(0,yy,0); layer(ss+0.2*SIZE,1*SIZE,pos); decorate(ss+0.2*SIZE,pos.plus(new Vec3(0,0.5*SIZE,0))); yy = yy + 1.5*SIZE; } pos = new Vec3(0,yy,0); layer(0.7*ss,2*SIZE,pos); yy = yy+1*SIZE; layer(ss*0.8,.5*SIZE,new Vec3(0,yy,0)); cc = new Cylinder(2.5*SIZE,2.5*SIZE,2.5*SIZE,0.45); cc.setTexture(stone, stone.getDefaultMapping(cc)); script.addObject(cc, new CoordinateSystem(new Vec3(0,yy+1.5*SIZE,0), 0, 0, 0)); layer(ss*.55, 0.5*SIZE, new Vec3(0,yy+1.25*SIZE,0)); layer(ss*0.4, 0.5*SIZE, new Vec3(0,yy+2.5*SIZE,0)); cc = new Sphere(1.0*SIZE,1.5*SIZE,1.0*SIZE); cc.setTexture(stone, stone.getDefaultMapping(cc)); script.addObject(cc, new CoordinateSystem(new Vec3(0,yy+3.3*SIZE,0), 0, 0, 0)); yy = yy+3.3*SIZE + 1*SIZE; for (int k=0;k<8;k++) { cc = new Sphere(0.25*SIZE,0.25*SIZE,0.25*SIZE); cc.setTexture(red, red.getDefaultMapping(cc)); theta = k*2*Math.PI/8.0; x = 0.7*Math.sin(theta)*SIZE; y = 0.7*Math.cos(theta)*SIZE; script.addObject(cc, new CoordinateSystem(new Vec3(x,yy,y), 0, 0, 0)); cc = new Sphere(0.3*SIZE,0.5*SIZE,0.3*SIZE); cc.setTexture(red, red.getDefaultMapping(cc)); script.addObject(cc, new CoordinateSystem(new Vec3(1.4*x,yy-1.4*SIZE,1.4*y), 0, 0, 0)); } cc = new Sphere(0.5*SIZE,0.3*SIZE,0.5*SIZE); cc.setTexture(red, red.getDefaultMapping(cc)); script.addObject(cc, new CoordinateSystem(new Vec3(0,yy+0.6*SIZE,0), 0, 0, 0)); cc = new Sphere(0.2*SIZE,0.4*SIZE,0.2*SIZE); cc.setTexture(red, red.getDefaultMapping(cc)); script.addObject(cc, new CoordinateSystem(new Vec3(0,yy+1*SIZE,0), 0, 0, 0)); cc = new Sphere(0.3*SIZE,0.3*SIZE,0.3*SIZE); cc.setTexture(red, red.getDefaultMapping(cc)); script.addObject(cc, new CoordinateSystem(new Vec3(0,yy+1.3*SIZE,0), 0, 0, 0));