Exemplo n.º 1
0
 public Color L(Point point, out Point lightPos, out Normal lightDir)
 {
     Vector dir = this.Position - point;
     float dist = dir.Magnitude();
     lightDir = new Normal(dir);
     lightPos = this.Position;
     return (this.E / (dist * dist));
 }
Exemplo n.º 2
0
 public bool Intersect(Point frontEnd, Point backEnd)
 {
     Vector segment = frontEnd - backEnd;
     float actualT = segment.Magnitude();
     Normal normSeg = segment.Normalize();
     Point perturbBack = Math.Utils.Perturb(backEnd, normSeg);
     Ray ray = new Ray(perturbBack, normSeg);
     Intersection tempInt = null;
     if (this.Intersect(ray, out tempInt))
     {
         float newT = (tempInt.Point - backEnd).Magnitude();
         return Math.Utils.LessThan(newT, actualT);
     }
     return false;
 }
Exemplo n.º 3
0
 private bool PointInRect(Point point)
 {
     Vector v1 = null;
     Vector v2 = null;
     for (int i = 0; i < 3; ++i)
     {
         v1 = this._corners[i + 1] - this._corners[i];
         v2 = point - this._corners[i];
         if (Vector.Dot(v1, v2) < 0)
         {
             return false;
         }
     }
     v1 = this._corners[0] - this._corners[3];
     v2 = point - this._corners[3];
     return (Vector.Dot(v1, v2) >= 0);
 }
Exemplo n.º 4
0
 public static Image Render(Scene scene, ICamera camera, Film film)
 {
     float halfWidth = film.Width / 2;
     float halfHeight = film.Height / 2;
     IIntegrator integrator = new DirectIntegrator();
     for (int x = 0; x < film.Width; ++x)
     {
         for (int y = 0; y < film.Height; ++y)
         {
             // Transform image->space to camera space
             Math.Point rayOrigin = new Math.Point()
             {
                 X = (x - halfWidth) / film.Width,
                 Y = -(y - halfHeight) / film.Width,
                 Z = 0
             };
             Ray ray = camera.GenerateRay(rayOrigin);
             film[x, y] = integrator.Integrate(ray, scene);
         }
     }
     return film.ToImage();
 }
Exemplo n.º 5
0
 public void Transform(Transformation trans)
 {
     this.Position = this.Position.Transform(trans);
 }
Exemplo n.º 6
0
 public Ray GenerateRay(Point point)
 {
     Ray ray = new Ray(point, new Normal(point - this._focalPoint));
     ray.Transform(this._transform);
     return ray;
 }
Exemplo n.º 7
0
 public PerspectiveCamera(float fov)
 {
     float dist = 0.5f / (float)System.Math.Tan(fov / 2.0f);
     this._focalPoint = new Point(0, 0, -dist);
 }
Exemplo n.º 8
0
 public void Transform(Transformation trans)
 {
     this._center = this._center.Transform(trans);
 }
Exemplo n.º 9
0
 public Ray(Point origin, Normal direction)
 {
     this.Origin = origin;
     this.Direction = direction;
 }
Exemplo n.º 10
0
 public void Transform(Transformation trans)
 {
     this.Origin = this.Origin.Transform(trans);
     this.Direction = this.Direction.Transform(trans);
 }