当前位置: 首页>>代码示例>>C++>>正文


C++ MainFrame::SetViewer方法代码示例

本文整理汇总了C++中MainFrame::SetViewer方法的典型用法代码示例。如果您正苦于以下问题:C++ MainFrame::SetViewer方法的具体用法?C++ MainFrame::SetViewer怎么用?C++ MainFrame::SetViewer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MainFrame的用法示例。


在下文中一共展示了MainFrame::SetViewer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OnInit

// `Main program' equivalent, creating windows and returning main app frame
bool wxOsgApp::OnInit()
{
    if (argc<2)
    {
        std::cout << wxString(argv[0]).mb_str() <<": requires filename argument." << std::endl;
        return false;
    }

    int width = 800;
    int height = 600;

    // Create the main frame window

    MainFrame *frame = new MainFrame(NULL, wxT("wxWidgets OSG Sample"),
        wxDefaultPosition, wxSize(width, height));

    // create osg canvas
    //    - initialize

    int *attributes = new int[7];
    attributes[0] = int(WX_GL_DOUBLEBUFFER);
    attributes[1] = WX_GL_RGBA;
    attributes[2] = WX_GL_DEPTH_SIZE;
    attributes[3] = 8;
    attributes[4] = WX_GL_STENCIL_SIZE;
    attributes[5] = 8;
    attributes[6] = 0;

    OSGCanvas *canvas = new OSGCanvas(frame, wxID_ANY, wxDefaultPosition,
        wxSize(width, height), wxSUNKEN_BORDER, wxT("osgviewerWX"), attributes);

    GraphicsWindowWX* gw = new GraphicsWindowWX(canvas);

    canvas->SetGraphicsWindow(gw);

    osgViewer::Viewer *viewer = new osgViewer::Viewer;
    viewer->getCamera()->setGraphicsContext(gw);
    viewer->getCamera()->setViewport(0,0,width,height);
    viewer->addEventHandler(new osgViewer::StatsHandler);
    viewer->setThreadingModel(osgViewer::Viewer::SingleThreaded);

    // load the scene.
    wxString fname(argv[1]);
    osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFile(std::string(fname.mb_str()));
    if (!loadedModel)
    {
        std::cout << argv[0] <<": No data loaded." << std::endl;
        return false;
    }

    viewer->setSceneData(loadedModel.get());
    viewer->setCameraManipulator(new osgGA::TrackballManipulator);
    frame->SetViewer(viewer);

    /* Show the frame */
    frame->Show(true);

    return true;
}
开发者ID:aalex,项目名称:osg,代码行数:60,代码来源:osgviewerWX.cpp

示例2: OnInit


//.........这里部分代码省略.........
    {
        std::string argument = std::string( wxString( argv[ ii ] ).mb_str() );
        arguments.push_back( argument );
    }
    for( unsigned int ii = 0; ii < arguments.size(); ++ii )
    {
        argarray[ ii ] = const_cast< char* >( arguments[ ii ].c_str() );
    }
    int argcount = arguments.size();
    
    // parse arguments
    if( argcount < 2 )
    {
        std::cout << arguments[ 0 ] << ": requires filename argument." << std::endl;
        return( false );
    }
    osg::ArgumentParser argparser(&argcount,argarray);
    flat_mode_ = argparser.read( "--flat" );

    const int width = 800;
    const int treeWidth = 300;
    const int overallWidth = (width + treeWidth);
    const int height = 600;

    //
    // Create the main osg window
    MainFrame * frame = new MainFrame( NULL, wxT( "backdropFX wxpick" ),
                                      wxPoint( 10, 30 ), wxSize( overallWidth, height ) );

    // create tree & edit window
    _tree = new osgWxTree::TreeControl( frame, wxID_ANY, wxDefaultPosition, wxSize(treeWidth, height),
       wxTR_DEFAULT_STYLE | wxTR_HAS_BUTTONS | wxTR_ROW_LINES | wxTR_SINGLE );
    _tree->Show( true );


    // create osg canvas
    int * attributes = new int[ 7 ];
    attributes[ 0 ] = int( WX_GL_DOUBLEBUFFER );
    attributes[ 1 ] = WX_GL_RGBA;
    attributes[ 2 ] = WX_GL_DEPTH_SIZE;
    attributes[ 3 ] = 8;
    attributes[ 4 ] = WX_GL_STENCIL_SIZE;
    attributes[ 5 ] = 8;
    attributes[ 6 ] = 0;
    OSGCanvas * canvas = new OSGCanvas( frame, wxID_ANY, wxPoint(treeWidth,0),
                                        wxSize( width, height ), wxSUNKEN_BORDER, wxT( "osgviewerWX" ), attributes );
    GraphicsWindowWX * gw = new GraphicsWindowWX( canvas );
    canvas->SetGraphicsWindow( gw );


    // load the scene.
    osg::ref_ptr< osg::Group > root = new osg::Group; 
    root->setName( "wxpick root" );

    osg::ref_ptr< osg::Node > loadedModels = osgDB::readNodeFiles( argparser );
    if( loadedModels.valid() )
        root->addChild( loadedModels.get() );

    // Convert loaded data to use shader composition.
    {
        backdropFX::ShaderModuleVisitor smv;
        smv.setAttachMain( false ); // Use bdfx-main
        smv.setAttachTransform( false ); // Use bdfx-transform
        smv.setSupportSunLighting( true ); // Use shaders that light from the Sun
        backdropFX::convertFFPToShaderModules( root.get(), &smv );
    }

    backdropFXSetUp( root.get(), width, height );


    // construct the viewer
    osg::ref_ptr< osgViewer::Viewer > viewer = new osgViewer::Viewer;

    viewer->getCamera()->setGraphicsContext( gw );
    viewer->getCamera()->setViewport( 0, 0, width, height );

    viewerSetUp( *viewer, (double)width / (double)height, root.get() );

    viewer->addEventHandler( new osgWxTree::PickHandler( _tree ) );
    viewer->addEventHandler( new EffectHandler( _tree ) );
    viewer->setThreadingModel( osgViewer::Viewer::SingleThreaded );

    // populate the ui control
    if ( !flat_mode_ )
    {
        // create a full tree or
        osgWxTree::PopulateTreeControlWithNodeVisitor pt( _tree );
        root->accept( pt );
    }
    else
    {
        // create a flattened tree
        osgWxTree::setTreeToFlatGroup( _tree, root.get() );
    }

    frame->SetViewer( viewer.get() );
    frame->Show( true );

    return( true );
}
开发者ID:yaroslav-tarasov,项目名称:backdropfx,代码行数:101,代码来源:wxpick.cpp


注:本文中的MainFrame::SetViewer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。