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; }
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; }
public Plane(Point3d point, Normal normal) { Point = point; Normal = normal; }