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_SQUARE_H 00024 #define TOXIC_RENDERER_SQUARE_H 00025 00026 #include "common/math/aabb3.h" 00027 #include "common/math/matrix4.h" 00028 #include "common/math/point2.h" 00029 #include "common/math/point3.h" 00030 #include "common/math/real.h" 00031 #include "common/math/vector3.h" 00032 #include "color3.h" 00033 #include "globals.h" 00034 #include "iarealight.h" 00035 #include "surfacebasis.h" 00036 00037 #include <cassert> 00038 00039 namespace toxic { 00040 00041 class Context; 00042 class Hit; 00043 class ISurfaceShader; 00044 class Ray; 00045 class Scene; 00046 00047 class Square : public IAreaLight { 00048 public: 00049 // The square is contained in the XZ plane and extends from (-0.5, 0, -0.5) to (0.5, 0, 0.5) 00050 // (borders are included). Surface normal is pointing toward Y+ (it goes away from the square 00051 // plane toward increasing Y). 00052 00053 //! m is the object space to world space transformation matrix. 00054 Square( 00055 const sheep::Matrix4 &m, 00056 const ISurfaceShader *surface_shader, 00057 IntersectionMask intersection_mask = INTERSECT_ALL_RAYS); 00058 00059 //! Returns the Axis Aligned Bounding Box of this object. The AABB is 00060 //! expressed in world space. 00061 virtual const sheep::AABB3 &GetAABB() const; 00062 00063 //! Computes the surface area of this object. 00064 virtual sheep::Real ComputeSurfaceArea() const; 00065 00066 //! Given a point in the unit square (the set of points in [0..1]^2), 00067 //! this method computes the corresponding surface point and normal 00068 //! (both are expressed in world space). 00069 virtual void EvaluateSurface( 00070 const sheep::Point2 &input, 00071 sheep::Point3 *point, 00072 sheep::Vector3 *geometric_normal 00073 ) const; 00074 00075 //! This method returns true if the ray intersect the object, or false otherwise. 00076 //! If 'hit' is not null, intersection data are reported through the 'hit' parameter 00077 //! (only if an intersection has been found; if no intersection has been found, the 00078 //! 'hit' parameter is left unchanged). The ray is expressed in world space. 00079 virtual bool Intersect( 00080 const Context &context, 00081 const Ray &ray, 00082 Hit *hit = 0 00083 ) const; 00084 00085 private: 00086 sheep::Point3 m_center; //!< Center of the object, expressed in world space. 00087 sheep::Vector3 m_normal; //!< Normal to the plane supporting the square, expressed in world space. 00088 const SurfaceBasis m_basis; 00089 sheep::Vector3 m_ex, m_ez; //!< X (1,0,0) and Z (0,0,1) basis vectors, expressed in world space. 00090 sheep::AABB3 m_aabb; //!< Bounding box of the object, expressed in world space. 00091 }; 00092 00093 #include "square.inl" 00094 00095 } 00096 00097 #endif // !TOXIC_RENDERER_SQUARE_H
1.3.6