Exemplo n.º 1
0
        public int Reflectivity(Light.Light lightSrc, Point3D lookVect)
        {
            Point3D lightVector = (this - lightSrc.Location);
            Point3D locNormal   = vertexNorm;

            //Diffuse
            float dotProduct; // cosine of the angle between the normal and the lightsource (from -1 to 1)

            dotProduct = (locNormal * lightVector) / (lightVector.Magnitude * locNormal.Magnitude);
            float temp = (1 + dotProduct) / 2; //max(2/2) = 1, min = (0/2) = 0
            //float temp = 0;

            //Specular
            Point3D reflectVect = lookVect - 2 * (Point3D.Dot(lookVect, locNormal) * locNormal);

            lightVector.Normalize();
            reflectVect.Normalize();
            if (Point3D.Dot(lightVector, reflectVect) < -.85f)
            {
                temp = 1 / lightSrc.Intensity;
            }

            return((int)(temp * 255));
        }
Exemplo n.º 2
0
 public void Add(Light.Light l)
 {
     lights.Add(l);
 }