Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/bsp_model/src/lib/graphics/importer/md3/md3_data.h @ 8547

Last change on this file since 8547 was 8547, checked in by patrick, 18 years ago

bsp: working on sorted maps for model links

File size: 4.2 KB
Line 
1/*!
2 * @file md2Model.h
3  *  Definition of an MD2 Model, a model format invented by ID Software.
4
5    We are deeply thankfull for all the wunderfull things id software made for us gamers!
6
7    The md2 file format is structured in a very simple way: it contains animations which are made out of
8    frames (so called keyframes). Each frame is a complete draweable model in a specific position.
9    A frame is a collection of vertex and its compagnions (normals, texture coordinates).
10
11    A typical model has about 200 frames, the maximum frame count is fixed by MD2_MAX_FRAMES to currently
12    512 frames. The maximal vetices count is set to 2048 verteces, not enough?
13    You just have to change the MD2_MAX_* values if it doesn't fit your purposes...
14
15    Surface Culling is fully implemented in md2 models: quake2 uses front face culling.
16*/
17
18#ifndef _MD3_DATA_H
19#define _MD3_DATA_H
20
21#include "base_object.h"
22
23#include "model.h"
24#include "material.h"
25#include "md_model_structure.h"
26
27#include <map>
28
29
30//! These are the needed defines for the max values when loading .MD2 files
31#define MD3_IDENT                       (('3'<<24) + ('P'<<16) + ('D'<<8) + 'I') //!< the md3 identifier tag in the bin file
32#define MD3_VERSION                     15                                       //!< the md2 version in the header
33
34
35
36namespace md3
37{
38
39  class MD3BoneFrame;
40  class MD3Mesh;
41
42//! This holds the header information that is read in at the beginning of the file: id software definition
43struct MD3Header
44{
45   int ident;                           //!< This is used to identify the file
46   int version;                         //!< The version number of the file (Must be 8)
47
48   char filename[68];                   //!< The filename of the model
49
50   int boneFrameNum;                    //!< number of frames
51   int tagNum;                          //!< number of tags
52   int meshNum;                         //!< number of mesh
53   int maxTexNum;                       //!< number of texture
54
55   int boneFrameStart;                  //!< start of bone frames
56   int tagStart;                        //!< start of the tag
57   int meshStart;                       //!< mesh start
58
59   int fileSize;                        //!< file size
60};
61
62
63
64//! class to store the md2 data in
65class MD3Data : public BaseObject
66{
67 public:
68   MD3Data(const std::string& modelFileName, const std::string& skinFileName, float scale = 1.0f);
69  virtual ~MD3Data();
70
71
72 private:
73   bool loadModel(const std::string& fileName);
74   bool loadSkin(const std::string& fileName = "");
75
76   int readHeader(FILE* pFile, int fileOffset);
77   int readBoneFrames(FILE* pFile, int fileOffset);
78   int readTags(FILE* pFile, int fileOffset);
79   int readMeshes(FILE* pFile, int fileOffset);
80
81
82   int readMeshTriangles(FILE* pFile, int fileOffset, int mesh);
83   int readMeshTextures(FILE* pFile, int fileOffset, int mesh);
84   int readMeshTexVecs(FILE* pFile, int fileOffset, int mesh);
85   int readMeshVertices(FILE* pFile, int fileOffset, int mesh);
86
87 public:
88
89  MD3Header*          header;            //!< the header file
90
91  std::string         filename;          //!< the name of the file as recorded in the .md3 file
92  std::string         loadFilename;      //!< filename of the actual file from which data was loaded
93
94  int                 boneFrameNum;      //!< number of anumation key fames in the models
95  int                 tagNum;            //!< number of tags
96  int                 meshNum;           //!< number of meshes
97
98  int                 maxTextureNum;     //!< maximum number of unique used in an md3 file
99  int                 boneFrameStart;    //!< starting position of bone frame data structures
100  int                 tagStart;          //!< starting position of tag-structures
101
102  int                 meshStart;         //!< starting position of mesh structures
103
104  int                 fileSize;          //!< file size
105
106
107  MD3BoneFrame**      boneFrames;        //!< array of bone frames, contains the metadata (bounding box, tags,...) for each frame
108  MD3Mesh**           meshes;            //!< array of meshes in the model. each containing the mesh for each of the animation
109
110  int                 parentTagIndex;    //!< tag index
111
112  //MD3Model*           parent;            //!< reference to the MD3Model
113
114
115};
116
117
118}
119
120
121
122#endif /* _MD3_DATA_H */
Note: See TracBrowser for help on using the repository browser.