import java.awt.*; public class test extends MISApplet { Surface[] objects=new Surface[12]; Matrix3D[] allTransfo=new Matrix3D[objects.length]; boolean lens=false; Light L1[]=new Light[2]; double[] orig=new double[] {0.0,0.0,0.0}; double fL=3.0; double[] v=new double[3]; double[] w=new double[3]; double[][][] rgbD; public void initialize(){ // setting the materials material mBackground=new material(); mBackground.setAmbient(0.1,0,0.3); mBackground.setDiffuse(0,0,0); mBackground.setSpecular(0,0,0); material mIce=new material(); mIce.setDiffuse(0.5,0.5,0.5); mIce.setSpecular(0.5,0.5,0.5); material mWood=new material(); mWood.setDiffuse(0.15,0.1,0.07); mWood.setSpecular(0,0,0); material mBlack=new material(); mBlack.setDiffuse(0,0,0); mBlack.setSpecular(0.8,0.8,0.8); mBlack.p=50; material mGris=new material(); mGris.setAmbient(new double[] {0.1,0.1,0.1}); mGris.setDiffuse(new double[] {0,1,0}); material mRed=new material(); mRed.setDiffuse(new double[] {1,0,0}); mRed.setAmbient(new double[] {0,0,0}); material mGlass=new material(); mGlass.setRefractive(new double[] {1,1,1}); mGlass.setTranslucent(); mGlass.refrInd=2; mGlass.setDiffuse(new double[] {0.1,0.1,0.1}); mGlass.setAmbient(new double[] {0,0,0}); mGlass.setSpecular(new double[] {0.3,0.3,0.3}); material mGris2=new material(); mGris2.copy(mGris); mGris2.setSpecular(new double[] {1,1,1}); // building objects Plane[] facesGlass=new Plane[6]; facesGlass[0]=new Plane(new double[] {-1,0,0,-1},mBackground); facesGlass[1]=new Plane(new double[] {1,0,0,-1},mBackground); facesGlass[2]=new Plane(new double[] {0,-1,0,-1},mBackground); facesGlass[3]=new Plane(new double[] {0,1,0,-1},mBackground); facesGlass[4]=new Plane(new double[] {0,0,-1,-1},mBackground); facesGlass[5]=new Plane(new double[] {0,0,1,-1},mBackground); objects[1]=new Polyhedron(facesGlass); Plane[] faces1=new Plane[6]; faces1[0]=new Plane(new double[] {-1,0,0,-1},mIce); faces1[1]=new Plane(new double[] {1,0,0,-1},mIce); faces1[2]=new Plane(new double[] {0,-1,0,-1},mIce); faces1[3]=new Plane(new double[] {0,1,0,-1},mIce); faces1[4]=new Plane(new double[] {0,0,-1,-1},mIce); faces1[5]=new Plane(new double[] {0,0,1,-1},mIce); objects[0]=new Polyhedron(faces1); Plane[] faces2=new Plane[6]; faces2[0]=new Plane(new double[] {-1,0,0,-1},mWood); faces2[1]=new Plane(new double[] {1,0,0,-1},mWood); faces2[2]=new Plane(new double[] {0,-1,0,-1},mWood); faces2[3]=new Plane(new double[] {0,1,0,-1},mWood); faces2[4]=new Plane(new double[] {0,0,-1,-1},mWood); faces2[5]=new Plane(new double[] {0,0,1,-1},mWood); objects[objects.length-1]=new sphere(1.7,mGlass,0,0,-5); objects[objects.length-1].m.translucent=1; objects[2]=new sphere(3,mIce,-4,-2.5,-12); objects[3]=new sphere(1,mIce,1,-1.7,-10); objects[4]=new sphere(0.7,mIce,1,-0.4,-10); objects[5]=new Polyhedron(faces2); objects[6]=new Polyhedron(faces2); objects[7]=new sphere(0.1,mBlack,1,-0.6,-9.3); objects[8]=new sphere(0.1,mBlack,0.8,-0.4,-9.3); objects[9]=new sphere(0.1,mBlack,1.2,-0.4,-9.3); objects[10]=new Polyhedron(faces1); //setting transformations for (int i=0;i255) rgb[j]=255; } } //--------------------------------------------------------- public double[] normalize(double[] vs){ int n=vs.length; double norm=0; for (int i=0; i