Esempio n. 1
0
        private Couleur processLumiere(V3 rayon, PointColore point)
        {
            V3 normalPoint = point.GetNormale();
            //V3 directionOculaire = new V3(camera - point.GetLoc());
            //directionOculaire.Normalize();

            Couleur lumiereTotale = new Couleur(0, 0, 0);

            lumiereTotale += point.GetCouleur() * couleurAmbiance * intensiteAmbiance;
            foreach (Lumiere lampe in lampes)
            {
                if (!(lampe.isOccluded(point, objets)))
                {
                    V3 directionLampeNormale = new V3(lampe.GetDirection(point.GetLoc()));
                    directionLampeNormale.Normalize();

                    float cosAlpha      = normalPoint * directionLampeNormale;
                    float facteurDiffus = Math.Max(0, cosAlpha);
                    lumiereTotale += point.GetCouleur() * lampe.GetCouleur() * facteurDiffus * lampe.GetIntensite(point.GetLoc());

                    V3    reflet            = (2 * cosAlpha * normalPoint) - directionLampeNormale;
                    float produitSpeculaire = Math.Max(0, (reflet * (-rayon)) / (reflet.Norm() * rayon.Norm()));
                    float facteurSpeculaire = (float)Math.Pow(produitSpeculaire, puissanceSpeculaire);
                    lumiereTotale += lampe.GetCouleur() * lampe.GetIntensite(point.GetLoc()) * facteurSpeculaire;
                }
            }
            return(lumiereTotale);
        }
Esempio n. 2
0
 public override bool isOccluded(PointColore point, List <Formes> objets)
 {
     foreach (Formes objet in objets)
     {
         if (objet != point.getOwner())
         {
             float intersect = objet.IntersectRayon(point.GetLoc(), this.direction);
             if (intersect >= 0)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Esempio n. 3
0
 public override bool isOccluded(PointColore point, List <Formes> objets)
 {
     foreach (Formes objet in objets)
     {
         if (objet != point.getOwner())
         {
             float intermax  = (this.position - point.GetLoc()).Norm();
             float intersect = objet.IntersectRayon(point.GetLoc(), this.GetDirection(point.GetLoc()));
             if (intersect >= 0 && intersect <= intermax)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Esempio n. 4
0
        private Couleur Raycast(V3 camera, V3 rayon)
        {
            Dictionary <float, Formes> intersections = new Dictionary <float, Formes>();

            foreach (Formes objet in objets)
            {
                float intersect = objet.IntersectRayon(camera, rayon);
                if (intersect >= 0 && !(intersections.Keys.Contains(intersect)))
                {
                    intersections.Add(intersect, objet);
                }
            }

            if (intersections.Keys.Count == 0)
            {
                return(new Couleur(0, 0, 0));
            }
            float       minT  = intersections.Keys.Min();
            PointColore point = intersections[minT].GetCouleurIntersect(camera, rayon, minT);

            return(processLumiere(rayon, point));
        }
Esempio n. 5
0
 public abstract bool isOccluded(PointColore point, List <Formes> objets);