//
import render.*; public class MeltingPot extends RenderApplet { Geometry teapot, can; public void initialize() { setBgColor(.25,.25,1); setFL(15); setFOV(.8); Material baseColor = new Material(); baseColor.setColor(.5,.5,.5).setAmbient(.5,.5,.5); push(); translate(0,.4,0); rotateX(.2); transform(world); pop(); Geometry base = world.add().ball(30).superquadric(10,.2).setMaterial(baseColor); push(); rotateY(Math.PI/6); translate(.1,-5.2,-.16); scale(4,4,2.9); transform(base); pop(); Material red = new Material(); red.setColor(0,0,0, .8,0,0,10).setAmbient(.5,0,0); teapot = world.add(); push(); translate(0,-1,0); rotateX(-Math.PI/2); scale(.03,.03,.03); transform(teapot); pop(); for (int i = 0 ; i < teapot_data.length ; i++) { Geometry s = teapot.add(); int m = 8, n = i < 12 ? 16 : 8; s.patch(m,n, Geometry.Bezier, teapot_data[i]).setMaterial(red); } addLight( 1, 0, 0, .7,.8,.7); addLight(-1, 0, 0, .7,.8,.7); addLight( 0, 1, 0, .8,.8,.9); addLight( 0,-1, 0, .3,.3,.4); addLight( 0, 0, 1, .3,.3,.25); addLight( 0, 0,-1, .3,.3,.25); } double getSize(double data[]) { double min[] = {1000,1000,1000}, max[] = {-1000,-1000,-1000}; for (int n = 0 ; n < 16 ; n++) for (int k = 0 ; k < 3 ; k++) { min[k] = Math.min(min[k], data[3*n + k]); max[k] = Math.max(max[k], data[3*n + k]); } return Math.max(Math.max(max[0]-min[0], max[1]-min[1]), max[2]-min[2]); } double prevTime = 0, melt = 1; public void animate(double time) { if (prevTime == 0) prevTime = time; double dt = time - prevTime; prevTime = time; melt *= 1 - .1 * dt; double m = Math.pow(melt,.1); if (melt < .5) m = Math.pow(.5,.1); for (int i = 0 ; i < teapot.child.length ; i++) { teapot.child[i].noiseOrigin[0] += 2*dt; teapot.child[i].addImprovedNoise(.02,.1); teapot.child[i].computeMeshNormals(); teapot.child[i].addImprovedNoise(.04,.12); teapot.child[i].computeMeshNormals(); push(); translate(0,0, -10 * (1-melt)); scale(1/m,1/m,Math.pow(melt,.5)); transform(teapot.child[i]); pop(); } } double teapot_data[][] = { { // 0 -80.00, 0.00, 30.00, -80.00, -44.80, 30.00, -44.80, -80.00, 30.00, 0.00, -80.00, 30.00, -80.00, 0.00, 12.00, -80.00, -44.80, 12.00, -44.80, -80.00, 12.00, 0.00, -80.00, 12.00, -60.00, 0.00, 3.00, -60.00, -33.60, 3.00, -33.60, -60.00, 3.00, 0.00, -60.00, 3.00, -60.00, 0.00, 0.00, -60.00, -33.60, 0.00, -33.60, -60.00, 0.00, 0.00, -60.00, 0.00, },{ 0.00, -80.00, 30.00, 44.80, -80.00, 30.00, 80.00, -44.80, 30.00, 80.00, 0.00, 30.00, 0.00, -80.00, 12.00, 44.80, -80.00, 12.00, 80.00, -44.80, 12.00, 80.00, 0.00, 12.00, 0.00, -60.00, 3.00, 33.60, -60.00, 3.00, 60.00, -33.60, 3.00, 60.00, 0.00, 3.00, 0.00, -60.00, 0.00, 33.60, -60.00, 0.00, 60.00, -33.60, 0.00, 60.00, 0.00, 0.00, },{ -60.00, 0.00, 90.00, -60.00, -33.60, 90.00, -33.60, -60.00, 90.00, 0.00, -60.00, 90.00, -70.00, 0.00, 69.00, -70.00, -39.20, 69.00, -39.20, -70.00, 69.00, 0.00, -70.00, 69.00, -80.00, 0.00, 48.00, -80.00, -44.80, 48.00, -44.80, -80.00, 48.00, 0.00, -80.00, 48.00, -80.00, 0.00, 30.00, -80.00, -44.80, 30.00, -44.80, -80.00, 30.00, 0.00, -80.00, 30.00, },{ 0.00, -60.00, 90.00, 33.60, -60.00, 90.00, 60.00, -33.60, 90.00, 60.00, 0.00, 90.00, 0.00, -70.00, 69.00, 39.20, -70.00, 69.00, 70.00, -39.20, 69.00, 70.00, 0.00, 69.00, 0.00, -80.00, 48.00, 44.80, -80.00, 48.00, 80.00, -44.80, 48.00, 80.00, 0.00, 48.00, 0.00, -80.00, 30.00, 44.80, -80.00, 30.00, 80.00, -44.80, 30.00, 80.00, 0.00, 30.00, },{ -56.00, 0.00, 90.00, -56.00, -31.36, 90.00, -31.36, -56.00, 90.00, 0.00, -56.00, 90.00, -53.50, 0.00, 95.25, -53.50, -29.96, 95.25, -29.96, -53.50, 95.25, 0.00, -53.50, 95.25, -57.50, 0.00, 95.25, -57.50, -32.20, 95.25, -32.20, -57.50, 95.25, 0.00, -57.50, 95.25, -60.00, 0.00, 90.00, -60.00, -33.60, 90.00, -33.60, -60.00, 90.00, 0.00, -60.00, 90.00, },{ // 5 0.00, -56.00, 90.00, 31.36, -56.00, 90.00, 56.00, -31.36, 90.00, 56.00, 0.00, 90.00, 0.00, -53.50, 95.25, 29.96, -53.50, 95.25, 53.50, -29.96, 95.25, 53.50, 0.00, 95.25, 0.00, -57.50, 95.25, 32.20, -57.50, 95.25, 57.50, -32.20, 95.25, 57.50, 0.00, 95.25, 0.00, -60.00, 90.00, 33.60, -60.00, 90.00, 60.00, -33.60, 90.00, 60.00, 0.00, 90.00, },{ 80.00, 0.00, 30.00, 80.00, 44.80, 30.00, 44.80, 80.00, 30.00, 0.00, 80.00, 30.00, 80.00, 0.00, 12.00, 80.00, 44.80, 12.00, 44.80, 80.00, 12.00, 0.00, 80.00, 12.00, 60.00, 0.00, 3.00, 60.00, 33.60, 3.00, 33.60, 60.00, 3.00, 0.00, 60.00, 3.00, 60.00, 0.00, 0.00, 60.00, 33.60, 0.00, 33.60, 60.00, 0.00, 0.00, 60.00, 0.00, },{ 0.00, 80.00, 30.00, -44.80, 80.00, 30.00, -80.00, 44.80, 30.00, -80.00, 0.00, 30.00, 0.00, 80.00, 12.00, -44.80, 80.00, 12.00, -80.00, 44.80, 12.00, -80.00, 0.00, 12.00, 0.00, 60.00, 3.00, -33.60, 60.00, 3.00, -60.00, 33.60, 3.00, -60.00, 0.00, 3.00, 0.00, 60.00, 0.00, -33.60, 60.00, 0.00, -60.00, 33.60, 0.00, -60.00, 0.00, 0.00, },{ 60.00, 0.00, 90.00, 60.00, 33.60, 90.00, 33.60, 60.00, 90.00, 0.00, 60.00, 90.00, 70.00, 0.00, 69.00, 70.00, 39.20, 69.00, 39.20, 70.00, 69.00, 0.00, 70.00, 69.00, 80.00, 0.00, 48.00, 80.00, 44.80, 48.00, 44.80, 80.00, 48.00, 0.00, 80.00, 48.00, 80.00, 0.00, 30.00, 80.00, 44.80, 30.00, 44.80, 80.00, 30.00, 0.00, 80.00, 30.00, },{ 0.00, 60.00, 90.00, -33.60, 60.00, 90.00, -60.00, 33.60, 90.00, -60.00, 0.00, 90.00, 0.00, 70.00, 69.00, -39.20, 70.00, 69.00, -70.00, 39.20, 69.00, -70.00, 0.00, 69.00, 0.00, 80.00, 48.00, -44.80, 80.00, 48.00, -80.00, 44.80, 48.00, -80.00, 0.00, 48.00, 0.00, 80.00, 30.00, -44.80, 80.00, 30.00, -80.00, 44.80, 30.00, -80.00, 0.00, 30.00, },{ // 10 56.00, 0.00, 90.00, 56.00, 31.36, 90.00, 31.36, 56.00, 90.00, 0.00, 56.00, 90.00, 53.50, 0.00, 95.25, 53.50, 29.96, 95.25, 29.96, 53.50, 95.25, 0.00, 53.50, 95.25, 57.50, 0.00, 95.25, 57.50, 32.20, 95.25, 32.20, 57.50, 95.25, 0.00, 57.50, 95.25, 60.00, 0.00, 90.00, 60.00, 33.60, 90.00, 33.60, 60.00, 90.00, 0.00, 60.00, 90.00, },{ 0.00, 56.00, 90.00, -31.36, 56.00, 90.00, -56.00, 31.36, 90.00, -56.00, 0.00, 90.00, 0.00, 53.50, 95.25, -29.96, 53.50, 95.25, -53.50, 29.96, 95.25, -53.50, 0.00, 95.25, 0.00, 57.50, 95.25, -32.20, 57.50, 95.25, -57.50, 32.20, 95.25, -57.50, 0.00, 95.25, 0.00, 60.00, 90.00, -33.60, 60.00, 90.00, -60.00, 33.60, 90.00, -60.00, 0.00, 90.00, },{ -64.00, 0.00, 75.00, -64.00, 12.00, 75.00, -60.00, 12.00, 84.00, -60.00, 0.00, 84.00, -92.00, 0.00, 75.00, -92.00, 12.00, 75.00, -100.00, 12.00, 84.00, -100.00, 0.00, 84.00, -108.00, 0.00, 75.00, -108.00, 12.00, 75.00, -120.00, 12.00, 84.00, -120.00, 0.00, 84.00, -108.00, 0.00, 66.00, -108.00, 12.00, 66.00, -120.00, 12.00, 66.00, -120.00, 0.00, 66.00, },{ -60.00, 0.00, 84.00, -60.00, -12.00, 84.00, -64.00, -12.00, 75.00, -64.00, 0.00, 75.00, -100.00, 0.00, 84.00, -100.00, -12.00, 84.00, -92.00, -12.00, 75.00, -92.00, 0.00, 75.00, -120.00, 0.00, 84.00, -120.00, -12.00, 84.00, -108.00, -12.00, 75.00, -108.00, 0.00, 75.00, -120.00, 0.00, 66.00, -120.00, -12.00, 66.00, -108.00, -12.00, 66.00, -108.00, 0.00, 66.00, },{ -108.00, 0.00, 66.00, -108.00, 12.00, 66.00, -120.00, 12.00, 66.00, -120.00, 0.00, 66.00, -108.00, 0.00, 57.00, -108.00, 12.00, 57.00, -120.00, 12.00, 48.00, -120.00, 0.00, 48.00, -100.00, 0.00, 39.00, -100.00, 12.00, 39.00, -106.00, 12.00, 31.50, -106.00, 0.00, 31.50, -80.00, 0.00, 30.00, -80.00, 12.00, 30.00, -76.00, 12.00, 18.00, -76.00, 0.00, 18.00, },{ // 15 -120.00, 0.00, 66.00, -120.00, -12.00, 66.00, -108.00, -12.00, 66.00, -108.00, 0.00, 66.00, -120.00, 0.00, 48.00, -120.00, -12.00, 48.00, -108.00, -12.00, 57.00, -108.00, 0.00, 57.00, -106.00, 0.00, 31.50, -106.00, -12.00, 31.50, -100.00, -12.00, 39.00, -100.00, 0.00, 39.00, -76.00, 0.00, 18.00, -76.00, -12.00, 18.00, -80.00, -12.00, 30.00, -80.00, 0.00, 30.00, },{ 68.00, 0.00, 51.00, 68.00, 26.40, 51.00, 68.00, 26.40, 18.00, 68.00, 0.00, 18.00, 104.00, 0.00, 51.00, 104.00, 26.40, 51.00, 124.00, 26.40, 27.00, 124.00, 0.00, 27.00, 92.00, 0.00, 78.00, 92.00, 10.00, 78.00, 96.00, 10.00, 75.00, 96.00, 0.00, 75.00, 108.00, 0.00, 90.00, 108.00, 10.00, 90.00, 132.00, 10.00, 90.00, 132.00, 0.00, 90.00, },{ 68.00, 0.00, 18.00, 68.00, -26.40, 18.00, 68.00, -26.40, 51.00, 68.00, 0.00, 51.00, 124.00, 0.00, 27.00, 124.00, -26.40, 27.00, 104.00, -26.40, 51.00, 104.00, 0.00, 51.00, 96.00, 0.00, 75.00, 96.00, -10.00, 75.00, 92.00, -10.00, 78.00, 92.00, 0.00, 78.00, 132.00, 0.00, 90.00, 132.00, -10.00, 90.00, 108.00, -10.00, 90.00, 108.00, 0.00, 90.00, },{ 108.00, 0.00, 90.00, 108.00, 10.00, 90.00, 132.00, 10.00, 90.00, 132.00, 0.00, 90.00, 112.00, 0.00, 93.00, 112.00, 10.00, 93.00, 141.00, 10.00, 93.75, 141.00, 0.00, 93.75, 116.00, 0.00, 93.00, 116.00, 6.00, 93.00, 138.00, 6.00, 94.50, 138.00, 0.00, 94.50, 112.00, 0.00, 90.00, 112.00, 6.00, 90.00, 128.00, 6.00, 90.00, 128.00, 0.00, 90.00, },{ 132.00, 0.00, 90.00, 132.00, -10.00, 90.00, 108.00, -10.00, 90.00, 108.00, 0.00, 90.00, 141.00, 0.00, 93.75, 141.00, -10.00, 93.75, 112.00, -10.00, 93.00, 112.00, 0.00, 93.00, 138.00, 0.00, 94.50, 138.00, -6.00, 94.50, 116.00, -6.00, 93.00, 116.00, 0.00, 93.00, 128.00, 0.00, 90.00, 128.00, -6.00, 90.00, 112.00, -6.00, 90.00, 112.00, 0.00, 90.00, },{ // 20 50.00, 0.00, 90.00, 50.00, 28.00, 90.00, 28.00, 50.00, 90.00, 0.00, 50.00, 90.00, 52.00, 0.00, 90.00, 52.00, 29.12, 90.00, 29.12, 52.00, 90.00, 0.00, 52.00, 90.00, 54.00, 0.00, 90.00, 54.00, 30.24, 90.00, 30.24, 54.00, 90.00, 0.00, 54.00, 90.00, 56.00, 0.00, 90.00, 56.00, 31.36, 90.00, 31.36, 56.00, 90.00, 0.00, 56.00, 90.00, },{ 0.00, 50.00, 90.00, -28.00, 50.00, 90.00, -50.00, 28.00, 90.00, -50.00, 0.00, 90.00, 0.00, 52.00, 90.00, -29.12, 52.00, 90.00, -52.00, 29.12, 90.00, -52.00, 0.00, 90.00, 0.00, 54.00, 90.00, -30.24, 54.00, 90.00, -54.00, 30.24, 90.00, -54.00, 0.00, 90.00, 0.00, 56.00, 90.00, -31.36, 56.00, 90.00, -56.00, 31.36, 90.00, -56.00, 0.00, 90.00, },{ -50.00, 0.00, 90.00, -50.00, -28.00, 90.00, -28.00, -50.00, 90.00, 0.00, -50.00, 90.00, -52.00, 0.00, 90.00, -52.00, -29.12, 90.00, -29.12, -52.00, 90.00, 0.00, -52.00, 90.00, -54.00, 0.00, 90.00, -54.00, -30.24, 90.00, -30.24, -54.00, 90.00, 0.00, -54.00, 90.00, -56.00, 0.00, 90.00, -56.00, -31.36, 90.00, -31.36, -56.00, 90.00, 0.00, -56.00, 90.00, },{ 0.00, -50.00, 90.00, 28.00, -50.00, 90.00, 50.00, -28.00, 90.00, 50.00, 0.00, 90.00, 0.00, -52.00, 90.00, 29.12, -52.00, 90.00, 52.00, -29.12, 90.00, 52.00, 0.00, 90.00, 0.00, -54.00, 90.00, 30.24, -54.00, 90.00, 54.00, -30.24, 90.00, 54.00, 0.00, 90.00, 0.00, -56.00, 90.00, 31.36, -56.00, 90.00, 56.00, -31.36, 90.00, 56.00, 0.00, 90.00, },{ 8.00, 0.00, 102.00, 8.00, 4.48, 102.00, 4.48, 8.00, 102.00, 0.00, 8.00, 102.00, 16.00, 0.00, 96.00, 16.00, 8.96, 96.00, 8.96, 16.00, 96.00, 0.00, 16.00, 96.00, 52.00, 0.00, 96.00, 52.00, 29.12, 96.00, 29.12, 52.00, 96.00, 0.00, 52.00, 96.00, 52.00, 0.00, 90.00, 52.00, 29.12, 90.00, 29.12, 52.00, 90.00, 0.00, 52.00, 90.00, },{ // 25 0.00, 8.00, 102.00, -4.48, 8.00, 102.00, -8.00, 4.48, 102.00, -8.00, 0.00, 102.00, 0.00, 16.00, 96.00, -8.96, 16.00, 96.00, -16.00, 8.96, 96.00, -16.00, 0.00, 96.00, 0.00, 52.00, 96.00, -29.12, 52.00, 96.00, -52.00, 29.12, 96.00, -52.00, 0.00, 96.00, 0.00, 52.00, 90.00, -29.12, 52.00, 90.00, -52.00, 29.12, 90.00, -52.00, 0.00, 90.00, },{ -8.00, 0.00, 102.00, -8.00, -4.48, 102.00, -4.48, -8.00, 102.00, 0.00, -8.00, 102.00, -16.00, 0.00, 96.00, -16.00, -8.96, 96.00, -8.96, -16.00, 96.00, 0.00, -16.00, 96.00, -52.00, 0.00, 96.00, -52.00, -29.12, 96.00, -29.12, -52.00, 96.00, 0.00, -52.00, 96.00, -52.00, 0.00, 90.00, -52.00, -29.12, 90.00, -29.12, -52.00, 90.00, 0.00, -52.00, 90.00, },{ 0.00, -8.00, 102.00, 4.48, -8.00, 102.00, 8.00, -4.48, 102.00, 8.00, 0.00, 102.00, 0.00, -16.00, 96.00, 8.96, -16.00, 96.00, 16.00, -8.96, 96.00, 16.00, 0.00, 96.00, 0.00, -52.00, 96.00, 29.12, -52.00, 96.00, 52.00, -29.12, 96.00, 52.00, 0.00, 96.00, 0.00, -52.00, 90.00, 29.12, -52.00, 90.00, 52.00, -29.12, 90.00, 52.00, 0.00, 90.00, },{ 0.00, 0.00, 120.00, 0.00, 0.00, 120.00, 0.00, 0.00, 120.00, 0.00, 0.00, 120.00, 32.00, 0.00, 120.00, 32.00, 18.00, 120.00, 18.00, 32.00, 120.00, 0.00, 32.00, 120.00, 0.00, 0.00, 108.00, 0.00, 0.00, 108.00, 0.00, 0.00, 108.00, 0.00, 0.00, 108.00, 8.00, 0.00, 102.00, 8.00, 4.48, 102.00, 4.48, 8.00, 102.00, 0.00, 8.00, 102.00, },{ 0.00, 0.00, 120.00, 0.00, 0.00, 120.00, 0.00, 0.00, 120.00, 0.00, 0.00, 120.00, 0.00, 32.00, 120.00, -18.00, 32.00, 120.00, -32.00, 18.00, 120.00, -32.00, 0.00, 120.00, 0.00, 0.00, 108.00, 0.00, 0.00, 108.00, 0.00, 0.00, 108.00, 0.00, 0.00, 108.00, 0.00, 8.00, 102.00, -4.48, 8.00, 102.00, -8.00, 4.48, 102.00, -8.00, 0.00, 102.00, },{ // 30 0.00, 0.00, 120.00, 0.00, 0.00, 120.00, 0.00, 0.00, 120.00, 0.00, 0.00, 120.00, -32.00, 0.00, 120.00, -32.00, -18.00, 120.00, -18.00, -32.00, 120.00, 0.00, -32.00, 120.00, 0.00, 0.00, 108.00, 0.00, 0.00, 108.00, 0.00, 0.00, 108.00, 0.00, 0.00, 108.00, -8.00, 0.00, 102.00, -8.00, -4.48, 102.00, -4.48, -8.00, 102.00, 0.00, -8.00, 102.00, },{ 0.00, 0.00, 120.00, 0.00, 0.00, 120.00, 0.00, 0.00, 120.00, 0.00, 0.00, 120.00, 0.00, -32.00, 120.00, 18.00, -32.00, 120.00, 32.00, -18.00, 120.00, 32.00, 0.00, 120.00, 0.00, 0.00, 108.00, 0.00, 0.00, 108.00, 0.00, 0.00, 108.00, 0.00, 0.00, 108.00, 0.00, -8.00, 102.00, 4.48, -8.00, 102.00, 8.00, -4.48, 102.00, 8.00, 0.00, 102.00, } }; }