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; }