使用OpenSceneGraph(OSG)库将osg模型转为obj格式

使用osgconv将多个osgb转为obj

在百度上搜索.osgb格式转.obj格式,往往需要使用付费软件;而OSG库自带的osgconv.exe其实就具备三维模型格式转换的功能,以多个osgb文件合并为一个obj文件为例,仅需要运行下面格式的命令:

osgconv -O OutputTextureFiles OSGB文件1 OSGB文件2 OSGB文件3 输出的OBJ文件

即,假如用户有scene1.osgb scene2.osgb两个模型,想合并成一个obj格式的模型,运行下面的命令即可:

osgconv -O OutputTextureFiles scene1.osgb scene2.osgb test.obj

osgconv的其他用法

使用 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

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

参考

  • 20
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值