1.多个模型添加到一个场景中去
#include <osgViewer/Viewer>
#include <osgDB/ReadFile>
#include <osg/Node>int main(void)
{
osgViewer::Viewer viewer;
osg::Group * root = new osg::Group();
root->addChild(osgDB::readNodeFile("sofa.osg"));
root->addChild(osgDB::readNodeFile("cow.osg"));
viewer.setSceneData(root);
viewer.realize();
viewer.run();
return 0;
}
出现下面效果:
删除节点:
#include <osgViewer/Viewer>
#include <osgDB/ReadFile>
#include <osg/Node>
int main(void)
{
osgViewer::Viewer viewer;
osg::Group * root = new osg::Group();
root->addChild(osgDB::readNodeFile("sofa.osg"));