Changeset 13041 for OpenSceneGraph/trunk/src/osgPlugins/cfg/Camera.h
 Timestamp:
 03/21/12 18:36:20 (2 years ago)
 Files:

 1 modified
Legend:
 Unmodified
 Added
 Removed

OpenSceneGraph/trunk/src/osgPlugins/cfg/Camera.h
r12292 r13041 30 30 /** 31 31 \class Camera 32 \brief A Camera provides a programming interface for 3D 33 graphics applications by means of an abstract camera analogy 34 35 The Camera contains a Lens class and has a RenderSurface. Methods 36 are provided to give the programmer control over the OpenGL PROJECTION 37 matrix throught the Lens and over the initial MODELVIEW matrix through 38 the camera's position and attitude. 32 \brief A Camera provides a programming interface for 3D 33 graphics applications by means of an abstract camera analogy 34 35 The Camera contains a Lens class and has a RenderSurface. Methods 36 are provided to give the programmer control over the OpenGL PROJECTION 37 matrix throught the Lens and over the initial MODELVIEW matrix through 38 the camera's position and attitude. 39 39 40 40 The programmer must provide a class derived from Camera::SceneHandler 41 to prepare and render the scene. The Camera does not provide direct 42 control over rendering itself. 41 to prepare and render the scene. The Camera does not provide direct 42 control over rendering itself. 43 43 */ 44 44 45 45 46 46 … … 49 49 50 50 public : 51 /** 51 /** 52 52 \class SceneHandler 53 53 \brief A Scene Handler handles the preparation and rendering … … 55 55 */ 56 56 57 /** 57 /** 58 58 \class Lens 59 59 \brief A Lens provides control over the PROJECTION matrix. 60 60 61 It is entirely contained within the Camera class. A Lens may 62 be of type Perspective or Orthographic and set with one of the 63 setFrustum, setProjection() or setOrtho(). The Lens type is 64 implied by the method used to set it */ 65 class Lens : public osg::Referenced 61 It is entirely contained within the Camera class. A Lens may 62 be of type Perspective or Orthographic and set with one of the 63 setFrustum, setProjection() or setOrtho(). The Lens type is 64 implied by the method used to set it */ 65 class Lens : public osg::Referenced 66 66 { 67 67 public : … … 84 84 hfov  Horizontal Field of View in degrees 85 85 vfov  Vertical Field of View in degrees 86 nearClip  Distance from the viewer to the near plane of the 86 nearClip  Distance from the viewer to the near plane of the 87 87 viewing frustum. 88 farClip  Distance from the viewer to the far plane of the 88 farClip  Distance from the viewer to the far plane of the 89 89 viewing frustum. 90 xshear Assymetrical shear in viewing frustum in the horizontal 91 direction. Value given in normalized device coordinates 90 xshear Assymetrical shear in viewing frustum in the horizontal 91 direction. Value given in normalized device coordinates 92 92 (see setShear() below). 93 yshear Assymetrical shear in viewing frustum in the vertical 94 direction. Value given in normalized device coordinates 93 yshear Assymetrical shear in viewing frustum in the vertical 94 direction. Value given in normalized device coordinates 95 95 (see setShear() below). 96 96 */ 97 void setPerspective( double hfov, double vfov, 97 void setPerspective( double hfov, double vfov, 98 98 double nearClip, double farClip ); 99 99 … … 101 101 the dimensions of the left, right, bottom, top, nearClip and farClip 102 102 extents of the viewing frustum as indicated. 103 xshear Assymetrical shear in viewing frustum in the horizontal 104 direction. Value given in normalized device coordinates 103 xshear Assymetrical shear in viewing frustum in the horizontal 104 direction. Value given in normalized device coordinates 105 105 (see setShear() below). 106 yshear Assymetrical shear in viewing frustum in the vertical 107 direction. Value given in normalized device coordinates 106 yshear Assymetrical shear in viewing frustum in the vertical 107 direction. Value given in normalized device coordinates 108 108 (see setShear() below). 109 109 */ 110 void setFrustum( double left, double right, 111 double bottom, double top, 110 void setFrustum( double left, double right, 111 double bottom, double top, 112 112 double nearClip, double farClip ); 113 113 114 114 /** Set the Projection type to be of Orthographic and provide 115 115 the left, right, bottom dimensions of the 2D rectangle*/ 116 void setOrtho( double left, double right, 117 double bottom, double top, 116 void setOrtho( double left, double right, 117 double bottom, double top, 118 118 double nearClip, double farClip ); 119 119 120 /** convertToOrtho() converts the current perspective view to an 121 orthographic view with dimensions that conserve the scale of the 122 objects at distance d. 123 convertToPerspective() converts the current orthographic view 120 /** convertToOrtho() converts the current perspective view to an 121 orthographic view with dimensions that conserve the scale of the 122 objects at distance d. 123 convertToPerspective() converts the current orthographic view 124 124 to a perspective view with parameters that conserve the scale of 125 125 objects at distance d. */ … … 155 155 156 156 private : 157 157 158 158 double _ortho_left, _ortho_right, _ortho_bottom, _ortho_top; 159 159 double _left, _right, _bottom, _top, _nearClip, _farClip; … … 194 194 { _rs>setWindowRectangle(x,y,width,height, resize); } 195 195 196 void setLens( Lens *lens ) 197 { 196 void setLens( Lens *lens ) 197 { 198 198 if( _lens.get() != lens ) 199 _lens = lens; 199 _lens = lens; 200 200 } 201 201 … … 206 206 /** Convenience method for setting the Lens Perspective. 207 207 See Camera::Lens::setPerspective(). */ 208 void setLensPerspective( double hfov, double vfov, 208 void setLensPerspective( double hfov, double vfov, 209 209 double nearClip, double farClip, 210 210 double xshear=0, double yshear=0 ) 211 { 211 { 212 212 _offset._xshear = xshear; 213 213 _offset._yshear = yshear; … … 217 217 /** Convenience method for setting the Lens Frustum. 218 218 See Camera::Lens::setFrustum(). */ 219 void setLensFrustum( double left, double right, 220 double bottom, double top, 219 void setLensFrustum( double left, double right, 220 double bottom, double top, 221 221 double nearClip, double farClip, 222 222 double xshear=0, double yshear=0 ) 223 { 223 { 224 224 _offset._xshear = xshear; 225 225 _offset._yshear = yshear; 226 _lens>setFrustum(left,right,bottom,top,nearClip, farClip); 226 _lens>setFrustum(left,right,bottom,top,nearClip, farClip); 227 227 } 228 228 229 229 /** Convenience method for setting the lens Orthographic projection. 230 See Camera::Lens::setOrtho() */ 231 void setLensOrtho( double left, double right, 232 double bottom, double top, 230 See Camera::Lens::setOrtho() */ 231 void setLensOrtho( double left, double right, 232 double bottom, double top, 233 233 double nearClip, double farClip , 234 234 double xshear=0, double yshear=0 ) 235 { 235 { 236 236 _offset._xshear = xshear; 237 237 _offset._yshear = yshear; 238 _lens>setOrtho( left, right, bottom, top, nearClip, farClip); 238 _lens>setOrtho( left, right, bottom, top, nearClip, farClip); 239 239 } 240 240 241 241 /** Convenience method for setting the lens shear. See Camera::Lens::setShear()*/ 242 242 void setLensShear( double xshear, double yshear ) 243 { 243 { 244 244 _offset._xshear = xshear; 245 245 _offset._yshear = yshear; … … 248 248 /** Convenience method for getting the lens shear. See Camera::Lens::getShear() */ 249 249 void getLensShear( double &xshear, double &yshear ) 250 { 250 { 251 251 xshear = _offset._xshear; 252 252 yshear = _offset._yshear; 253 253 } 254 254 255 /** Convenience method for converting the Perpective lens to an 255 /** Convenience method for converting the Perpective lens to an 256 256 Orthographic lens. see Camera::lens:convertToOrtho() */ 257 257 bool convertLensToOrtho( float d) { return _lens>convertToOrtho(d); } 258 258 259 /** Convenience method for converting the Orthographic lens to an 259 /** Convenience method for converting the Orthographic lens to an 260 260 Perspective lens. see Camera::lens:convertToPerspective() */ 261 261 bool convertLensToPerspective( float d) { return _lens>convertToPerspective(d); } … … 268 268 void applyLens() { _lens>apply(_offset._xshear, _offset._yshear); } 269 269 270 /** Convenience method for getting the Lens parameters. 270 /** Convenience method for getting the Lens parameters. 271 271 See Camera::Lens::apply() */ 272 272 void getLensParams( double &left, double &right, double &bottom, double &top, … … 278 278 } 279 279 280 /** Convenience method for getting the Lens Horizontal field of view. 280 /** Convenience method for getting the Lens Horizontal field of view. 281 281 See Camera::Lens::getHorizontalFov() */ 282 282 float getLensHorizontalFov() { return _lens>getHorizontalFov(); } 283 283 284 /** Convenience method for getting the Lens Horizontal field of view. 284 /** Convenience method for getting the Lens Horizontal field of view. 285 285 See Camera::Lens::getVerticalFov() */ 286 286 float getLensVerticalFov() { return _lens>getVerticalFov(); } … … 294 294 See Camera::Lens::getMatrix() */ 295 295 void getLensMatrix(osg::Matrix::value_type matrix[16] ) 296 { 296 { 297 297 _lens>generateMatrix(_offset._xshear, _offset._yshear, matrix ); 298 298 } … … 322 322 void getProjectionRectangle( int &x, int &y, unsigned int &width, unsigned int &height ) const ; 323 323 324 osg::Matrix::value_type *getProjectionMatrix () 325 { 326 _lens>generateMatrix(_offset._xshear, _offset._yshear, _projectionMatrix ); 324 osg::Matrix::value_type *getProjectionMatrix () 325 { 326 _lens>generateMatrix(_offset._xshear, _offset._yshear, _projectionMatrix ); 327 327 return _projectionMatrix; 328 328 } … … 338 338 void applyView(); 339 339 340 void setOffset( const osg::Matrix::value_type matrix[16], 341 osg::Matrix::value_type _xshear=0.0, 342 osg::Matrix::value_type _yshear=0.0); 343 void setOffset( double _xshear, double _yshear); 340 void setOffset( const osg::Matrix::value_type matrix[16], 341 osg::Matrix::value_type _xshear=0.0, 342 osg::Matrix::value_type _yshear=0.0); 343 void setOffset( double _xshear, double _yshear); 344 344 void setOffsetMultiplyMethod( Offset::MultiplyMethod method ) 345 345 { … … 350 350 void setClearColor( float red, float green, float blue, float alpha); 351 351 void getClearColor( float& red, float& green, float& blue, float& alpha); 352 352 353 353 void clear( void ); 354 354 355 355 void setIndex( unsigned int index ) { _index = index; } 356 356 unsigned int getIndex() const { return _index; }