MatVisitor.h

Go to the documentation of this file.
00001 /* $Id:$ */
00002 
00003 #ifndef __MATERIAL_VISITOR_H
00004 #define __MATERIAL_VISITOR_H
00005 
00006 /*
00007  * Visitor, which  inspects all attributes necessary for illumination:
00008  * material coefficients and reflection information (BRDF, emittance etc.).
00009  * This is much more faster then inspecting them individually.
00010  */
00011 
00012 #include <esg/Material.h>
00013 #include <esg/visitor/Visitor.h>
00014 
00015 namespace esg {
00016 
00017 class OGSCENE_EXPORT MatVisitor : public Visitor {
00018 protected:
00019     Roughness         * _pRoughness; 
00020     Specular          * _pSpecular;
00021     Diffuse           * _pDiffuse;
00022     Ambient           * _pAmbient;
00023     IndexOfRefraction * _pIndexOfRefraction;
00024     FresnelTerm       * _pFresnelTerm;
00025     GaussianCoef      * _pGaussianCoef;
00026     Transparency      * _pTransparency;
00027     Reflection        * _pReflection;
00028   
00029 public:
00030     MatVisitor () { 
00031         _pRoughness         = NULL; 
00032         _pSpecular          = NULL;
00033         _pDiffuse           = NULL;
00034         _pAmbient           = NULL;
00035         _pIndexOfRefraction = NULL;
00036         _pFresnelTerm       = NULL;
00037         _pGaussianCoef      = NULL;
00038         _pTransparency      = NULL;
00039         _pReflection        = NULL;
00040     }
00041 
00042     virtual void visitRoughness    (Roughness   * p) { _pRoughness    = p; }
00043     virtual void visitSpecular     (Specular    * p) { _pSpecular     = p; }
00044     virtual void visitDiffuse      (Diffuse     * p) { _pDiffuse      = p; }
00045     virtual void visitAmbient      (Ambient     * p) { _pAmbient      = p; }
00046     virtual void visitIndexOfRefraction (IndexOfRefraction * p) { _pIndexOfRefraction   = p; }
00047     virtual void visitTransparency (Transparency* p) { _pTransparency = p; }
00048     virtual void visitReflection   (Reflection  * p) { _pReflection   = p; }
00049     virtual void visitFresnelTerm  (FresnelTerm * p) { _pFresnelTerm  = p; }
00050     virtual void visitGaussianCoef (GaussianCoef* p) { _pGaussianCoef = p; }
00051     
00052     virtual void init (void) {
00053         _pRoughness         = NULL; 
00054         _pSpecular          = NULL;
00055         _pDiffuse           = NULL;
00056         _pAmbient           = NULL;
00057         _pIndexOfRefraction = NULL;
00058         _pFresnelTerm       = NULL;
00059         _pGaussianCoef      = NULL;
00060         _pTransparency      = NULL;
00061         _pReflection        = NULL;
00062     }
00063 
00064     float roughness (void) const {
00065         return ((_pRoughness) ? _pRoughness->value() : Roughness().value());
00066     }
00067 
00068     int intRoughness (void) const {
00069         return ((_pRoughness) ?
00070                 _pRoughness->intValue() :
00071                 Roughness().intValue());
00072     }
00073 
00074     float indexOfRefraction (void) {
00075         return ((_pIndexOfRefraction) ?
00076                 _pIndexOfRefraction->value() :
00077                 IndexOfRefraction().value());
00078     }
00079     
00080     const Vector3& specular (void) const {
00081         return ((_pSpecular) ? _pSpecular->value() : Specular().value());
00082     }
00083     
00084     const Vector3& diffuse (void) const {
00085         return ((_pDiffuse) ? _pDiffuse->value() : Diffuse().value());
00086     }
00087     
00088     const Vector3& ambient (void) const {
00089         return ((_pAmbient) ? _pAmbient->value() : Ambient().value());
00090     }
00091 
00092     const Vector3& transparency (void) const {
00093         return ((_pTransparency) ?
00094                 _pTransparency->value() :
00095                 Transparency().value());
00096     }
00097 
00098     const Vector3& reflection (void) const {
00099         return ((_pReflection) ?
00100                 _pReflection->value() :
00101                 Reflection().value());
00102     }
00103 
00104     const Vector3& fresnelTerm (void) const {
00105         return ((_pFresnelTerm) ?
00106                 _pFresnelTerm->value() :
00107                 FresnelTerm().value());
00108     }
00109     
00110     const Vector3& gaussianCoef (void) const {
00111         return ((_pGaussianCoef) ?
00112                 _pGaussianCoef->value() :
00113                 GaussianCoef().value());
00114     }
00115 
00116     const double avgSpecular (void) const {
00117         return ((_pSpecular) ? _pSpecular->avgValue() : Specular().avgValue());
00118     }
00119     
00120     const double avgDiffuse (void) const {
00121         return ((_pDiffuse) ? _pDiffuse->avgValue() : Diffuse().avgValue());
00122     }
00123     
00124     const double avgAmbient (void) const {
00125         return ((_pAmbient) ? _pAmbient->avgValue() : Ambient().avgValue());
00126     }
00127     
00128     const double avgTransparency (void) const {
00129         return ((_pTransparency) ?
00130                 _pTransparency->avgValue() :
00131                 Transparency().avgValue());
00132     }
00133 
00134     const double avgReflection (void) const {
00135         return ((_pReflection) ?
00136                 _pReflection->avgValue() :
00137                 Reflection().avgValue());
00138     }
00139     
00140     const double avgFresnelTerm (void) const {
00141         return ((_pFresnelTerm) ?
00142                 _pFresnelTerm->avgValue() :
00143                 FresnelTerm().avgValue());
00144     }
00145 
00146     const double avgGaussianCoef (void) const {
00147         return ((_pGaussianCoef) ?
00148                 _pGaussianCoef->avgValue() :
00149                 GaussianCoef().avgValue());
00150     }
00151 };
00152 
00153 }; // namespace
00154 
00155 #endif // __RT_MATERIAL_VISITOR_H

Generated on Wed Jun 28 12:24:29 2006 for esg by  doxygen 1.4.6