|
本帖最后由 Mze 于 2014-12-25 19:55 编辑
程序读入.ive文件,用osgViewer浏览场景,场景是完整的,转存成.obj文件文件。用osgViewer场景浏览器浏览此读入的.obj,发现纹理丢失
1.完整的.ive转成.obj程序
#include <osgViewer/Viewer>
#include <osgDB/ReadFile>
#include <osgDB/WriteFile>
#include <osgUtil/Optimizer>
int main(int argc, char**argv)
{
osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer();
osg::ref_ptr<osg::Group> root = new osg::Group();
osg::ref_ptr<osg::Node> node = osgDB::readNodeFile("abc.ive"); //读入.ive文件
root->addChild(node.get());
osgDB::writeNodeFile(*(root.get()), "abc.obj"); // 转存.obj文件
osgUtil::Optimizer optimizer;
optimizer.optimize(root.get());
viewer->setSceneData(root.get());
viewer->realize();
return viewer->run();
}
2.完整的浏览.obj文件场景的程序
#include <osgViewer/Viewer>
#include <osgDB/ReadFile>
#include <osgDB/WriteFile>
#include <osgUtil/Optimizer>
int main(int argc, char**argv)
{
osg::ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer();
osg::ref_ptr<osg::Group> root = new osg::Group();
osg::ref_ptr<osg::Node> node = osgDB::readNodeFile("abc.obj"); //读入.obj文件
root->addChild(node.get());
osgUtil::Optimizer optimizer;
optimizer.optimize(root.get());
viewer->setSceneData(root.get());
viewer->realize();
return viewer->run();
}
刚开始学习OSG,求前辈指点!谢谢! |
|