其他分享
首页 > 其他分享> > Qt osg QWidget osgViewer::Viewer

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);
}

 

 

 

标签:addChild,Qt,Viewer,viewer,osgViewer,new,root,osg
来源: https://www.cnblogs.com/herd/p/11028738.html