📄 camera.h
字号:
} Lens *getLens() { return _lens.get(); } const Lens *getLens() const { return _lens.get(); } ////////////////////////////////////////////////////////////////////////////////////// /** Convenience method for setting the Lens Perspective. See Camera::Lens::setPerspective(). */ void setLensPerspective( double hfov, double vfov, double nearClip, double farClip, double xshear=0, double yshear=0 ) { _offset._xshear = xshear; _offset._yshear = yshear; _lens->setPerspective(hfov,vfov,nearClip,farClip); } /** Convenience method for setting the Lens Frustum. See Camera::Lens::setFrustum(). */ void setLensFrustum( double left, double right, double bottom, double top, double nearClip, double farClip, double xshear=0, double yshear=0 ) { _offset._xshear = xshear; _offset._yshear = yshear; _lens->setFrustum(left,right,bottom,top,nearClip, farClip); } /** Convenience method for setting the lens Orthographic projection. See Camera::Lens::setOrtho() */ void setLensOrtho( double left, double right, double bottom, double top, double nearClip, double farClip , double xshear=0, double yshear=0 ) { _offset._xshear = xshear; _offset._yshear = yshear; _lens->setOrtho( left, right, bottom, top, nearClip, farClip); } /** Convenience method for setting the lens shear. See Camera::Lens::setShear()*/ void setLensShear( double xshear, double yshear ) { _offset._xshear = xshear; _offset._yshear = yshear; } /** Convenience method for getting the lens shear. See Camera::Lens::getShear() */ void getLensShear( double &xshear, double &yshear ) { xshear = _offset._xshear; yshear = _offset._yshear; } /** Convenience method for converting the Perpective lens to an Orthographic lens. see Camera::lens:convertToOrtho() */ bool convertLensToOrtho( float d) { return _lens->convertToOrtho(d); } /** Convenience method for converting the Orthographic lens to an Perspective lens. see Camera::lens:convertToPerspective() */ bool convertLensToPerspective( float d) { return _lens->convertToPerspective(d); } /** Convenience method for getting the lens projection type. See Camera::Lens::setAspectRatio() */ Lens::Projection getLensProjectionType() { return _lens->getProjectionType(); } /** Convenience method for applying the lens. See Camera::Lens::apply() */ void applyLens() { _lens->apply(_offset._xshear, _offset._yshear); } /** Convenience method for getting the Lens parameters. See Camera::Lens::apply() */ void getLensParams( double &left, double &right, double &bottom, double &top, double &nearClip, double &farClip, double &xshear, double &yshear ) { _lens->getParams(left,right,bottom,top,nearClip,farClip ); xshear = _offset._xshear; yshear = _offset._yshear; } /** Convenience method for getting the Lens Horizontal field of view. See Camera::Lens::getHorizontalFov() */ float getLensHorizontalFov() { return _lens->getHorizontalFov(); } /** Convenience method for getting the Lens Horizontal field of view. See Camera::Lens::getVerticalFov() */ float getLensVerticalFov() { return _lens->getVerticalFov(); } /** Convenience method for setting the Lens ProjectionMatrix. See Camera::Lens::setMatrix() */ // DEPRECATE //void setLensMatrix( float mat[16] ) { _lens->setMatrix(mat); } /** Convenience method for getting the Lens ProjectionMatrix. See Camera::Lens::getMatrix() */ void getLensMatrix(osg::Matrix::value_type matrix[16] ) { _lens->generateMatrix(_offset._xshear, _offset._yshear, matrix ); } /** Convenience method for setting AutoAspect on the lens. See Camera::Lens::setAutoAspect() */ void setLensAutoAspect(bool ar) { _lens->setAutoAspect(ar); } /** Convenience method for getting AutoAspect on the lens. See Camera::Lens::getAutoAspect() */ bool getLensAutoAspect() { return _lens->getAutoAspect(); } /** Convenience method for setting the lens Aspect Ratio. See Camera::Lens::setAspectRatio() */ void setLensAspectRatio( double aspectRatio ) { _lens->setAspectRatio(aspectRatio); } double getLensAspectRatio() { return _lens->getAspectRatio(); } ////////////////////////////////////////////////////////////////////////////////////// void setProjectionRectangle( const float left, const float right, const float bottom, const float top ); void getProjectionRectangle( float &left, float &right, float &bottom, float &top ) const; void setProjectionRectangle( int x, int y, unsigned int width, unsigned int height ); void getProjectionRectangle( int &x, int &y, unsigned int &width, unsigned int &height ) const ; osg::Matrix::value_type *getProjectionMatrix () { _lens->generateMatrix(_offset._xshear, _offset._yshear, _projectionMatrix ); return _projectionMatrix; } void setViewByLookat( float eyex, float eyey, float eyez, float centerx, float centery, float centerz, float upx, float upy, float upz ); void setViewByLookat( const osg::Vec3 &eye, const osg::Vec3 ¢er, const osg::Vec3 &up ); void setViewByMatrix( const osg::Matrix &mat ); void setFocalDistance( double focal_distance ) { _focal_distance = focal_distance; } const osg::Matrix::value_type *getViewMatrix( void ) const; const osg::Matrix::value_type *getPositionAndAttitudeMatrix( void ) const { return _viewMatrix; } void applyView(); void setOffset( const osg::Matrix::value_type matrix[16], osg::Matrix::value_type _xshear=0.0, osg::Matrix::value_type _yshear=0.0); void setOffset( double _xshear, double _yshear); void setOffsetMultiplyMethod( Offset::MultiplyMethod method ) { _offset._multiplyMethod = method; } void setClearColor( float red, float green, float blue, float alpha); void getClearColor( float& red, float& green, float& blue, float& alpha); void clear( void ); void setIndex( unsigned int index ) { _index = index; } unsigned int getIndex() const { return _index; } void setShareLens( bool flag ) { _shareLens = flag; } bool getShareLens() { return _shareLens; } void setShareView( bool flag ) { _shareView = flag; } bool getShareView() { return _shareView; } protected : virtual ~Camera( void ); osg::ref_ptr<Lens> _lens; osg::ref_ptr<RenderSurface> _rs; unsigned int _index; private : bool _initialized; bool _initialize(void); bool _enabled; float _projrectLeft, _projrectRight, _projrectBottom, _projrectTop; Offset _offset; osg::Matrix::value_type _projectionMatrix[16]; osg::Matrix::value_type _viewMatrix[16]; float _clear_color[4]; double _focal_distance; friend class CameraGroup; bool _shareLens; bool _shareView;};}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -