Exemple #1
0
        public ShadeRec IntersectAllObjects(Ray ray)
        {
            ShadeRec shadeRec = new ShadeRec(this);
            double t;
            Normal normal = new Normal();
            Point3d localHitPoint=new Point3d();

            double tmin = double.PositiveInfinity;

            for (int i = 0;i<Objects.Count;i++)
            {
                if (Objects[i].Intersect(ray,out t,shadeRec) && t < tmin)
                {
                    tmin = t;
                    shadeRec.HasHitObject = true;
                    shadeRec.Material = Objects[i].Material;
                    shadeRec.Hitpoint = ray.Origin + t*ray.Direction;
                    normal = shadeRec.Normal;
                    localHitPoint = shadeRec.LocalHitPoint;
                }
            }

            if (shadeRec.HasHitObject)
            {
                shadeRec.T = tmin;
                shadeRec.Normal = normal;
                shadeRec.LocalHitPoint = localHitPoint;
                shadeRec.Hitpoint = ray.Origin + tmin*ray.Direction;

            }

            return shadeRec;
        }
Exemple #2
0
        public void SetUpCamera(Vector3d eye, Vector3d lookAt, Vector3d up)
        {
            Eye = eye;
            LookAt = lookAt;
            Up = up;

            ComputeUVW();
        }
Exemple #3
0
        public ShadeRec(World world)
        {
            HasHitObject = false;
            Hitpoint = new Point3d();
            Normal = new Normal();
            LocalHitPoint = new Point3d();
            Ray=new Ray();
            Depth = 0;
            Direction = new Vector3d();
            T = 0;

            //Chapter 3 only
            Color = new RGBColor(0, 0, 0); //Black

            World = world;
        }
Exemple #4
0
 public Sphere(Point3d center, double radius)
 {
     Center = center;
     Radius = radius;
 }
Exemple #5
0
 public Plane(Point3d point, Normal normal)
 {
     Point = point;
     Normal = normal;
 }