/*! * @file md2Model.h * Definition of an MD2 Model, a model format invented by ID Software. We are deeply thankfull for all the wunderfull things id software made for us gamers! The md2 file format is structured in a very simple way: it contains animations which are made out of frames (so called keyframes). Each frame is a complete draweable model in a specific position. A frame is a collection of vertex and its compagnions (normals, texture coordinates). A typical model has about 200 frames, the maximum frame count is fixed by MD2_MAX_FRAMES to currently 512 frames. The maximal vetices count is set to 2048 verteces, not enough? You just have to change the MD2_MAX_* values if it doesn't fit your purposes... Surface Culling is fully implemented in md2 models: quake2 uses front face culling. */ #ifndef _MD3_DATA_H #define _MD3_DATA_H #include "base_object.h" #include "model.h" #include "material.h" #include "md_model_structure.h" //! These are the needed defines for the max values when loading .MD2 files #define MD3_IDENT (('3'<<24) + ('P'<<16) + ('D'<<8) + 'I') //!< the md3 identifier tag in the bin file #define MD3_VERSION 15 //!< the md2 version in the header #define MD2_MAX_TRIANGLES 4096 //!< maximal triangles count #define MD2_MAX_VERTICES 2048 //!< maximal vertices count #define MD2_MAX_TEXCOORDS 2048 //!< maximal tex coordinates #define MD2_MAX_FRAMES 512 //!< maximal frames #define MD2_MAX_SKINS 32 //!< maximal skins #define MD2_MAX_FRAMESIZE (MD2_MAX_VERTICES * 4 + 128) //!< maximal framesize #define NUM_VERTEX_NORMALS 162 //!< number of vertex normals #define SHADEDOT_QUANT 16 //!< shade dot quantity - no idea what it is //! This stores the speed of the animation between each key frame - currently conflicting with the animation framework #define kAnimationSpeed 12.0f //!< animation speed namespace md3 { class MD3BoneFrame; class MD3Mesh; //! This holds the header information that is read in at the beginning of the file: id software definition struct MD3Header { int ident; //!< This is used to identify the file int version; //!< The version number of the file (Must be 8) char filename[68]; //!< The filename of the model int boneFrameNum; //!< number of frames int tagNum; //!< number of tags int meshNum; //!< number of mesh int maxTexNum; //!< number of texture int boneFrameStart; //!< start of bone frames int tagStart; //!< start of the tag int meshStart; //!< mesh start int fileSize; //!< file size }; //! class to store the md2 data in class MD3Data : public BaseObject { public: MD3Data(const std::string& modelFileName, const std::string& skinFileName, float scale = 1.0f); virtual ~MD3Data(); private: bool loadModel(const std::string& fileName); bool loadSkin(const std::string& fileName = ""); int readHeader(FILE* pFile, int fileOffset); int readBoneFrames(FILE* pFile, int fileOffset); int readTags(FILE* pFile, int fileOffset); int readMeshes(FILE* pFile, int fileOffset); int readMeshTriangles(FILE* pFile, int fileOffset, int mesh); int readMeshTextures(FILE* pFile, int fileOffset, int mesh); int readMeshTexVecs(FILE* pFile, int fileOffset, int mesh); int readMeshVertices(FILE* pFile, int fileOffset, int mesh); public: MD3Header* header; //!< the header file std::string filename; //!< the name of the file as recorded in the .md3 file std::string loadFilename; //!< filename of the actual file from which data was loaded int boneFrameNum; //!< number of anumation key fames in the models int tagNum; //!< number of tags int meshNum; //!< number of meshes int maxTextureNum; //!< maximum number of unique used in an md3 file int boneFrameStart; //!< starting position of bone frame data structures int tagStart; //!< starting position of tag-structures int meshStart; //!< starting position of mesh structures int fileSize; //!< file size MD3BoneFrame** boneFrames; //!< array of bone frames, contains the metadata (bounding box, tags,...) for each frame MD3Mesh** meshes; //!< array of meshes in the model. each containing the mesh for each of the animation int parentTagIndex; //!< tag index //MD3Model* parent; //!< reference to the MD3Model }; } #endif /* _MD3_DATA_H */