Exemplo n.º 1
0
 public DirectionalLight(Vect3D d)
 {
     _direction = d.Hat();
     _intensity = 0.5f;
     _color = new RGBColor(1, 1, 1);
     _castsShadows = false;
 }
Exemplo n.º 2
0
 public DirectionalLight(RGBColor c, float i, Vect3D d)
 {
     _color = new RGBColor(c);
     _intensity = i;
     _direction = d.Hat();
     _castsShadows = false;
 }
Exemplo n.º 3
0
        //Approximates the gradient of F(p) at a given point p
        protected virtual Normal ApproximateNormal(Point3D p, Vect3D rd)
        {
            float f = EvaluateImplicitFunction(p);
            float f_x = EvaluateImplicitFunction(new Point3D(p.X + EPSILON, p.Y, p.Z));
            float f_y = EvaluateImplicitFunction(new Point3D(p.X, p.Y + EPSILON, p.Z));
            float f_z = EvaluateImplicitFunction(new Point3D(p.X, p.Y, p.Z + EPSILON));

            //Compute vector for normal
            Vect3D raw_normal = (new Vect3D((float)(f_x - f), (float)(f_y - f), (float)(f_z - f))).Hat();

            //Check if dot product is positive, if so, flip the vector so it's facing the ray origin
            if(raw_normal * rd.Hat() > 0.0f) { raw_normal = -raw_normal; }
            return (new Normal(raw_normal));
        }