TA的每日心情 | 开心 2020-3-20 17:50 |
---|
签到天数: 1 天 [LV.1]初来乍到
|
楼主 |
发表于 2020-3-9 21:02:22
|
显示全部楼层
本帖最后由 liyihongcug 于 2020-3-9 21:09 编辑
//读取
#include <osgDB/ReadFile>
osg::ref_ptr<Node> node = osgDB::readNodeFile("cow.osg");
osg::ref_ptr<Image> image = osgDB::readImageFile("lz.rgb");
//保存
#include <osgDB/WriteFile>
osgDB::writeNodeFile(*node, "saved.osg");
生成osg图像并保存
#include "osgViewer/Viewer"
#include "osgDB/WriteFile"
#include "osgDB/ReadFile"
#include "osgGA/TrackballManipulator"
#include <osgViewer/GraphicsWindow>
void main()
{
//////////////////////////////////////////////////////////////////////////
//得到屏幕分辨率
osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface();
unsigned int width, height;
wsi->getScreenResolution(osg::GraphicsContext::ScreenIdentifier(0), width, height);
///////////////////////////////////////////////////////////////////////////
osgViewer::Viewer v;
v.setSceneData(osgDB::readNodeFile("axes.osg"));
v.setCameraManipulator(new osgGA::TrackballManipulator());
v.frame();
osg::ref_ptr<osg::Image> image = new osg::Image;
image->readPixels(0,0,width,height, GL_RGB,GL_UNSIGNED_BYTE);
osgDB::writeImageFile(*image,"abc.jpg");
}
osgDB::writeNodeFile和osgDB::Registry::instance()->writeNode都能写出osg文件,他们有什么主要区别吗 |
|