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_THINLENSCAMERA_H 00024 #define TOXIC_RENDERER_THINLENSCAMERA_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 "globals.h" 00032 #include "icamera.h" 00033 00034 namespace toxic { 00035 00036 class Context; 00037 class Ray; 00038 class Scene; 00039 00040 class ThinLensCamera : public ICamera { 00041 public: 00042 //! 'm' is the object space to world space transformation matrix. 00043 //! 'hfov' is the horizontal field of view, expressed in radians. 00044 ThinLensCamera( 00045 const sheep::Matrix4 &m, 00046 sheep::Real hfov, 00047 sheep::Real aspect_ratio, 00048 sheep::Real fstop, 00049 sheep::Real focal_length, 00050 sheep::Real focal_distance 00051 ); 00052 00053 //! This constructor intializes the focal distance with the autofocus 00054 //! mechanism. Autofocus computes the right focal distance so that the 00055 //! point of the scene visible through the point 'target' is in focus 00056 //! plane. 'target' is a point on the film plane, expressed in NDC. 00057 //! 'm' is the object space to world space transformation matrix. 00058 //! 'hfov' is the horizontal field of view, expressed in radians. 00059 ThinLensCamera( 00060 const sheep::Matrix4 &m, 00061 sheep::Real hfov, 00062 sheep::Real aspect_ratio, 00063 sheep::Real fstop, 00064 sheep::Real focal_length, 00065 const sheep::Point2 &af_target 00066 ); 00067 00068 //! This method must be called only once, after the camera is completely 00069 //! configured, and before it is used for the first time. 00070 virtual void Finalize( 00071 const Context &context, 00072 const Scene *scene 00073 ); 00074 00075 //! Returns a ray whose origin is at camera location, and which 00076 //! is directed toward the point 'p'. 'p' is a point on the film 00077 //! plane. It is expressed in NDC. The returned ray is expressed 00078 //! in world space. The direction of the returned ray IS unit-length. 00079 virtual Ray ComputeRay( 00080 const Context &context, 00081 const sheep::Point2 &p 00082 ) const; 00083 00084 //! Projects a point in the scene to the image plane. 00085 virtual sheep::Point2 Project( 00086 const sheep::Point3 &p 00087 ) const; 00088 00089 private: 00090 sheep::Real m_lens_radius; //!< Lens radius (computed user defined f-stop number and DOF focal length). 00091 sheep::Real m_focal_distance; //!< User defined distance of the focus plane from the lens center. 00092 bool m_af_enabled; //!< True if autofocus is enabled, false otherwise. 00093 sheep::Point2 m_af_target; //!< Focus point, expressed in NDC. 00094 }; 00095 00096 #include "thinlenscamera.inl" 00097 00098 } 00099 00100 #endif // !TOXIC_RENDERER_THINLENSCAMERA_H
1.3.6