⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cameraconfig.cpp

📁 最新osg包
💻 CPP
📖 第 1 页 / 共 2 页
字号:
        _current_camera->setRenderSurface( rs );}void CameraConfig::setCameraRenderSurface( void ){    if( _current_camera != NULL && _current_render_surface != NULL )        _current_camera->setRenderSurface( _current_render_surface.get() );}void CameraConfig::setCameraProjectionRectangle( float x0, float x1, float y0, float y1 ){    if( _current_camera != NULL )        _current_camera->setProjectionRectangle( x0, x1, y0, y1 );}void CameraConfig::setCameraProjectionRectangle( int x0, int x1, int y0, int y1 ){    if( _current_camera != NULL )        _current_camera->setProjectionRectangle( x0, x1, y0, y1 );}void CameraConfig::setCameraOrtho( float left, float right, float bottom, float top, float nearClip, float farClip,                        float xshear, float yshear ){    if( _current_camera != NULL )        _current_camera->setLensOrtho( left, right, bottom, top, nearClip, farClip, xshear, yshear );}void CameraConfig::setCameraPerspective( float hfov, float vfov, float nearClip, float farClip,                        float xshear, float yshear ){    if( _current_camera != 0 )        _current_camera->setLensPerspective( hfov, vfov, nearClip, farClip, xshear, yshear );}void CameraConfig::setCameraFrustum( float left, float right, float bottom, float top, float nearClip, float farClip,                        float xshear, float yshear ){    if( _current_camera != 0 )        _current_camera->setLensFrustum( left, right, bottom, top, nearClip, farClip, xshear, yshear );}void CameraConfig::setCameraLensShear( osg::Matrix::value_type xshear, osg::Matrix::value_type yshear ){    if( _current_camera != NULL )        _current_camera->setLensShear(xshear,yshear);}void CameraConfig::setCameraShareLens( bool shared ){    if( _current_camera != NULL )        _current_camera->setShareLens( shared );}void CameraConfig::setCameraShareView( bool shared ){    if( _current_camera != NULL )        _current_camera->setShareView( shared );}void CameraConfig::setCameraClearColor( float r, float g, float b, float a ){    if( _current_camera != NULL )        _current_camera->setClearColor( r, g, b, a );}void CameraConfig::beginCameraOffset(){  osg::Matrix::value_type id[] = {        1, 0, 0, 0,        0, 1, 0, 0,        0, 0, 1, 0,        0, 0, 0, 1        };  memcpy( _offset_matrix, id, sizeof(osg::Matrix::value_type[16]));    _offset_shearx = _offset_sheary = 0.0;}void CameraConfig::shearCameraOffset( osg::Matrix::value_type shearx, osg::Matrix::value_type sheary ){    _offset_shearx = shearx;    _offset_sheary = sheary;}void CameraConfig::setCameraOffsetMultiplyMethod( Camera::Offset::MultiplyMethod method ){    if( _current_camera != NULL )        _current_camera->setOffsetMultiplyMethod(method);}void CameraConfig::endCameraOffset(){    if( _current_camera != NULL )        _current_camera->setOffset( _offset_matrix, _offset_shearx, _offset_sheary);}void  CameraConfig::endCamera( void ){    _can_add_camera_attributes = false;}Camera *CameraConfig::findCamera( const char *name ){    std::map<std::string,  osg::ref_ptr<Camera> >::iterator p;    p = _camera_map.find( std::string(name) );    if( p == _camera_map.end() )        return NULL;    else        return (*p).second.get();}unsigned int CameraConfig::getNumberOfCameras() const{    return _camera_map.size();}const Camera *CameraConfig::getCamera( unsigned int n ) const{    if( n >= _camera_map.size() )             return NULL;    unsigned int i;    std::map <std::string,  osg::ref_ptr<Camera> >::const_iterator p;    for( i = 0, p = _camera_map.begin(); p != _camera_map.end(); p++ )        if( i++ == n )                 break;    if(  p == _camera_map.end() )            return NULL;    return p->second.get();}Camera *CameraConfig::getCamera( unsigned int n ){    if( n >= _camera_map.size() )             return NULL;    unsigned int i;    std::map <std::string,  osg::ref_ptr<Camera> >::iterator p;    for( i = 0, p = _camera_map.begin(); p != _camera_map.end(); p++ )        if( i++ == n )                 break;    if(  p == _camera_map.end() )            return NULL;    return p->second.get();}void CameraConfig::beginInputArea(){    _input_area = new InputArea;    _can_add_input_area_entries = true;}void CameraConfig::addInputAreaEntry( char *renderSurfaceName ){        osgProducer::RenderSurface *rs = findRenderSurface( renderSurfaceName );    if( rs == NULL )    {        std::cerr << "setInputAreaEntry(): No Render Surface by name of \"" << renderSurfaceName << "\" was found!\n";        return;    }    if( _input_area != NULL && _can_add_input_area_entries == true )        _input_area->addRenderSurface( rs );}void CameraConfig::endInputArea() {    _can_add_input_area_entries = false;}void CameraConfig::setInputArea(InputArea *ia) {     _input_area=ia; }InputArea *CameraConfig::getInputArea() {     return _input_area.get(); }const InputArea *CameraConfig::getInputArea() const {     return _input_area.get(); }#if 0void CameraConfig::realize( void ){    std::map <std::string,  osg::ref_ptr<RenderSurface> >::iterator p;    for( p = _render_surface_map.begin(); p != _render_surface_map.end(); p++ )    {        ((*p).second)->realize();    }}#endifstd::string findFile( std::string );void CameraConfig::addStereoSystemCommand( int screen, std::string stereoCmd, std::string monoCmd ){    _stereoSystemCommands.push_back(StereoSystemCommand( screen, stereoCmd, monoCmd ));}const std::vector<CameraConfig::StereoSystemCommand> &CameraConfig::getStereoSystemCommands() {     return _stereoSystemCommands; }CameraConfig::~CameraConfig() {}//////////////////////void CameraConfig::rotateCameraOffset( osg::Matrix::value_type deg, osg::Matrix::value_type x, osg::Matrix::value_type y, osg::Matrix::value_type z ){  osg::Matrix m;  m.invert(osg::Matrix::rotate( osg::DegreesToRadians(deg), x,y,z));   m = m * osg::Matrix(_offset_matrix);    memcpy( _offset_matrix, m.ptr(), sizeof( osg::Matrix::value_type[16] ));}void CameraConfig::translateCameraOffset( osg::Matrix::value_type x, osg::Matrix::value_type y, osg::Matrix::value_type z ){  osg::Matrix m;    m.invert(osg::Matrix::translate( x,y,z));     m = m * osg::Matrix(_offset_matrix);    memcpy( _offset_matrix, m.ptr(), sizeof( osg::Matrix::value_type[16] ));}void CameraConfig::scaleCameraOffset( osg::Matrix::value_type x, osg::Matrix::value_type y, osg::Matrix::value_type z ){  osg::Matrix m = osg::Matrix::scale( x,y,z) * osg::Matrix(_offset_matrix);  memcpy( _offset_matrix, m.ptr(), sizeof( osg::Matrix::value_type[16] ));}// Order of precedence://std::string CameraConfig::findFile( std::string filename ){    if (filename.empty()) return filename;    std::string path;    // Check env var    char *ptr = getenv( "PRODUCER_CONFIG_FILE_PATH");    if( ptr != NULL )    {         path = std::string(ptr) + '/' + filename;        if( osgDB::fileExists(path))             return path;    }    // Check standard location(s)    //path.clear();    path = std::string( "/usr/local/share/Producer/Config/") + filename;    if( osgDB::fileExists(path) )         return path;    //path.clear();    path = std::string( "/usr/share/Producer/Config/") + filename;    if( osgDB::fileExists(path) )         return path;    // Check local directory    if(osgDB::fileExists(filename))         return filename;    // Fail    return std::string();}bool CameraConfig::defaultConfig(){    if( getNumberOfCameras() != 0 ) return false;    char *env = getenv( "PRODUCER_CAMERA_CONFIG_FILE" );    // Backwards compatibility    if( env == NULL )        env = getenv( "PRODUCER_CONFIG_FILE" );    if( env != NULL )    {        std::string file = findFile(env);        return parseFile( file.c_str() );    }    unsigned int numScreens =  getNumberOfScreens();    if( numScreens == 0 )        return false;    float xshear = float(numScreens-1);    float yshear = 0.0;    float input_xMin = -1.0f;    float input_yMin = -1.0f;    float input_width = 2.0f/float(numScreens);    float input_height = 2.0f;    // use an InputArea if there is more than one screen.    InputArea *ia = (numScreens>1) ? new InputArea : 0;    setInputArea(ia);    for( unsigned int i = 0; i < numScreens; i++ )    {      std::string name = "Screen" + i;      std::pair<std::map<std::string, osg::ref_ptr<Camera> >::iterator,bool> res =       _camera_map.insert(std::pair<std::string, osg::ref_ptr<Camera> >(name, new Camera));      ((res.first)->second)->getRenderSurface()->setScreenNum( i );      ((res.first)->second)->setLensShear( xshear, yshear );       RenderSurface *rs = ((res.first)->second)->getRenderSurface();       rs->setWindowName( name );       if (ia)       {           rs->setInputRectangle( RenderSurface::InputRectangle(input_xMin, input_xMin+input_width, input_yMin, input_yMin+input_height) );           input_xMin += input_width;           ia->addRenderSurface(rs);       }       _render_surface_map.insert(std::pair<std::string,             osg::ref_ptr<RenderSurface> >( rs->getWindowName(), rs ));      xshear -= 2.0;    }    _threadModelDirective = CameraGroup::getDefaultThreadModel();    return true;}        

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -