在使用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. mysql查询相关

    查询事务 SELECT * FROM information_schema.INNODB_TRX\G; 查询正在锁的事务 SELECT * FROM INFORMATION_SCHEMA.INNODB ...

  2. git - Mac生成SSH key

    步骤1.检查是否已经存在SSH Key 打开电脑终端,输入以下命令: ls -al ~/.ssh 会出现两种情况 步骤2. 生成/设置SSH Key 继续上一步可能出现的情况 (1)情况一: 终端出现 ...

  3. 64 计算机图形学入门(1)——OpenGL环境配置与图形流水线(图像管线)

    0 引言 最近想学一下计算机图形学方面的知识,原因如下.目前本人接触了数字图像处理(opencv)以及点云处理(PCL)方面的知识,对从图像和点云中提取特征信息,并将特征转化为底层/中层语义信息有了一 ...

  4. LInux多线程编程----线程属性pthread_attr_t

    1.每个POSIX线程有一个相连的属性对象来表示属性.线程属性对象的类型是pthread_attr_t,pthread_attr_t 在文件/usr/include/bits/pthreadtypes ...

  5. 6.1.2 The continuous assignment statement

    Frm: IEEE Std 1364™-2001, IEEE Standard Verilog® Hardware Description Language The continuous assign ...

  6. 【三】Jmeter接口自动化测试系列之Http接口自动化实战

    作者:大虫 本文介绍 Jmeter 工具的 http 接口 自动化测试 实战! 为了通用性,就拿知乎 网站作为实战例子吧! 必备技能:http接口基础知识.抓包,本文不做详细介绍,不会的可以先百度恶补 ...

  7. vue-router 使用二级路由去实现子组件的显示和隐藏

    在需求中有一个这样的情况:一个组件在主组件和另外的组件中引用,且点击主组件和这个组件分别有相应得切换事件. 一开始的时候我是没有划分组件,把它们放到主组件内,这样便于切换,但是主主件内有独立的部分需要 ...

  8. Reqests----Get请求之参数化

    一.环境安装 >>pip install requests 注意:pip很容易就会版本升级,如果用python3的,请使用pip3 install requests 1.初始化版本 2.把 ...

  9. 2018-2-13-win10-UWP-动画

    title author date CreateTime categories win10 UWP 动画 lindexi 2018-2-13 17:23:3 +0800 2018-2-13 17:23 ...

  10. ssh隧道实现端口转发

    ssh隧道实现端口转发 本地转发 # 本地转发 ssh -g -f -N -L : root@ # -L 本地端口转发,转发172.16.1.1主机可以访问的资源,这里为转发172.16.1.2的80 ...