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

ring.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_RING_H
00024 #define TOXIC_RENDERER_RING_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 
00036 namespace toxic {
00037 
00038     class Context;
00039     class Hit;
00040     class ISurfaceShader;
00041     class Ray;
00042     class Scene;
00043 
00044     class Ring : public IAreaLight {
00045     public:
00046         // The ring has unit outer radius, custom inner radius and unit height (ring base
00047         // is at y=-0.5, ring top is at y=+0.5). The ring is centered at the origin and
00048         // its axis is directed along Y. Surface normal is pointing outward (it goes away
00049         // from the ring surface).
00050 
00051         //! m is the object space to world space transformation matrix.
00052         Ring(
00053             const sheep::Matrix4 &m,
00054             const ISurfaceShader *surface_shader,
00055             sheep::Real inner_radius,   //!< The inner radius of the ring, in [0..1).
00056             IntersectionMask intersection_mask = INTERSECT_ALL_RAYS);
00057 
00058         //! Returns the Axis Aligned Bounding Box of this object. The AABB is
00059         //! expressed in world space.
00060         virtual const sheep::AABB3 &GetAABB() const;
00061 
00062         //! Computes the surface area of this object.
00063         virtual sheep::Real ComputeSurfaceArea() const;
00064 
00065         //! Given a point in the unit square (the set of points in [0..1]^2),
00066         //! this method computes the corresponding surface point and normal
00067         //! (both are expressed in world space).
00068         virtual void EvaluateSurface(
00069             const sheep::Point2 &input,
00070             sheep::Point3 *point,
00071             sheep::Vector3 *geometric_normal
00072         ) const;
00073 
00074         //! This method returns true if the ray intersect the object, or false otherwise.
00075         //! If 'hit' is not null, intersection data are reported through the 'hit' parameter
00076         //! (only if an intersection has been found; if no intersection has been found, the
00077         //! 'hit' parameter is left unchanged). The ray is expressed in world space.
00078         virtual bool Intersect(
00079             const Context &context,
00080             const Ray &ray,
00081             Hit *hit = 0
00082         ) const;
00083 
00084     private:
00085         sheep::Real m_inner_radius2;        //!< Square of the ring's inner radius.
00086         sheep::Point3 m_center;             //!< Center of the object, expressed in world space.
00087         sheep::Vector3 m_ex, m_ey, m_ez;    //!< Basis vectors, expressed in world space.
00088         sheep::AABB3 m_aabb;                //!< Bounding box of the object, expressed in world space.
00089     };
00090 
00091 #include "ring.inl"
00092 
00093 }
00094 
00095 #endif  // !TOXIC_RENDERER_RING_H

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