M2文件中的信息大体是这样的
全局纹理列表 全局顶点列表
- Position
- Blend weights
- Blend indices
- Normal
- Texture coordinates
LOD (每个模型共4级?)
- Vertex indices (这级LOD用到的顶点 为全局顶点列表的索引)
- Face indices (每个三角形有三个, 同样是全局顶点列表中的索引)
- Vertex properties (每个顶点索引有一个, 未知)
- Submeshes (一般每种材质一个)
- Texture units (引用Subemesh, 全局纹理列表的索引, 绑定纹理单元的数目)
全局包围体 (用来碰撞检测?) 动画(Animations, global sequences) 骨骼(Skeleton) 额外的渲染信息: 颜色, 透明度, 纹理动画, 模型混合等. 特效: 条带, 粒子 灯光 摄像机
代码语言:javascript复制struct ModelHeader {
char id[4]; //"MD20"
uint8 version[4];
uint32 nameLength; //model name length (including /0)
uint32 nameOfs; //model name offset
uint32 type; //Model type? always 0, 1 or 3 (mostly 0)
uint32 nGlobalSequences; //number of global sequences
uint32 ofsGlobalSequences; //offset to global sequences
uint32 nAnimations; //number of animation sequences
uint32 ofsAnimations; //offset to animation sequences
uint32 nC;
uint32 ofsC;
uint32 nD; //always 201 or 203 depending on WoW client version
uint32 ofsD;
uint32 nBones; //number of bones
uint32 ofsBones; //offset to bones
uint32 nF; //bone lookup table
uint32 ofsF;
uint32 nVertices; //number of vertices
uint32 ofsVertices; //offset to vertices
uint32 nViews; //number of views (LOD versions?) 4 for every model
uint32 ofsViews; //offset to views
uint32 nColors; //number of color definitions
uint32 ofsColors; //offset to color definitions
uint32 nTextures; //number of textures
uint32 ofsTextures; //offset to texture definitions
uint32 nTransparency; //number of transparency definitions
uint32 ofsTransparency; //offset to transparency definitions
uint32 nI; // always unused ?
uint32 ofsI;
uint32 nTexAnims; //number of texture animations
uint32 ofsTexAnims; //offset to texture animations
uint32 nTexReplace;
uint32 ofsTexReplace;
uint32 nTexFlags; //number of blending mode definitions
uint32 ofsTexFlags; //offset to blending mode definitions
uint32 nY; //bone lookup table
uint32 ofsY;
uint32 nTexLookup; //number of texture lookup table entries
uint32 ofsTexLookup; //offset to texture lookup table
uint32 nTexUnitLookup; //texture unit definitions?
uint32 ofsTexUnitLookup;
uint32 nTransparencyLookup; //number of transparency lookup table entries
uint32 ofsTransparencyLookup;//offset to transparency lookup table
uint32 nTexAnimLookup; //number of texture animation lookup table entries
uint32 ofsTexAnimLookup;
float floats[14];
uint32 nBoundingTriangles;
uint32 ofsBoundingTriangles;
uint32 nBoundingVertices;
uint32 ofsBoundingVertices;
uint32 nBoundingNormals;
uint32 ofsBoundingNormals;
uint32 nAttachments;
uint32 ofsAttachments;
uint32 nAttachLookup;
uint32 ofsAttachLookup;
uint32 nQ;
uint32 ofsQ;
uint32 nLights; //number of lights
uint32 ofsLights; //offset to lights
uint32 nCameras; //number of cameras
uint32 ofsCameras; //offset to cameras
uint32 nT;
uint32 ofsT;
uint32 nRibbonEmitters; //number of ribbon emitters
uint32 ofsRibbonEmitters; //offset to ribbon emitters
uint32 nParticleEmitters; //number of particle emitters
uint32 ofsParticleEmitters; //offset to particle emitters
};
这把刀看起来挺漂亮, 就拿它开刀了:
16进制文件分析: