public class hw8bis extends MISApplet { spherebis[] spheres=new spherebis[2]; light L[]=new light[2]; //light L[]=new light[1]; 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(){ spheres=new spherebis[2]; spheres[0]=new spherebis(0.8, new material(), -0.2, 0, -5); material mtruc=new material(); mtruc.setAmbient(new double[] {0.1,0.1,0.1}); mtruc.setSpecular(new double[] {1,1,1}); mtruc.setDiffuse(new double[] {0.3,0,0}); mtruc.p=5; spheres[1]=new spherebis(1, mtruc, 0.5, 0.3, -4); L[0]=new light(); L[0].setDir(new double[] {0,1,0}); L[0].setRgb(new double[] {1,1,1}); L[1]=new light(); L[1].setDir(new double[] {-0.5,0.3,-0.4}); L[1].setRgb(new double[] {1,1,1}); v[0]=0; v[1]=0; v[2]=0; rgbD=new double[W][H][3]; } public void initFrame(double time) { L[0].setDir(new double[] {0,Math.sin(time),Math.cos(time)}); for (int i=0;i255) rgb[j]=255; } } //--------------------------------------------------------- public double[] rayTrace(double[] v, double[] w){ double t=10000; int ind=-1; double[] res=new double[3]; for (int i=0; i< spheres.length; i++){ double tc=spheres[i].intersect(v,w); if (tc0){ t=tc; ind=i; } } if (ind>=0){ res=spheres[ind].shade(L,v,w,t);// add fields in sphere to keep values of the intersection and "prepare" shading if it is indeed shaded //res=spheres[ind].shade(spheres,L,v,w,t);// add fields in sphere to keep values of the intersection and "prepare" shading if it is indeed shaded } return res; } public double[] normalize(double[] vs){ int n=vs.length; double norm=0; for (int i=0; i