Radiosity.h

Go to the documentation of this file.
00001 /* $Id:$ */
00002 
00003 #ifndef __RADIOSITY_H
00004 #define __RADIOSITY_H
00005 
00006 #include <gra/reflection/ReflectionModel.h>
00007 #include <esg/Intersector.h>
00008 #include <esg/energy/PolygonalEnergy.h>
00009 #include <esg/mesh/Mesh.h>
00010 
00011 using namespace esg;
00012 
00013 namespace gra {
00014 
00015 class GRA_EXPORT Radiosity : public ReflectionModel {
00016 public:
00017     struct Patch {
00018         PolygonalEnergy  * pEnergy;
00019         Mesh::Plane      * pMeshPlane;
00020         Vector3            reflectance;
00021         Vector3            emittance;
00022         Vector3            normal;
00023         Vector3            centre;
00024         float              area; 
00025 
00026         Patch (PolygonalEnergy *,
00027                Mesh::Plane     *,
00028                const Vector3   & /* reflectance */,
00029                const Vector3   & /* emittance   */,
00030                const Vector3   & /* centroid    */,
00031                float             /* area        */);
00032     };
00033 
00034 protected:
00035     Intersector * _pIntersector;
00036     int           _quadLevel;  // Error tolerance for the differential FF
00037     float         _dFError;    // How accurate to make quadrature
00038     List<Patch>   _scenePatches;
00039     int           _stage;      // which illumination stage will proceed
00040     bool          _useAmbient;
00041     
00042 protected:
00043     /*
00044      * Return energy of single edge of patche
00045      */
00046     virtual float _edge_area (const Vector3& /* v1     */,
00047                               const Vector3& /* v2     */,
00048                               const Vector3& /* normal */);
00049 
00050     /*
00051      * Form factor of single patch (cos theta * cos phi * Ap / (pi * r^2))
00052      */
00053     virtual float _est_patch_factor(Patch&         /* patch  */,
00054                                     const Vector3& /* point  */,
00055                                     const Vector3& /* normal */);
00056 
00057     /*
00058      * polygon-to-point form factor
00059      */
00060     virtual float _patch_factor(Patch&         /* patch  */,
00061                                 const Vector3& /* point  */,
00062                                 const Vector3& /* normal */);
00063 
00064     /*
00065      * Compute the form factor
00066      */
00067     virtual float _est_form_factor (Patch& /* from */, Patch& /* to */);
00068 
00069     /*
00070      * Compute all form factors for the given patch
00071      */
00072     virtual void _make_form_factors (Patch& /* from */, Vector3/* result */[]);
00073 
00074     /*
00075      * Vibility function
00076      */
00077     virtual float _visibility (Patch& /* from */, Patch& /* to */);
00078     
00079 public:
00080     Radiosity (Intersector   * i = NULL,
00081                int             q = 0,
00082                float           f = 0.0,
00083                bool            a = true)
00084         : _pIntersector(i),
00085           _quadLevel(q),
00086           _dFError(f),
00087           _useAmbient(a) {}
00088     
00089     virtual ~Radiosity () { _scenePatches.deleteAll(); }
00090 
00091     /*
00092      * BRDF employed by radiance-based methods is reduced to diffuse
00093      * coefficient. Dependency of reflection ration on azimuth and elevation
00094      * angles becames part of geometry term (form factors).
00095      */
00096     virtual void setBRDF (BRDF *) {}
00097 
00098     /*
00099      * Emittance is set for all patches in the setScene() function
00100      */
00101     virtual void setEmittance (Emittance *) {}
00102 
00103     /*
00104      * Initialize list of patches. Set them to facets of polygonal energy
00105      * coats found in the scene. The coats have to be facet-based
00106      * (see PoygonalEnergy class) and initialized
00107      * propositionally to emittance function of their original object.
00108      */
00109     virtual void setScene (Scene * /* scene */);
00110 
00111     /*
00112      * Instead of single point, whole scene is computed by radiance equation
00113      * evaluation. And because this evaluation is view-independent then
00114      * no argument is really used.
00115      */
00116     virtual Color3f* illuminatePoint (PointEnv&);
00117 };
00118 
00119 } // namespace
00120 
00121 #endif // __RADIOSITY_H

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