Qt osg QWidget osgViewer::Viewer

osgViewer::Viewer* _viewer = nullptr;

_viewer = new osgViewer::Viewer;
osg::ref_ptr<osg::Group> root = new osg::Group;
//注意:这两句话的先后顺序 先添加模型在添加相机
//root->addChild(osgDB::readNodeFile("cow.osgt"));
root->addChild(osgDB::readNodeFile("D:\\参考手册\\BIM\\osg\\library.OSGB"));

root->addChild(createLight());
_viewer->setCamera(camera);//这两句话的先后顺序
_viewer->setSceneData(root);
_viewer->setThreadingModel(osgViewer::Viewer::SingleThreaded);
_viewer->setCameraManipulator(new osgGA::TrackballManipulator);
_viewer->addEventHandler(new osgViewer::WindowSizeHandler());

GraphicsWindowQt* gcQT = dynamic_cast<GraphicsWindowQt*>(gc);
if (gcQT) {
  QWidget *pWgt = gcQT->getGLWidget();
  //ui.verticalLayout->addWidget(pWgt);
  ui.verticalLayout->addWidget(pWgt);
}

 

 

 

posted @ 2019-06-15 20:27  西北逍遥  阅读(1280)  评论(0编辑  收藏  举报