|
楼主 |
发表于 2010-11-26 10:31:28
|
显示全部楼层
主程序中:
osg::ref_ptr<osgViewer::Viewer> m_viewer;
osg::ref_ptr<osg::Group> m_group;
osg::ref_ptr<CityManipulator3D> mani3;
m_viewer = new osgViewer::Viewer;
m_group = new osg::Group;
mani3 = new CityManipulator3D();
osg::ref_ptr<osg::Node> node = osgDB::readNodeFile("cow.osg");
m_group->addChild(node.get());
mani3->setCenter(osg::Vec3d(0.0, 0.0, 0.0));
mani3->setDistance(500.0);
mani3->setRoot(m_group.get());
osgUtil::Optimizer optimizer;
optimizer.optimize(m_group.get());
m_viewer->setCameraManipulator(mani3.get());
m_viewer->setSceneData(m_group.get());
m_viewer->realize();
m_viewer->run();
在操作器中:
if (ea.getKey() == 'z' || ea.getKey() == 'Z')
{
osgDB::writeNodeFile(*(sceneRoot), "data\\root.ive");
return false;
} |
|