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

sphere.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_SPHERE_H
00024 #define TOXIC_RENDERER_SPHERE_H
00025 
00026 #include "common/math/aabb3.h"
00027 #include "common/math/bs.h"
00028 #include "common/math/matrix4.h"
00029 #include "common/math/point2.h"
00030 #include "common/math/point3.h"
00031 #include "common/math/real.h"
00032 #include "common/math/vector3.h"
00033 #include "color3.h"
00034 #include "globals.h"
00035 #include "iarealight.h"
00036 #include "isurfacesampler.h"
00037 
00038 namespace toxic {
00039 
00040     class Context;
00041     class Hit;
00042     class ISurfaceShader;
00043     class Ray;
00044     class Scene;
00045 
00046     class Sphere : public IAreaLight {
00047     public:
00048         // The sphere has unit radius and is centered at the origin.
00049         // Surface normal is pointing outward (it goes away from the sphere center).
00050 
00051         //! m is the object space to world space transformation matrix.
00052         Sphere(
00053             const sheep::Matrix4 &m,
00054             const ISurfaceShader *surface_shader,
00055             IntersectionMask intersection_mask = INTERSECT_ALL_RAYS);
00056 
00057         //! Returns the Axis Aligned Bounding Box of this object. The AABB is
00058         //! expressed in world space.
00059         virtual const sheep::AABB3 &GetAABB() const;
00060 
00061         //! Computes the surface area of this object.
00062         virtual sheep::Real ComputeSurfaceArea() const;
00063 
00064         //! Given a point in the unit square (the set of points in [0..1]^2),
00065         //! this method computes the corresponding surface point and normal
00066         //! (both are expressed in world space).
00067         virtual void EvaluateSurface(
00068             const sheep::Point2 &input,
00069             sheep::Point3 *point,
00070             sheep::Vector3 *geometric_normal
00071         ) const;
00072 
00073         //! This method returns true if the ray intersect the object, or false otherwise.
00074         //! If 'hit' is not null, intersection data are reported through the 'hit' parameter
00075         //! (only if an intersection has been found; if no intersection has been found, the
00076         //! 'hit' parameter is left unchanged). The ray is expressed in world space.
00077         virtual bool Intersect(
00078             const Context &context,
00079             const Ray &ray,
00080             Hit *hit = 0
00081         ) const;
00082 
00083         //! Computes irradiance due to this light source. The point and the surface normal
00084         //! are both expressed in world space.
00085         virtual void ComputeIrradiance(
00086             const Context &context,
00087             const Scene *scene,
00088             const sheep::Point3 &point,
00089             const sheep::Vector3 &geometric_normal,
00090             const sheep::Vector3 &shading_normal,
00091             const ISurfaceSampler::SampleVector &input,
00092             IrradianceSampleVector *output
00093         ) const;
00094 
00095     private:
00096         sheep::Point3 m_center;             //!< Center of the object, expressed in world space.
00097         sheep::Vector3 m_ex, m_ey, m_ez;    //!< Basis vectors, expressed in world space.
00098         sheep::AABB3 m_aabb;                //!< Bounding box of the object, expressed in world space.
00099         sheep::BS m_bs;                     //!< Bounding sphere of the sphere, expressed in world space.
00100     };
00101 
00102 #include "sphere.inl"
00103 
00104 }
00105 
00106 #endif  // !TOXIC_RENDERER_SPHERE_H

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