Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

ilight.h

Go to the documentation of this file.
00001 /*
00002     toxic - A Global Illumination Renderer
00003     Copyright (C) 2003-2004 Francois Beaune
00004     Contact: http://toxicengine.sourceforge.net/
00005 
00006     This file is part of toxic.
00007 
00008     toxic is free software; you can redistribute it and/or modify
00009     it under the terms of the GNU General Public License as published by
00010     the Free Software Foundation; either version 2 of the License, or
00011     (at your option) any later version.
00012 
00013     toxic is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016     GNU General Public License for more details.
00017 
00018     You should have received a copy of the GNU General Public License
00019     along with toxic; if not, write to the Free Software
00020     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021 */
00022 
00023 #ifndef TOXIC_RENDERER_ILIGHT_H
00024 #define TOXIC_RENDERER_ILIGHT_H
00025 
00026 #include "common/math/bs.h"
00027 #include "common/math/point3.h"
00028 #include "common/math/vector3.h"
00029 #include "color3.h"
00030 #include "globals.h"
00031 #include "isurfacesampler.h"
00032 
00033 namespace toxic {
00034 
00035     class Context;
00036     class Ray;
00037     class Scene;
00038 
00039     class ILight {
00040     public:
00041         //! m is the object space to world space transformation matrix.
00042         ILight(bool cast_shadows = true);
00043 
00044         virtual ~ILight() {}
00045 
00046         //! This method returns true if the light casts shadows, false otherwise.
00047         bool CastShadows() const;
00048 
00049         //! Returns the emission power of this object, expressed in W.
00050         virtual const Color3 &GetPower() const = 0;
00051 
00052         virtual Ray GeneratePhotonRay(const Context &context) const = 0;
00053 
00054         struct IrradianceSample {
00055             Color3 m_irradiance;            //!< Differential irradiance, expressed in W.m^-2.
00056             sheep::Vector3 m_direction;     //!< Incoming direction, expressed in world space.
00057 
00058             IrradianceSample(const Color3 &irradiance, const sheep::Vector3 &direction) :
00059                 m_irradiance(irradiance),
00060                 m_direction(direction) {}
00061         };
00062 
00063         typedef std::vector<IrradianceSample> IrradianceSampleVector;
00064 
00065         //! Computes irradiance due to this light source. The point and the surface normal
00066         //! are both expressed in world space.
00067         virtual void ComputeIrradiance(
00068             const Context &context,
00069             const Scene *scene,
00070             const sheep::Point3 &point,
00071             const sheep::Vector3 &geometric_normal,
00072             const sheep::Vector3 &shading_normal,
00073             const ISurfaceSampler::SampleVector &input,
00074             IrradianceSampleVector *output
00075         ) const = 0;
00076 
00077     protected:
00078         bool m_cast_shadows;    //!< Does this light cast shadows?
00079     };
00080 
00081 #include "ilight.inl"
00082 
00083 }
00084 
00085 #endif  // !TOXIC_RENDERER_ILIGHT_H

Generated on Tue May 11 01:31:50 2004 for toxic by doxygen 1.3.6