-
3DS MAX
标准文本导出格式
ASE
的文件结构<
/p>
如果你正在寻找它的几何体存放在哪
的话,事实上,这不是描述具体信息层级关系的图示,
而是类似
XML
的一种
存储规范
,它具有
独立标签
和
嵌套标签
,独立标签有
名称
和
值表
,而
嵌套标签不仅可以
嵌套子标签
< br>,
还可以
嵌套
“
子嵌套标签
”
,
如此递归下去
。这种格式固然带
来很大的灵活性,
但是非常浪费时间。
需要对它们
全部解套然后利用一致的算法
,<
/p>
提供一个
匹配标签名进行标签取出和迭代。
*3DSMAX_ASCIIEXPORT 200
*COMMENT
版本
2.00 - Wed Sep 19 22:16:39
2007
*SCENE {
*SCENE_FILENAME
*SCENE_FIRSTFRAME 0
*SCENE_LASTFRAME 100
*SCENE_FRAMESPEED 30
*SCENE_TICKSPERFRAME 160
*SCENE_BACKGROUND_STATIC 0.00000000
0.00000000 0.00000000
*SCENE_AMBIENT_STA
TIC
0.00000000 0.00000000 0.00000000
}
第二行使用了双引号对值进行了限定,
避免被分割成子单元。
我们可以假设
*SCENE
块还可
以内嵌子块,
假如存在,
便可将此子块作为独立单元进
行递归分解。
直到所有嵌套子块全部
被遍历。
< br>
* QUICK NOTES *
This tutorial shows how to load a .Ase
file.
An ASE file is a 3D
Studio Max ASCII file
that saves all
the information in a text file instead of in
binary.
The
good thing about this is that it's easy to read
in, as well as easy to change without
having the software. The bad thing is
that it's a HUGE file size, it takes a lot longer
to read
in, no other programs support
it and it can't even be imported back into 3D
Studio Max.
I
would recommend looking at this
tutorial before you look at the 3DS tutorial
though.
That
way
you can see what is actually being read in.
Let
me mention that the math functions above are not
so important and don't need to be
in
this file.
I wanted to show
how to calculate vertex normals so your models
would have
some excellent lighting.
You most likely have
functions already that do the basics so I
encourage you to just use those.
This will cut down the code
significantly.
* What's An STL (Standard
Template Library) Vector? *
Let me quickly explain the
STL vector for those of you who are not familiar
with them.
To
use
a
vector
you
must
include
and
use
the
std
namespace:
using
namespace std;
A
vector
is
an
array
based
link
list.
It
allows
you
to
dynamically
add
and
remove
nodes.
This is a template class so it can be a
list of ANY type.
To create
a vector of type
vector
Now
you can add a integer to the dynamic array by
saying: _back(10);
or you can say:
_back(num);.
The
more you push back, the larger
your array gets.
You can index the vector
like an array.
myIntList[0]
= 0;
To get rid
of a node you use the pop_back() function.
To clear the vector use
clear().
It
frees itself so you don't need to worry about it,
except if you have data
structures that need information freed
from inside them, like our objects.
Let's go over some of the format of the
.Ase file.
I will only
address the information that
we really
care about for object loading.
The rest is Scene stuff.
I created a single box
around the origin that had a texture
map over it to show
the simplest and smallest amount of
data.
This next block
is the material block.
This
holds all the info on the materials.
*MATERIAL_LIST {
// This is the tag for the
start of the material info
*MATERIAL_COUNT 1
// This tells us how many
materials there are
*MATERIAL 0 {
// This is the material ID
that the next data is refering
too.
*MATERIAL_NAME
// The
material name
*MATERIAL_CLASS
*MATERIAL_AMBIENT 0.1791
0.0654
0.0654
*MATERIAL_DIFFUSE 0.5373
0.1961
0.1961
//
The color of the object
*MATERIAL_SPECULAR 0.9000
0.9000
0.9000
*MATERIAL_SHINE
0.2500
*MATERIAL_SHINESTRENGTH 0.0500
*MATERIAL_TRANSPARENCY 0.0000
*MATERIAL_WIRESIZE 1.0000
*MATERIAL_SHADING Blinn
*MATERIAL_XP_FALLOFF 0.0000
*MATERIAL_SELFILLUM 0.0000
*MATERIAL_FALLOFF In
*MATERIAL_XP_TYPE Filter
*MAP_DIFFUSE {
*MAP_NAME
*MAP_CLASS
*MAP_SUBNO 1
*MAP_AMOUNT
1.0000
*BITMAP
// This is the file name for the
texture
*MAP_TYPE Screen
*UVW_U_OFFSET 0.0000
//
This is the U offset for the tile
*UVW_V_OFFSET 0.0000
//
This is the V offset for the tile
*UVW_U_TILING 1.0000
// This is the U tiling ratio (1 is
standard)
*UVW_V_TILING 1.0000
// This is the V tiling
ratio (1 is standard)
*UVW_ANGLE
0.0000
*UVW_BLUR 1.0000
*UVW_BLUR_OFFSET 0.0000
*UVW_NOUSE_AMT 1.0000
*UVW_NOISE_SIZE 1.0000
*UVW_NOISE_LEVEL 1
*UVW_NOISE_PHASE 0.0000
*BITMAP_FILTER Pyramidal
}
}
}
*GEOMOBJECT {
// This tag let's us know that objects
are
next
*NODE_NAME
// This is the
object name
*NODE_TM {
*NODE_NAME
// Once again,
this is the objects name
*INHERIT_POS 0 0 0
*INHERIT_ROT 0 0 0
*INHERIT_SCL 0
0 0
*TM_ROW0 1.0000
0.0000
0.0000
*TM_ROW1 0.0000
1.0000
0.0000
*TM_ROW2 0.0000
0.0000
1.0000
*TM_ROW3 0.0000
0.0000
0.0000
*TM_POS 0.0000
0.0000
0.0000
*TM_ROTAXIS 0.0000
0.0000
0.0000
*TM_ROTANGLE
0.0000
*TM_SCALE 1.0000
1.0000
1.0000
*TM_SCALEAXIS 0.0000
0.0000
0.0000