ThinLensCamera.h

Go to the documentation of this file.
00001 /**<!-------------------------------------------------------------------->
00002    @class  ThinLensCamera
00003    @author Travis Fischer (fisch0920@gmail.com)
00004    @date   January 2008
00005    
00006    @brief
00007       Thin lens camera approximation supporting common camera inputs and 
00008    allowing for depth of field
00009    
00010    @param
00011       aperture - diameter of the aperature of the lens in mm (eg. 35mm, 50mm)
00012    @param
00013       fstop    - (aka F number), is defined as the unitless ratio of the focal 
00014                  length to the diameter of the aperture of the lens
00015    @param
00016       focalDistance - the distance in meters between the lens and the focal 
00017                       plane (objects lying on the focal plane will be in 
00018                       perfect focus)
00019    @param
00020       focalPoint    - (optional) user may specify a focalPoint in NDC on the 
00021                       film-plane instead of specifying a focalDistance to 
00022                       "auto-focus" the object intersected by a ray traced 
00023                       through the corresponding pixel, whose distance away 
00024                       from the lens will be used as the focalDistance.
00025                       @note focalPoint is expressed as a vector2 in the unit 
00026                       square [0,1]^2, where [0,0] is the upper left corner 
00027                       of the image, and [1,1] is the lower right corner
00028    
00029    (focal length is derived from fstop and aperture)
00030    
00031    @see http://www.eecs.berkeley.edu/~barsky/VisRendPapers/survey1.pdf
00032    <!-------------------------------------------------------------------->**/
00033 
00034 #ifndef THIN_LENS_CAMERA_H_
00035 #define THIN_LENS_CAMERA_H_
00036 
00037 #include "cameras/Camera.h"
00038 
00039 class ThinLensCamera : public Camera {
00040    public:
00041       ///@name Constructors
00042       //@{-----------------------------------------------------------------
00043       
00044       ThinLensCamera();
00045       virtual ~ThinLensCamera();
00046       
00047       
00048       //@}-----------------------------------------------------------------
00049       ///@name Initialization
00050       //@{-----------------------------------------------------------------
00051       
00052       virtual void init(Scene *scene);
00053       
00054       
00055       //@}-----------------------------------------------------------------
00056       ///@name Main usage interface
00057       //@{-----------------------------------------------------------------
00058       
00059       virtual Ray    getWorldRay(const Point2 &pt) const;
00060       
00061       virtual Point2 getProjection(const Point3 &p) const;
00062       
00063       virtual real_t getIntersection(const Ray &ray, SurfacePoint &pt);
00064       
00065       virtual void   fillGLMatrix(real_t *buffer);
00066       
00067       
00068       //@}-----------------------------------------------------------------
00069       ///@name Accessors / Mutators
00070       //@{-----------------------------------------------------------------
00071       
00072       virtual void setOrientation(const Point3  &eye,
00073                                   const Vector3 &look, 
00074                                   const Vector3 &up);
00075       
00076       inline Point3 getEye() const {
00077          return m_eye;
00078       }
00079       
00080       inline Vector3 getUp() const {
00081          return m_v;
00082       }
00083       
00084       inline Vector3 getLook() const {
00085          return -m_n;
00086       }
00087       
00088       inline Vector3 getU() const {
00089          return m_u;
00090       }
00091       
00092       inline Vector3 getV() const {
00093          return m_v;
00094       }
00095       
00096       inline Vector3 getN() const {
00097          return m_n;
00098       }
00099       
00100       
00101       //@}-----------------------------------------------------------------
00102       
00103    protected:
00104       void _computeMatrix();
00105       
00106    protected:
00107       Matrix4x4     m_filmToWorld;
00108       Matrix4x4     m_worldToFilm;
00109       
00110       /// Position
00111       Point3        m_eye;
00112       
00113       /// Camera's internal right-handed coordinate system
00114       Vector3       m_u, m_v, m_n;
00115       
00116       /// Clipping planes
00117       real_t        m_near, m_far;
00118       
00119       /// View volume parameters
00120       real_t        m_aspect;
00121       real_t        m_hAngle;
00122       
00123       /// Aperture diameter (input in mm; stored internally in meters)
00124       real_t        m_aperture;
00125       
00126       /// F-stop or F-number; unitless
00127       real_t        m_fstop;
00128       
00129       /// Focal length in meters
00130       real_t        m_focalLength;
00131       
00132       /// Focal distance in meters
00133       real_t        m_focalDistance;
00134 };
00135 
00136 #endif // THIN_LENS_CAMERA_H_
00137 

Generated on 28 Feb 2009 for Milton by doxygen 1.5.6