游戏开发论坛

 找回密码
 立即注册
搜索
查看: 2803|回复: 2

有没有MD3文件的详细格式说明啊

[复制链接]

78

主题

194

帖子

194

积分

注册会员

Rank: 2

积分
194
发表于 2004-3-21 14:24:00 | 显示全部楼层 |阅读模式
md2的格式说明倒挺多的,md3不好找啊,那位前辈可以帮一个忙? 特别是骨骼数据部分的格式

15

主题

73

帖子

81

积分

注册会员

Rank: 2

积分
81
发表于 2004-3-21 17:10:00 | 显示全部楼层

Re:有没有MD3文件的详细格式说明啊

只有英文的,我正在看.一本叫做<<FOCUS ON 3D MODELS>>中间有MD3的文件格式和各种3D文件格式的比较详细的说明.

5

主题

25

帖子

25

积分

注册会员

Rank: 2

积分
25
发表于 2004-4-5 00:29:00 | 显示全部楼层

Re:有没有MD3文件的详细格式说明啊

MD3 File format

Char  是8位整型变量类型
Short 是16位整型变量类型
Int 是32位整型变量类型
Float 是32位浮点变量类型
Vec2 是float[2]
Vec3 是float[3]
Mat3x3 是float[3][3]二维数组
TexVec 是纹理U/V坐标向量
文件头
MD3_HEADER
char ID[4];                          //文件标志"IDP3"                               
int   Version;                           //文件版本0x0f                               
char FileName[68];        //文件名                                               
int  BoneFrame_num;      //BoneFrames数                                                int  Tag_num;                //每个BoneFrame的Tag数                               
int  Mesh_num;              //Mesh(几何网格)数                                       
int  MaxSkin_num;             //最大可用Skin(材质)数                               
int  HeaderLength;     //文件头长度.                                               
int  Tag_Start;         //Tag(标签)结构的开始位置.                               
int  Tag_End;           //标签Tag的结束位置也就是几何网格结构的起始位置               
int  FileSize;        //文件大小                                               
注释:
Tag的开始位置和结束位置相同则表示没有Tag
Tag_Num有时为零,当然表示没有Tag.
我不能确定Tag有什么作用,也许对骨骼动画系统有用吧.
文件头后是Tag列表,如果有效那么tags的总和等于Tag_num个BoneFrame_num.
注意: 我们称之为'Tags',是因为在MD3文件中它为'Tag_';
TAG:
char Name[64];    //name of 'tag' as it's usually
                               //called in the md3 files try to
                               //see it as a sub-mesh/seperate
                               //mesh-part.
                               //sometimes this 64 string may
                               //contain some garbage, but
                               //i've been told this is because
                               //some tools leave garbage in
                               //those strings, but they ARE
                               //strings...
Vec3 Postition;   //relative position of tag
Vec3x3 Rotation;   //the direction the tag is facing relative to the rest of the model               
注释:
fairly obvious i think, the name is the name of the tag.
"position" is the relative position and "rotation" is the relative rotation to the rest of the model.
在tags之后是,'boneframe'骨架帧.几何网格帧的个数通常
After the tags come the 'boneframes', frames in the bone animation.
The number of meshframes is usually identical to this number or simply 1.
The header variable BoneFrame_num holds the ammount of BoneFrame..
BONEFRAME:
没有完全证实:
float  Mins[3];
float  Maxs[3];
float  Position[3];
float  scale;
char   Creator[16]; //我想这应该是制作者的名字,但仅仅是猜测.
注释:
Mins,Maxs,和Position可能是正确的,scale则是猜测.
If you divide the maximum and minimum xyz values of all the vertices from each meshframe you get
the exact values as mins and maxs..
Position is the exact center of mins and maxs, most of the time anyway.
Creator 非常可能是制作模型的程序生成的文件名通常为(from ASE)"或 .3ds.
在之后为几何网格头:mesh-headers;
几何网格总数为Mesh_num所指明.
注意:一个Mesh包含Mesh-header,表皮,三角形,纹理坐标和顶点.
Each mesh contains that data, and the next mesh will only start after the triangles, meshes etc. of the previous mesh.
让我惊讶的是Md3文件并不包含很多个Mesh,这是我们需要深入了解的.
MESH:
char ID[4];           //id, must be IDP3
char Name[68];       //name of mesh 65 chars, 32 bit aligned == 68 chars
int  MeshFrame_num;  //number of meshframes in mesh
int  Skin_num;       //number of skins in mesh
int  Vertex_num;     //number of vertices
int  Triangle_num;   //number of Triangles
int  Triangle_Start; //三角形数据的开始位置,相对于Mesh_Header
int  HeaderSize;     //头的长度
int  TexVec_Start;   //纹理坐标数据的开始位置,相对于Mesh_Header
int  Vertex_Start;   //顶点的开始位置,相对于Mesh_Header
int  MeshSize;       //Mesh的大小
注释:
Meshframe_num 类似于quake1/quake2的总帧数.
(these frames work on a morph like way, the vertices are moved from one position to another instead of rotated around eachother like in bone-based-animations)
Skin_num 是Skins的个数.
一些Skin是动画.
Triangle_Start, TexVec_Start 和 Vertex_Start 是以字节为单位从Mesh Header指出相应的位置.
Mesh header 之后是Skin(纹理)
它的个数由上面的Mesh_header中的Skin_num决定.
SKIN:
char Name[68]; //name of skin used by mesh 65 chars,32 bit aligned == 68 chars        
注释:
Name 纹理的名字, 在baseq3路径下.
Q3 通过特殊的方法取得纹理.
脚本放置在baseq3/script路径下,保存了那些表面采用动画及多重纹理映射.
Now the strange thing is, if you remove the ".tga" at the end of the skin, and that name is used in the script files, than that scripted surface is used.
If it isn't mentioned in the script files then the filename is used to load the tga file.

纹理之后接着是三角形数据,个数由Triangle_num指出.
TRIANGLE
int Triangle[3]; //vertex 1,2,3 of triangle
注释:
三角形结构是很简单的结构.一个三角形由三个顶点构成,如果你有一个顶点列表,比如你有28个顶点的列表,一个三角形由顶点1,14,7构成,那么三角形结构就是整形的1,14,7 7.
三角形列表之后是纹理UV坐标个数由顶点决定:
TEXTURE U/V COORDINATES:
Vec2 TexVec; //Texture U/V coordinates of vertex
注释:
它使三角形知道如何给自己贴上纹理.
纹理坐标之后是顶点坐标,由Vertex_num指出个数.
VERTICES:
//!!!注意变量类型!!! signed!
signed short Vec[3];   //顶点 X/Y/Z 坐标
unsigned char EnvTex[2];   //环境贴图坐标
注释:
Vec 包含 3d xyz 的顶点坐标.
EnvTex 包含环境贴图的纹理坐标.
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-5-16 11:56

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表