public EnergieLumineuse GetLumiere(Rayon R, int bounceLeft, List <ObjetPhysique> ExclusionContact) { EnergieLumineuse E = Rayon.CalculerAtmosphere(this, R.tir); if (E.isNan()) { ; } EnergieLumineuse Ei = new EnergieLumineuse(); InfoContact contact = R.Tirer(this, ExclusionContact); if (!(contact.Objet is null)) { Vector Opacite = Rayon.CalculerOpacite(this, R.tir.depart, R.Position()); Materiau mat = contact.Objet.getMateriau(); if (bounceLeft > 0) { Tir rebond = contact.Rebond(); Tir refrac = contact.Refraction(); Rayon Rebond = new Rayon(rebond, 0, R.Pas, R.distMax); Rayon Refrac = new Rayon(refrac, 0, R.Pas, R.distMax); EnergieLumineuse LumRebond = GetLumiere(Rebond, bounceLeft - 1, new List <ObjetPhysique>() { contact.Objet }); if (!mat.Opaque) { EnergieLumineuse LumRefrac = GetLumiere(Refrac, bounceLeft - 1, new List <ObjetPhysique>() { contact.Objet }); Ei += LumRefrac * contact.coeffRefrac(refrac.direction); } Vector Couleur = contact.Objet.CouleurReelle(contact, rebond.direction); Ei += LumRebond * Couleur * contact.coeffRebond(refrac.direction); } foreach (SourceLumineuse lu in sources) { Vector OpaciteLum = Rayon.CalculerOpacite(this, lu.Position(), contact.Position); Vector Sortant = (lu.Position() - contact.Position).Normer(); EnergieLumineuse ArriveeBrute = lu.GetEnergieLumineuse(contact.Position); EnergieLumineuse Attenuee = ArriveeBrute.Opacifier(OpaciteLum, facteurExtinction); Vector Couleur = contact.Objet.CouleurReelle(contact, Sortant); EnergieLumineuse PointContact = Attenuee * Couleur; Ei += PointContact; } Ei.Opacifier(Opacite, facteurExtinction); } return(E + Ei); }
static void Main(string[] args) { Materiau Test = new Materiau(Mapper.Uniforme(new Vector(0.1, 0.03, 0.06)), Mapper.Uniforme(new Vector(0, 0, 0)), Mapper.AttenuationGaussienne(0.1, 0.1, 0.1), Mapper.AttenuationGaussienne(2, 2, 2), new Vector(1, 1, 1), 1, true); Materiau Test2 = new Materiau(Mapper.Uniforme(new Vector(0.01, 0, 0)), Mapper.Uniforme(new Vector(0, 0, 0)), Mapper.AttenuationGaussienne(1, 1, 0.5), ((x) => new Vector(1, 1, 1) * (x / 10)), new Vector(0.4, 0.4, 0.2), 1.3, false); Materiau Test3 = new Materiau(Mapper.Uniforme(new Vector(0, 0.2, 0)), Mapper.Uniforme(new Vector(0, 0, 0)), Mapper.AttenuationGaussienne(1, 1, 0.5), ((x) => new Vector(1, 1, 1) * (x / 10)), new Vector(0.4, 0.4, 0.2), 1, false); SourceLumineuse Source = new SourceLumineuse(new Base(Vector.X(), Vector.Y(), Vector.Z(), new Vector(0, 7, 3)), Mapper.ConeConstant(Color.White)); SourceLumineuse Source2 = new SourceLumineuse(new Base(Vector.X(), Vector.Y(), Vector.Z(), new Vector(0, 7, -3)), Mapper.ConeConstant(Color.White)); Sphere S = new Sphere(5, Test, new Base(Vector.X(), Vector.Y(), Vector.Z(), new Vector(0, 0, 0))); Sphere S1 = new Sphere(1, Test2, new Base(Vector.X(), Vector.Y(), Vector.Z(), new Vector(1.5, 6, 0))); Sphere S2 = new Sphere(1, Test3, new Base(Vector.X(), Vector.Y(), Vector.Z(), new Vector(-1.5, 6, 0))); Univers U = new Univers(new List <ObjetPhysique>() { S, S1, S2 }, new List <SourceLumineuse>() { Source2, Source }, 2, 5, 0.01, 1, Mapper.FiltrationUniforme(new Vector(0.1, 0.1, 0.1)), Mapper.Cacahuete(0.5, 0.01), 0.2); Camera C = new Camera(new Base(Vector.X(), Vector.Y(), Vector.Z(), new Vector(0, 7, 0)), 0.5, 100, 100, 0.05); C.Rendre(U).Save("D:/lab/Rendu3D/1.bmp"); }
public Sphere(double Rayon, Materiau Mat, Base orientation) : base(Mat, orientation) { rayon = Rayon; }
public ObjetPhysique(Materiau Mat, Base orientation) : base(orientation) { materiau = Mat; }