public override Couleur drawPixel(V3 position) { V3 ai = position - this.getPosition(); double la = (this.largeur * ai) / (this.largeur * this.largeur); double lo = (this.longueur * ai) / (this.longueur * this.longueur); V3 vectRect = ((float)la * this.largeur) + ((float)lo * this.longueur); V3 copyVectRect = new V3(vectRect); copyVectRect.Normalize(); float dhsdu; float dhsdv; this.getBump(la, lo, out dhsdu, out dhsdv); V3 dmsdu = new V3((float)(-1 * Math.Cos(lo) * Math.Sin(la)), (float)(1 * Math.Cos(lo) * Math.Cos(la)), 0.0f); V3 dmsdv = new V3((float)(-1 * Math.Sin(lo) * Math.Cos(la)), (float)(-1 * Math.Sin(lo) * Math.Sin(la)), (float)(1 * Math.Cos(lo))); V3 dmpsdu = dmsdu + dhsdu * copyVectRect; V3 dmpsdv = dmsdv + dhsdv * copyVectRect; V3 Np = ((dmpsdu ^ dmpsdv) / (dmpsdu ^ dmpsdv).Norm()); V3 vecteurBump = Np; V3 position_point = this.getPosition() + vectRect; Couleur vcolor = new Couleur(); foreach (Light light in RenderSing.getCurrentRender().getLight()) { vcolor += light.applyLight(this, position_point, vecteurBump, this.getColor(la, lo)); } return(vcolor); }
public Couleur specular(Object3D b, V3 v, Couleur color_surface) { V3 copy_v = new V3(v); copy_v.Normalize(); V3 copy_pos = new V3(this.direction); copy_pos.Normalize(); float sca = (copy_pos * copy_v); V3 v_curent_perfect = (copy_v * sca * 2.0f) - copy_pos; V3 v_current_oeil = -(v + b.getPosition()) + RenderSing.getCurrentRender().getEyesPosition(); float a = (float)Math.Pow((Math.Max((v_curent_perfect * v_current_oeil) / (v_curent_perfect.Norm() * v_current_oeil.Norm()), 0)), 25); return(this.couleur * a); }
public override Couleur applyLight(Object3D enlightmentObject, V3 positionOnScene, V3 normal, Couleur color_surface) { foreach (Object3D one in RenderSing.getCurrentRender().getObject()) { V3 dirN = new V3(direction); dirN.Normalize(); double t = 0; if (enlightmentObject != one && one.testColition(positionOnScene, dirN, out t)) { return(new Couleur(0f, 0f, 0f)); } } return(this.diffuse(enlightmentObject, normal, color_surface) + this.specular(enlightmentObject, normal, color_surface)); }