在使用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格式数据量大的问题,节省空间。

OpenSceneGraph | OSG如何存储带纹理osgb格式可以节省空间的更多相关文章

  1. Unity3D学习笔记2——绘制一个带纹理的面

    目录 1. 概述 2. 详论 2.1. 网格(Mesh) 2.1.1. 顶点 2.1.2. 顶点索引 2.2. 材质(Material) 2.2.1. 创建材质 2.2.2. 使用材质 2.3. 光照 ...

  2. MySQL 存储php中json_encode格式中文问题及解决

    MySQL 存储php中json_encode格式信息  ,遇到中文时, 会变成一堆类似uxxxx信息. 1. 原因分析:在存储到数据库时!MySQL 不会存储 unicode 字符: MySQL 仅 ...

  3. supermap中预览osgb格式的倾斜摄影文件

    参考: https://zhidao.baidu.com/question/136723493545478005.html 使用的是SuperMap IDesktop 9D,操作方法如下: 打开超图, ...

  4. js 处理Json 时间带T 时间格式

    对于后台传过来的json数据是带T时间格式的坑处理的一些做法总结 new Date(data[j].addtime).toISOString().replace(/T/g, ' ').replace( ...

  5. Apache Hive 存储方式、压缩格式

    简介: Apache hive 存储方式跟压缩格式! 1.Text File hive> create external table tab_textfile ( host string com ...

  6. GIS开源库OpenSceneGraph(OSG)、OSGEarth、GDAL、Qt、CGAL、Boost

    GIS开源有这些库:OpenSceneGraph(OSG).OSGEarth.GDAL.Qt.CGAL.Boost

  7. PCL Save VTK File With Texture Coordinates 使用PCL库来保存带纹理坐标的VTK文件

    我之前有一篇博客Convert PLY to VTK Using PCL 1.6.0 or PCL 1.8.0 使用PCL库将PLY格式转为VTK格式展示了如何将PLY格式文件转化为VTK格式的文件, ...

  8. [粒子特效]osg的自带粒子系统osgParticle::ParticleSystem

    osgParticle示例简单的演示了在osg中使用粒子系统的效果,用到了osgParticle库中的相关类,在osgParticle中主要有: (以下部分材料摘取自osg向场景中添加osgParti ...

  9. Python的小数据存储,用什么格式更有逼格?

    小数据存储 我们在编写代码的时候,经常会涉及到数据存储的情况,如果是爬虫得到的大数据,我们会选择使用数据库,或者excel存储.但如果只是一些小数据,或者说关联性较强且存在存储后复用的数据,我们该如何 ...

随机推荐

  1. 71 Serializable(序列化和反序列化)

    对象的输出流:ObjectOutputStream  把对象输出到文件存储起来,我们称作为序列化对象的输入流:ObjectInputStream   把对象从文件中读取出来,我们称作为反序列化 Obj ...

  2. 深入理解MAGENTO – 第九章 – 数据集合瓦瑞恩

    本来,作为一个PHP程序员,如果你想攒一组变量的相关你有一个选择,古老的 阵列 . 尽管共享一个地址的名称与C存储器的阵列,一个PHP数组是一种通用的字典可变数组索引像数值对象结合行为的影响. 在其他 ...

  3. 搭建基于Linux6.3+Nginx1.2+PHP5+MySQL5.5的Web服务器全过程

    http://blog.chinaunix.net/uid-20639775-id-154497.html

  4. angulajs 详解 directive 中 的 scope 概念

    Directive 是 angularjs 中最重要的概念,我的理解就是自定义html tag, 这个自定的tag 浏览器不会解析,会有angularjs 来动态解析. 比如在html 中添加 < ...

  5. (12)centos7 环境变量配置

    export 一个变量的设置一般只在当前环境有效,export命令可以用于传递一个或多个变量的值到任何后续脚本.export可新增.修改或删除环境变量,供后续执行的程序使用.export的效力限于该次 ...

  6. super_blocks没有导出

    在模块中,通过查询super_blocks列表,来遍历系统中的所有super_block,但是出现与下面类似的错误: http://stackoverflow.com/q/5051111/941650 ...

  7. 拾遗:ssh 公钥连接前的相关准备

    ssh 公钥连接条件: sshd_config 中启用公钥认证 authorized_keys 文件权限必须为 0600 目标用户的 家目录 权限必须为 0700 目标账户必须已设定登陆密码(即处于可 ...

  8. exe自启动的几种方式

    1 注册表启动项目RUN (注册路径 HKEY_LOCAL_MACHINE\SOFTWARE\microsoft\Windows\CurrentVersion\Run) 2 计划任务 比较少见这种方式 ...

  9. Lung Nodule Detection------work log

    有时候真的不知道自己是怎么走上,模式识别,人工智能的这条路上的.但既然走上了这条路,我就没有理由荒废我所学到的东西.在学校里面研究了很长的时间的肺结节检测,但那都是只限于研究和写论文,现在我想把大家的 ...

  10. 解决 IE6 position:fixed 固定定位问题

    #e_float{ _position:absolute; _bottom:auto; _right:50%; _margin-right:-536px; _top:expression(eval(d ...