OpenSceneGraph | OSG如何存储带纹理osgb格式可以节省空间
2024-10-13 06:54:45
在使用OSG(OpenSceneGraph)存储带纹理osgb格式的过程中,大家会遇到这样一种情况:存储后的osgb文件所占用的大小远大于原始文件的大小,几倍至几十倍。这是为何呢?原因是OSG默认的存储格式是不压缩存储,所以解决方案就是设置参数将存储格式改为压缩存储。方法如下:
osg::ref_ptr<osgDB::ReaderWriter::Options> options = new osgDB::ReaderWriter::Options; options->setOptionString("WriteImageHint=IncludeFile"); // 设置压缩 osgDB::writeNodeFile(*(node.get()), osgb_path, options);
如下文档可以找到解决方法的来源:
$ osgconv --format osgb Plugin osgPlugins-3.3.9/osgdb_osg.so { ReaderWriter : OSG Reader/Writer { features : readObject readNode writeObject writeNode extensions : .osg OpenSceneGraph Ascii file format extensions : .osgs Pseudo OpenSceneGraph file loaded, with file encoded in filename string options : OutputTextureFiles Write out the texture images to file options : includeExternalReferences Export option options : precision Set the floating point precision when writing out files options : writeExternalReferenceFiles Export option } ReaderWriter : OpenSceneGraph Native Format Reader/Writer { features : readObject readImage readNode writeObject writeImage writeNode extensions : .osg2 OpenSceneGraph extendable format extensions : .osgb OpenSceneGraph extendable binary format extensions : .osgt OpenSceneGraph extendable ascii format extensions : .osgx OpenSceneGraph extendable XML format options : Ascii Import/Export option: Force reading/writing ascii file options : Compressor=<name> Export option: Use an inbuilt or user-defined compressor options : ForceReadingImage Import option: Load an empty image instead if required file missed options : SchemaData Export option: Record inbuilt schema data into a binary file options : SchemaFile=<file> Import/Export option: Use/Record an ascii schema file options : WriteImageHint=<hint> Export option: Hint of writing image to stream: <IncludeData> writes Image::data() directly; <IncludeFile> writes the image file itself to stream; <UseExternal> writes only the fi lename; <WriteOut> writes Image::data() to disk as external file. options : XML Import/Export option: Force reading/writing XML file } }
上面文档中,有关WriteImageHint的项的描述(第26行):选择IncludeData是直接写入数据,无压缩,是默认选项。而includeFile则是写入流,按我的理解,就是将原始的影像数据流原原本本的写入osgb,原始的影像是压缩过的,比如jpg格式,那保存出来的osgb就是压缩过的。因此,将WriteImageHint设置为IncludeFile可以解决OSG存储带纹理osgb格式数据量大的问题,节省空间。
最新文章
- UVA 11464 偶数矩阵
- javascript自学002--DOM事件
- Delphi之DLL知识学习2---静态链接和动态链接
- Servlet与Tomcat
- 如何使用 XSD
- Java二维数组
- What exactly is the difference between WndProc and DefaultWndProc?
- 抽空通过简书网学习了一下console,感觉高大上!
- http协议与http代理
- MVC 控制器激活
- postgresql 修改属性
- 服务器大量的fin_wait1 状态长时间存在原因分析-1
- POJ2065 SETI 高斯消元
- 【代码审计】iCMS_v7.0.7 apps.admincp.php页面存在SQL注入漏洞分析
- Codeforces Round #439 (Div. 2) A B C
- java中需要用equals来判断两个字符串值是否相等
- [AGC025E]Walking on a Tree
- [转]Marshaling a SAFEARRAY of Managed Structures by P/Invoke Part 1.
- 冒泡排序&;快速排序
- 【BZOJ 3238】差异 后缀自动机+树形DP
热门文章
- Linux part2(系统的相关设置变更)
- vue 项目 跳转 页面 不刷新 问题
- 【JNDI】Java Naming and Directory Interface
- 数据结构和算法设计专题之---二分查找(Java版)
- (转)JMS事务
- 2017年上半年,一线城市豪宅TOP50成交均价排名
- Linux上VNC 启动和关闭
- 修改 Chrome浏览器主页被劫持 chrome 主页被篡改成hao.qquu8.com的解决方案
- POJ 2451 Uyuw&#39;s Concert (半平面交)
- jquery $用法