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_ICAMERA_H 00024 #define TOXIC_RENDERER_ICAMERA_H 00025 00026 #include "common/math/matrix4.h" 00027 #include "common/math/point2.h" 00028 #include "common/math/point3.h" 00029 #include "common/math/real.h" 00030 #include "common/math/vector3.h" 00031 #include "basis.h" 00032 #include "globals.h" 00033 00034 namespace toxic { 00035 00036 class Context; 00037 class Ray; 00038 class Scene; 00039 00040 //! Normalized Device Coordinates (NDC) are normalized pixel coordinates so 00041 //! that x and y both run from -0.5 to +0.5 across the entire (uncropped) 00042 //! image, with (-0.5, -0.5) being at the lower left corner of the image plane 00043 //! and (0.5, 0.5) being at the upper right corner, regardless of the image 00044 //! resolution. 00045 00046 //! The camera is located at the origin and looks toward Z-. 00047 class ICamera : public Basis { 00048 public: 00049 //! 'm' is the object space to world space transformation matrix. 00050 //! 'hfov' is the horizontal field of view, expressed in radians. 00051 ICamera( 00052 const sheep::Matrix4 &m, 00053 sheep::Real hfov, 00054 sheep::Real aspect_ratio 00055 ); 00056 00057 virtual ~ICamera() {} 00058 00059 //! This method must be called only once, after the camera is completely 00060 //! configured, and before it is used for the first time. 00061 virtual void Finalize( 00062 const Context &context, 00063 const Scene *scene 00064 ) {} 00065 00066 //! Returns a ray whose origin is at camera location, and which 00067 //! is directed toward the point 'p'. 'p' is a point on the film 00068 //! plane. It is expressed in NDC. The returned ray is expressed 00069 //! in world space. The direction of the returned ray IS unit-length. 00070 virtual Ray ComputeRay( 00071 const Context &context, 00072 const sheep::Point2 &p 00073 ) const = 0; 00074 00075 //! Projects a point in the scene to the image plane. 00076 virtual sheep::Point2 Project( 00077 const sheep::Point3 &p 00078 ) const = 0; 00079 00080 protected: 00081 sheep::Point3 m_location; //!< Location of the camera, expressed in world space. 00082 sheep::Vector3 m_ex, m_ey, m_ez; //!< Basis vectors, expressed in world space. m_ex is scaled by the aspect ratio. 00083 sheep::Vector3 m_u, m_w; //!< m_u = m_ex * m_aspect_ratio, m_w = m_ez * (-m_focal_length). 00084 00085 //! Frustum parameters. 00086 sheep::Real m_hfov; //!< User defined horizontal field of view, expressed in radians. 00087 sheep::Real m_aspect_ratio; //!< User defined aspect ratio. 00088 sheep::Real m_focal_length; //!< Lens focal length (computed from m_hfov and m_aspect_ratio values). 00089 }; 00090 00091 #include "icamera.inl" 00092 00093 } 00094 00095 #endif // !TOXIC_RENDERER_ICAMERA_H
1.3.6