EnvironmentMap.h

Go to the documentation of this file.
00001 /**<!-------------------------------------------------------------------->
00002    @class  EnvironmentMap
00003    @author Travis Fischer (fisch0920@gmail.com)
00004    @date   Fall 2008
00005    
00006    @brief
00007       Environment map using latitude-longitude format.  An environment map 
00008    roughly models distant illumination surrounding a scene by conceptually 
00009    surrounding the scene with a spherical emitter that emits light inwards 
00010    according to a distribution defined by a 2D 'environment' texture map that 
00011    is projected onto the surface of the sphere.  Note the term HDR environment 
00012    map is thrown around a lot; the only difference is that the underlying 
00013    environment texture is stored in some type of high dynamic range format, 
00014    such as OpenEXR or HDR.
00015    <!-------------------------------------------------------------------->**/
00016 
00017 #ifndef ENVIRONMENT_MAP_H_
00018 #define ENVIRONMENT_MAP_H_
00019 
00020 #include <common/image/Image.h>
00021 #include <materials/Material.h>
00022 #include <materials/Emitter.h>
00023 #include <core/UV.h>
00024 
00025 class KernelFilter;
00026 
00027 class EnvironmentMap : public Emitter {
00028    public:
00029       ///@name Constructors
00030       //@{-----------------------------------------------------------------
00031       
00032       inline   EnvironmentMap(Material *parent = NULL, 
00033                               ImagePtr image = ImagePtr())
00034          : Emitter(Material::s_nullSurfacePoint, NULL, parent), 
00035            m_filter(NULL), m_image(image)
00036       { }
00037       
00038       virtual ~EnvironmentMap()
00039       { }
00040       
00041       
00042       //@}-----------------------------------------------------------------
00043       ///@name Initialization
00044       //@{-----------------------------------------------------------------
00045       
00046       /**
00047        * @brief
00048        *    Performs any initialization that may be necessary before beginning 
00049        * to use this environment map
00050        */
00051       virtual void init();
00052       
00053       
00054       //@}-----------------------------------------------------------------
00055       ///@name Main usage interface
00056       //@{-----------------------------------------------------------------
00057       
00058       /**
00059        * @returns the spectral radiance emitted along the given vector
00060        */
00061       virtual SpectralSampleSet getLe(const Vector3 &w);
00062       
00063       /// Overridden to be empty
00064       virtual void preview(Shape *shape);
00065       
00066       
00067       //@}-----------------------------------------------------------------
00068       ///@name Accessors / Mutators
00069       //@{-----------------------------------------------------------------
00070       
00071       inline ImagePtr &getImage() {
00072          return m_image;
00073       }
00074       
00075       inline void setImage(ImagePtr image) {
00076          m_image = image;
00077       }
00078       
00079       
00080       //@}-----------------------------------------------------------------
00081       ///@name Spherical <-> Planar mapping
00082       //@{-----------------------------------------------------------------
00083       
00084       virtual Vector2 getSphericalCoords(const Vector3 &w);
00085       virtual Vector2 getSphericalCoords(const UV &uv);
00086       virtual UV getUV(const Vector3 &w);
00087       virtual UV getUV(const Vector2 &coords);
00088       virtual Vector3 getDirection(const UV &uv);
00089       
00090       
00091       //@}------------------------------------------------------------------
00092       
00093    protected:
00094       KernelFilter *m_filter;
00095       ImagePtr      m_image;
00096 };
00097 
00098 #endif // ENVIRONMENT_MAP_H_
00099 

Generated on 28 Feb 2009 for Milton by doxygen 1.5.6