Caustics.cc

Go to the documentation of this file.
00001 #include <gra/reflection/Caustics.h>
00002 #include <esg/visitor/PhotonMapBhvVisitor.h>
00003 
00004 using namespace gra;
00005 
00006 void Caustics::_illuminate(PointEnv& surr,
00007                            unsigned  actDepth,
00008                            bool      firstObjHit,
00009                            Color3f&  unused)
00010 {
00011     /*
00012      * We suppose that the given "surr" contains proper point of intersection,
00013      * normal vector and associated primitive
00014      *
00015      * Transform point of intersection and properly orient normal
00016      */
00017     _check_point_of_intersection(surr);
00018 
00019     /*
00020      * Inspect attributes that are necessary for local illumination,
00021      * reflection and transmission. Set correct BRDF and emittance for local
00022      * reflection. If the point of interest is the second point of refraction
00023      * ray then previous material is used (the object was not changed)
00024      */
00025     MatVisitor* pMatVisitor = _check_material(surr.pVisitableObj, firstObjHit);
00026 
00027     const Vector3& refl   = pMatVisitor->reflection();
00028     const Vector3& transp = pMatVisitor->transparency();
00029     if (refl.x || refl.y || refl.z || transp.x || transp.y || transp.z) {
00030         /*
00031          * Traverse random direction using russian roulette
00032          */
00033         if (actDepth < _maxDepth) 
00034             _cast_secondary_rays(surr, actDepth, firstObjHit,
00035                                  unused, *pMatVisitor);
00036     } else {
00037         /*
00038          * store photon falled on a diffuse surface
00039          */
00040         _store_photon(surr, true);
00041     }
00042 }
00043 
00044 // --------- public ----------------
00045 
00046 

Generated on Tue Nov 21 15:11:42 2006 for gra by  doxygen 1.4.6