📄 md2.h
字号:
#ifndef __MD2_H
#define __MD2_H
#include "texture.h"
#define MAX_FRAMES 512
/*
enum texTypes_t
{
PCX,
BMP,
TGA
};
typedef struct
{
// C Compatible version: enum texTypes textureType;
// We use C++ only version
texTypes_t textureType;
int width; // width of texture
int height; // height of texture
long int scaledWidth;
long int scaledHeight;
unsigned int texID; // the texture object id of this texture
unsigned char *data; // the texture data
unsigned char *palette;
} texture_t;
// only partial pcx file header
typedef struct
{
unsigned char manufacturer;
unsigned char version;
unsigned char encoding;
unsigned char bits;
unsigned char xMin;
unsigned char yMin;
unsigned char xMax;
unsigned char yMax;
unsigned char *palette;
} PCXHEADER;
*/
// a single vertex
typedef struct
{
float point[3];
} vector_t;
/*
vector_t operator-(vector_t a, vector_t b)
{
vector_t c;
c.point[0] = a.point[0] - b.point[0];
c.point[1] = a.point[1] - b.point[1];
c.point[2] = a.point[2] - b.point[2];
return c;
}
vector_t operator*(float f, vector_t b)
{
vector_t c;
c.point[0] = f * b.point[0];
c.point[1] = f * b.point[1];
c.point[2] = f * b.point[2];
return c;
}
// vector division
vector_t operator/(vector_t a, vector_t b)
{
vector_t c;
c.point[0] = a.point[0] / b.point[0];
c.point[1] = a.point[1] / b.point[1];
c.point[2] = a.point[2] / b.point[2];
return c;
}
vector_t operator+(vector_t a, vector_t b)
{
vector_t c;
c.point[0] = a.point[0] + b.point[0];
c.point[1] = a.point[1] + b.point[1];
c.point[2] = a.point[2] + b.point[2];
return c;
}
*/
// texture coordinate
typedef struct
{
float s;
float t;
} texCoord_t;
// texture coordinate index
typedef struct
{
short s;
short t;
} stIndex_t;
// info for a single frame point
typedef struct
{
unsigned char v[3];
unsigned char normalIndex; // not used
} framePoint_t;
// information for a single frame
typedef struct
{
float scale[3];
float translate[3];
char name[16];
framePoint_t fp[1];
} frame_t;
// data for a single triangle
typedef struct
{
unsigned short meshIndex[3]; // vertex indices
unsigned short stIndex[3]; // texture coordinate indices
} mesh_t;
// the model data
typedef struct
{
int numFrames; // number of frames
int numPoints; // number of points
int numTriangles; // number of triangles
int numST; // number of skins
int frameSize; // size of each frame in bytes
int texWidth, texHeight; // texture width, height
int currentFrame; // current frame # in animation
int nextFrame; // next frame # in animation
float interpol; // percent through current frame
mesh_t *triIndex; // triangle list
texCoord_t *st; // texture coordinate list
vector_t *pointList; // vertex list
texture_t *modelTex; // texture data
} modelData_t;
typedef struct
{
int ident; // identifies as MD2 file "IDP2"
int version; // mine is 8
int skinwidth; // width of texture
int skinheight; // height of texture
int framesize; // number of bytes per frame
int numSkins; // number of textures
int numXYZ; // number of points
int numST; // number of texture
int numTris; // number of triangles
int numGLcmds;
int numFrames; // total number of frames
int offsetSkins; // offset to skin names (64 bytes each)
int offsetST; // offset of texture s-t values
int offsetTris; // offset of triangle mesh
int offsetFrames; // offset of frame data (points)
int offsetGLcmds; // type of OpenGL commands to use
int offsetEnd; // end of file
} modelHeader_t;
//void FreeModel(modelData_t *model);
extern"C"{ void Initialize();
void Render();
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -