Camera.h

Go to the documentation of this file.
00001 /**<!-------------------------------------------------------------------->
00002    @class  Camera
00003    @author Matthew Jacobs (jacobs.mh@gmail.com)
00004    @author Travis Fischer (fisch0920@gmail.com)
00005    @date   Fall 2008
00006    
00007    @brief
00008       Abstract camera that all Milton cameras subclass, representing a 
00009    mapping from film-space to world-space and vice-versa. Cameras may 
00010    optionally also specify an OpenGL preview projection matrix that can be 
00011    used by OpenGLRenderer.
00012       Film-space is represented by (slightly modified) Normalized Device 
00013    Coordinates (NDC), which are unit film-plane coordinates, with (x,y) both 
00014    ranging inbetween 0 and 1. NDC lie in the unit square [0,1]^2, where [0,0] 
00015    gets mapped to the upper left corner of the corresponding Viewport/Image, 
00016    and [1,1] is the lower right corner. NDC film-space allows for mapping 
00017    rendering results onto an arbitrarily-sized Viewport/Image.
00018    
00019    @see ThinLensCamera
00020    <!-------------------------------------------------------------------->**/
00021 
00022 #ifndef CAMERA_H_
00023 #define CAMERA_H_
00024 
00025 #include <utils/PropertyMap.h>
00026 #include <shapes/Shape.h>
00027 #include <core/Ray.h>
00028 
00029 class Viewport;
00030 class Scene;
00031 
00032 class Camera : public Shape, public PropertyMap {
00033    public:
00034       ///@name Constructors
00035       //@{-----------------------------------------------------------------
00036       
00037       inline   Camera()
00038          : Shape(), PropertyMap()
00039       { }
00040       
00041       virtual ~Camera()
00042       { }
00043       
00044       
00045       //@}-----------------------------------------------------------------
00046       ///@name Initialization
00047       //@{-----------------------------------------------------------------
00048       
00049       /// Initializes camera state from its PropertyMap
00050       virtual void init(Scene *scene) = 0;
00051       
00052       
00053       //@}-----------------------------------------------------------------
00054       ///@name Main usage interface
00055       //@{-----------------------------------------------------------------
00056       
00057       /**
00058        * @returns a world-space ray for the given point on image plane
00059        * @param pt is a point on the film plane expressed in NDC ([0,1]^2)
00060        */
00061       virtual Ray getWorldRay(const Point2 &pt) const = 0;
00062       
00063       /**
00064        * @returns the projection of the given world-space point onto the film-
00065        *    plane (result is expressed in NDC  ([0,1]^2))
00066        */
00067       virtual Point2 getProjection(const Point3 &p) const = 0;
00068       
00069       /**
00070        * @returns the projection of the given world-space point onto the film-
00071        *    plane (result is expressed in pixel coordinates on the specified
00072        *    Viewport @p v)
00073        */
00074       virtual Point2 getProjection(const Point3 &p, const Viewport &v) const;
00075       
00076       /**
00077        * @brief
00078        *    Fills the 16-element, column-major buffer with an OpenGL projection
00079        * matrix to preview the transformation of points from world-space to 
00080        * NDC using this camera model
00081        */
00082       virtual void fillGLMatrix(real_t *buffer) = 0;
00083        
00084       
00085       //@}-----------------------------------------------------------------
00086       ///@name Accessors / Mutators
00087       //@{-----------------------------------------------------------------
00088       
00089       virtual void setOrientation(const Point3  &eye, 
00090                                   const Vector3 &look, 
00091                                   const Vector3 &up) = 0;
00092       
00093       
00094       //@}-----------------------------------------------------------------
00095       ///@name Sampling functionality
00096       //@{-----------------------------------------------------------------
00097       
00098       /**
00099        * @returns the point on the surface of this Camera corresponding to the 
00100        *    given UV coordinates
00101        */
00102       virtual Point3 getPosition(const UV &uv);
00103       
00104       
00105       //@}-----------------------------------------------------------------
00106       
00107    protected:
00108       virtual void _getUV(SurfacePoint &pt) const;
00109       virtual void _getGeometricNormal(SurfacePoint &pt) const;
00110 };
00111 
00112 #endif // CAMERA_H_
00113 

Generated on 28 Feb 2009 for Milton by doxygen 1.5.6