osg(osg中文社区)-osgEarth-osgViewer-基于OpenGL-开源三维渲染引擎-图形引擎-虚拟仿真工具-osg教程-osg仿真

osgconv

当前位置:首页 > 关于osg > 使用指南 > 用户指南

osgconv 主要的功能是用来将3D模型进行格式转换和进行一些诸如纹理压缩类的操作的。


使用OSGCONV将模型转为OSG的专属文件格式IVE

将cow.obj转成ive:

osgconv cow.obj cow.ive

压缩并自动将纹理生成mipmap:

osgconv --compressed cow.obj cow.ive


查看帮助

查看osgconv支持的操作:

osgconv --help

会出如下打印

usage:

osgconv [options] infile1 [infile2 ...] outfile

options:

-O option

ReaderWriter option

--compressed

Compress textures.

--compressed

Enable the usage of compressed textures.

--compressed-arb

Enable the usage of OpenGL ARB compressed textures

--compressed-dxt1

Enable the usage of S3TC DXT1 compressed textures

--compressed-dxt3

Enable the usage of S3TC DXT3 compressed textures

--compressed-dxt5

Enable the usage of S3TC DXT5 compressed textures

-l libraryName

load plugin of name libraryName i.e. -l osgdb_pfb 
Useful for loading reader/writers which can load other file formats in addition to its extension.

-e extensionName

load reader/wrter plugin for file extension i.e. -e pfb 
Useful short hand for specifying full library name as done with -l above, as it automatically expands to the full library name appropriate for each platform.

-o orientation

Convert geometry from input files to output files.
Format of orientation argument must be the following:

X1,Y1,Z1-X2,Y2,Z2
or
degrees-A0,A1,A2

where X1,Y1,Z1 represent the UP vector in the input files and X2,Y2,Z2 represent the UP vector of the output file, or degrees is the rotation angle in degrees around axis (A0,A1,A2). For example, to convert a model built in a Y-Up coordinate system to a model with a Z-up 
coordinate system, the argument may look like 

0,1,0-0,0,1 
or 
-90-1,0,0

-t translation

Convert spatial position of output files. Format of translation argument must be the following :

X,Y,Z

where X, Y, and Z represent the coordinates of the absolute position in world space

-s scale

- Scale size of model. Scale argument must be the following :

SX,SY,SZ

where SX, SY, and SZ represent the scale factors. Caution: Scaling will be done in destination orientation


小知识

纹理转换

如果将ive转成osg会有一个问题就是ive内部是包含纹理的,就在ive文件中,而osg是ASCII文件,是不包含纹理的,这样就会产生OSG没有纹理的问题,可以通过指定-O OutputTextureFiles来把纹理也进行导出。

Example:

osgconv -O OutputTextureFiles in.ive out.osg

注意导出的时候有些纹理格式是不支持导出的,比如.RGB格式,详情见:http://forum.openscenegraph.org/viewtopic.php?t=3196&view=next

纹理的压缩与解压其实是使用OPENGL来完成的,因此如果出现问题不要怀疑是OSG的代码,有可能是显卡驱动的原因等。