Usages of

.trace(?)
@Override public double isVisible(Point3d globalPoint, List<Body> bodies) { Point3d localPoint = toLocal(globalPoint); Vector3d direction = Vectors.normalize(Vectors.sub(position, localPoint)); Ray ray = new Ray(direction, localPoint); double maxT = position.distance(localPoint); Ray globalRay = new Ray(toGlobal(ray.getDirection()), toGlobal(ray.getOrigin())); IntersectionContext ic = globalRay.trace(bodies); if (ic.getHit() && maxT - ic.getT() > Shape.EPS) return 0; return 1; }
@Override public IntersectionContext trace(Ray ray) { return ray.trace(objects); }
@Override public Color3f directShade(IntersectionContext ic, List<Light> lights, List<Body> bodies, int refractionDepth, int reflectionDepth) { Color3f rrColor; Color3f rfColor; Color3f phongColor = super.directShade(ic, lights, bodies, refractionDepth, reflectionDepth); Ray refracted = refract(ic, refractionIndex); Ray reflected = reflect(ic); double costi = -ic.getRay().getDirection().dot(ic.getNormal()); boolean in = costi < 0; if (tir(ic, refractionIndex)) { if (reflectionDepth < REFLECTIONDEPTH) { IntersectionContext reflectedIc = reflected.trace(bodies); Color3f reflectedColor = reflectedIc.directShade(lights, bodies, refractionDepth, reflectionDepth+1); Color3f result = filterColor(reflectedColor, reflectedIc, in); result.add(phongColor); return result; } else return new Color3f(1,0,1); } if (refractionDepth < REFRACTIONDEPTH) { IntersectionContext refractedIc = refracted.trace(bodies); rrColor = refractedIc.directShade(lights, bodies, refractionDepth+1, reflectionDepth); rrColor = filterColor(rrColor, refractedIc, !in); } else rrColor = new Color3f(1,0,1); if (reflectionDepth < REFLECTIONDEPTH) { IntersectionContext reflectedIc = reflected.trace(bodies); rfColor = reflectedIc.directShade(lights, bodies, refractionDepth, reflectionDepth+1); rfColor = filterColor(rfColor, reflectedIc, in); } else rfColor = new Color3f(1,0,1); float rC = (float)calculateReflectionCoefficient(refracted, reflected, ic); float localKr = kR*rC; float localKt = kT*(1-rC); rrColor.scale(localKt); rfColor.scale(localKr); phongColor.scale(localKr); rrColor.add(rfColor); rrColor.add(phongColor); return rrColor; }
Usage snippet has been bookmarked! Review your bookmarks
Thank you! Review your likes