?? md3.h
字號:
// -----------------------------------------------------
// File: md3.h
// Description: header for methods, which loads and
// renders a *.md3 file
//
// Author: Wolfgang Engel (wolf@direct3d.net)
// Internet: www.direct3d.net
// Last modified: 13. September 2000
// -----------------------------------------------------
#define STRICT
#define D3D_OVERLOADS
#include <windows.h>
#include <stdio.h> // file i/o
#include <tchar.h>
#include <D3DX8.h>
#include <DXUtil.h>
// typedefs
typedef int TRIANGLEVERT[3];
typedef char TEXNAMES[68];
typedef D3DXVECTOR3 *VMESHFRAME;
typedef struct
{
float u;
float v;
} TEXCOORDS;
//------------------------------------------------------------
// the length of MD3HEADER, MD3BONEFRAME, MD3TAG, MD3MESHFILE
// and MD3VERTEX is fixed in the md3 file
//------------------------------------------------------------
typedef struct
{
char id[4]; // id of file, always "IDP3"
int iVersion; // version number
char cFileName[68];
int iBoneFrameNum; // Number of animation key frames in the whole model=every mesh
int iTagNum; // Number of tags
int iMeshNum; // Number of meshes
int iMaxTextureNum; // maximum number of unique textures used in a md3 model
int iHeaderSize; // size of header
int iTagStart; // starting position of tag frame structures
int iMeshStart; // starting position of mesh structures
int iFileSize;
} MD3HEADER;
typedef struct
{
FLOAT fMins[3];
FLOAT fMaxs[3]; // extrema of the bounding box
FLOAT pos[3]; // position of the bounding box
float scale; // scaling the bounding box
char creator[16];
} MD3BONEFRAME;
typedef struct
{
char cTagName[12];
char unknown [52];
FLOAT pos[3]; // position of tag relative to the model that contains the tag
FLOAT fMatrix[3][3];// the direction the tag is facing
} MD3TAG;
typedef struct
{
char cId[4];
char cName[68];
int iMeshFrameNum; // number of frames in mesh
int iTextureNum; // number of textures=skins in this mesh
int iVertexNum; // number of vertices in this mesh
int iTriangleNum; // number of triangles
int iTriangleStart; // starting position of triangle data, relative to the start of MD3Mesh
int iHeaderSize; // Headersize = starting position of texture data
int iTecVecStart; // starting position of the texture vector data
int iVertexStart; // starting position of the vertex data
int iMeshSize;
} MD3MESHFILE;
typedef struct
{
SHORT vec[3];
UCHAR unknown;
} MD3VERTEX;
typedef struct
{
char cName[68]; // 65 chars, 32-bit aligned == 68 chars in file
int iNumVertices; // Mesh vertices
int iMeshFrameNum; // animation frames in mesh
VMESHFRAME *vMeshFrames; // stores vertices per animation frame in
// vertices[FrameNum][VertexNum]
int iNumTriangles; // Mesh triangles
TRIANGLEVERT *pTriangles;
int iNumTextures; // Mesh textures
TEXNAMES *pTexNames;
LPDIRECT3DTEXTURE8* pTexturesInterfaces;
TEXCOORDS *pfTextureCoords; // Mesh tex coordinates
TEXCOORDS *pfEnvTextureCoords; // not used here
} MD3MESH;
class CMD3Model
{
private:
int iNumMeshes;
MD3MESH *pMd3Meshes;
MD3BONEFRAME *md3BoneFrame;
MD3TAG **md3Tags;
FILE *LogFile; // the log file for md3 geometry data.txt
// and md3 textures.txt
LPDIRECT3DVERTEXBUFFER8 m_pVB; // Buffer to hold vertices
long ReadLong(FILE* File); // file i/o helper
short ReadShort(FILE* File);
FLOAT ReadFloat(FILE* File);
void CreateVB(LPDIRECT3DDEVICE8 lpD3Ddevice); // vertex buffer system
void DeleteVB();
void CreateTextures(LPDIRECT3DDEVICE8 lpD3Ddevice); // texture system
void DeleteTextures();
public:
BOOL CreateModel( char *fname, LPDIRECT3DDEVICE8 lpD3Ddevice); // class methods
void DeleteModel();
void InitDeviceObjects(LPDIRECT3DDEVICE8 lpD3Ddevice);
void DeleteDeviceObjects();
void Render(LPDIRECT3DDEVICE8 lpD3Ddevice);
CMD3Model(); // constructor/destructor
~CMD3Model();
};
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -