Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/md2_loader/src/lib/graphics/importer/md2Model.h @ 4072

Last change on this file since 4072 was 4072, checked in by patrick, 19 years ago

orxonox/branches/md2_loader: implemented some data formats used by the md2 loader, altered debug levels, and commented out all the debug() functions. This branche won't run on you computer unless you have the fonts and models installed i use temporary for testing purposes

File size: 2.8 KB
Line 
1/*!
2    \file md2Model.h
3    \brief 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*/
8
9#ifndef _MD2MODEL_H
10#define _MD2MODEL_H
11
12#include "abstract_model.h"
13
14
15//! These are the needed defines for the max values when loading .MD2 files
16#define MD2_MAX_TRIANGLES               4096
17#define MD2_MAX_VERTICES                2048
18#define MD2_MAX_TEXCOORDS               2048
19#define MD2_MAX_FRAMES                  512
20#define MD2_MAX_SKINS                   32
21#define MD2_MAX_FRAMESIZE               (MD2_MAX_VERTICES * 4 + 128)
22
23//! This holds the header information that is read in at the beginning of the file
24struct tMd2Header
25{ 
26   int magic;                                   //!< This is used to identify the file
27   int version;                                 //!< The version number of the file (Must be 8)
28   int skinWidth;                               //!< The skin width in pixels
29   int skinHeight;                              //!< The skin height in pixels
30   int frameSize;                               //!< The size in bytes the frames are
31   int numSkins;                                //!< The number of skins associated with the model
32   int numVertices;                             //!< The number of vertices (constant for each frame)
33   int numTexCoords;                    //!< The number of texture coordinates
34   int numTriangles;                    //!< The number of faces (polygons)
35   int numGlCommands;                   //!< The number of gl commands
36   int numFrames;                               //!< The number of animation frames
37   int offsetSkins;                             //!< The offset in the file for the skin data
38   int offsetTexCoords;                 //!< The offset in the file for the texture data
39   int offsetTriangles;                 //!< The offset in the file for the face data
40   int offsetFrames;                    //!< The offset in the file for the frames data
41   int offsetGlCommands;                //!< The offset in the file for the gl commands data
42   int offsetEnd;                               //!< The end of the file offset
43};
44
45
46//! This is used to store the vertices that are read in for the current frame directly from the file (compressed)
47struct tMd2AliasTriangle
48{
49   byte vertex[3];
50   byte lightNormalIndex;
51};
52
53//! This stores the normals and vertices for the frames (uncompressed)
54struct tMd2Triangle
55{
56   float vertex[3];
57   float normal[3];
58};
59
60//! This stores the indices into the vertex and texture coordinate arrays
61struct tMd2Face
62{
63   short vertexIndices[3];
64   short textureIndices[3];
65};
66
67//! This stores UV coordinates
68struct tMd2TexCoord
69{
70   short u, v;
71};
72
73// This stores the animation scale, translation and name information for a frame, plus verts
74struct tMd2AliasFrame
75{
76   float scale[3];
77   float translate[3];
78   char name[16];
79   tMd2AliasTriangle aliasVertices[1];
80};
81
82// This stores the frames vertices after they have been transformed
83struct tMd2Frame
84{
85   char strName[16];
86   tMd2Triangle *pVertices;
87};
88
89// This stores a skin name
90typedef char tMd2Skin[64];
91
92
93//! A class for representating a MD2Model
94class MD2Model : public AbstractModel {
95
96 public:
97  MD2Model();
98  virtual ~MD2Model();
99
100
101};
102
103#endif /* _MD2MODEL_H */
Note: See TracBrowser for help on using the repository browser.