MD2文件由兩個(gè)主要部分組成:文件頭和數(shù)據(jù)。
文件頭部分: 包含模型描述,多邊形數(shù),頂點(diǎn)數(shù)和動(dòng)畫細(xì)節(jié)等。
數(shù)據(jù)部分: 組成模型的多邊形網(wǎng)格的數(shù)據(jù),包括所有的多邊形,頂點(diǎn)和紋理數(shù)據(jù)。
在MD2文件中,所有的多邊形都為三角形,且沒(méi)有其他的實(shí)體。
頂點(diǎn)數(shù)據(jù)定義的不是單幀而是多幀動(dòng)畫。事實(shí)上,每個(gè)MD2文件包含198幀動(dòng)畫,編號(hào)為0-197。
MD2文件頭數(shù)據(jù)結(jié)構(gòu)定義:
// This is the header structure for a Quake II .MD2 file by id Software
typedef struct MD2_HEADER_TYPE
{
int identifier; // identifies the file type, should be "IDP2"
int version; // version number, should be 8.
int skin_width; // width of texture map used for skinning
int skin_height; // height of texture map used for skinning
int framesize; // number of bytes in a single frame of animation
int num_skins; // total number of skins,
// listed by ASCII filename and are available for loading if files are found in full path.
int num_verts; // number of vertices in each model frame,
// the number of vertices in each frame is always the same.
int num_textcoords; // total number of texture coordinates in entire file,
// may be larger than the number of vertices.
int num_polys; // number of polygons per model, or per frame of animation if you will.
int num_openGLcmds; // number of openGL commands which can help with rendering optimization,
// however, we won't be using them.
int num_frames; // total number of animation frames
// memory byte offsets to actual data for each item
int offset_skins; // offset in bytes from beginning of file to the skin array that holds the file name
// for each skin, each file name record is 64 bytes.
int offset_textcoords; // offset in bytes from the beginning of file to the texture coordinate array
int offset_polys; // offset in bytes from the beginning of file to the polygon mesh
int offset_frames; // offset in bytes from the beginning of file to the vertex data for each frame
int offset_openGLcmds; // offset in bytes from the beginning of file to the openGL commands
int offset_end; // offset in bytes from the beginning of file to end of file
} MD2_HEADER, *MD2_HEADER_PTR;

線框模式

實(shí)體模式
其他模型



