Пример #1
0
        private Ray GetRay(Vec3d x)
        {
            Vec3d direction = position - x;

            direction.Normalize();
            return(new Ray(x + direction * 1e-6f, direction));
        }
Пример #2
0
        public Ray SightLine(float x, float y)
        {
            Vec3d v         = (x - 0.5f) * right * fovScale;
            Vec3d u         = (y - 0.5f) * up * fovScale;
            Vec3d direction = v + u + front;

            direction.Normalize();
            return(new Ray(viewPoint, direction));
        }
Пример #3
0
 public Triangle(Vec3d v1, Vec3d v2, Vec3d v3)
 {
     this.v1 = v1;
     this.v2 = v2;
     this.v3 = v3;
     e1      = v2 - v1;
     e2      = v3 - v1;
     normal  = e1.Cross(e2);
     normal.Normalize();
 }
Пример #4
0
 public PerspectiveCamera(Vec3d vp, Vec3d f, Vec3d refUp, float fov)
 {
     viewPoint = vp;
     f.Normalize();
     front = f;
     right = f.Cross(refUp);
     right.Normalize();
     up       = right.Cross(f);
     fovScale = (float)Math.Tan(fov * Pi * 0.5f / 180) * 2;
 }
Пример #5
0
 public Plane(Vec3d n, float l)
 {
     n.Normalize();
     pos    = l * n;
     normal = n;
 }
Пример #6
0
 public DirectionalLight(Vec3d d, float l)
 {
     d.Normalize();
     direction = d;
     luminance = l;
 }