doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Model_md3.h
Go to the documentation of this file.
1 /*
2 ===========================================================================
3 
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
6 
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
8 
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13 
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
21 
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
23 
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
25 
26 ===========================================================================
27 */
28 
29 #ifndef __MODEL_MD3_H__
30 #define __MODEL_MD3_H__
31 
32 /*
33 ========================================================================
34 
35 .MD3 triangle model file format
36 
37 Private structures used by the MD3 loader.
38 
39 ========================================================================
40 */
41 
42 #define MD3_IDENT (('3'<<24)+('P'<<16)+('D'<<8)+'I')
43 #define MD3_VERSION 15
44 
45 // surface geometry should not exceed these limits
46 #define SHADER_MAX_VERTEXES 1000
47 #define SHADER_MAX_INDEXES (6*SHADER_MAX_VERTEXES)
48 
49 // limits
50 #define MD3_MAX_LODS 4
51 #define MD3_MAX_TRIANGLES 8192 // per surface
52 #define MD3_MAX_VERTS 4096 // per surface
53 #define MD3_MAX_SHADERS 256 // per surface
54 #define MD3_MAX_FRAMES 1024 // per model
55 #define MD3_MAX_SURFACES 32 // per model
56 #define MD3_MAX_TAGS 16 // per frame
57 #define MAX_MD3PATH 64 // from quake3
58 
59 // vertex scales
60 #define MD3_XYZ_SCALE (1.0/64)
61 
62 typedef struct md3Frame_s {
63  idVec3 bounds[2];
65  float radius;
66  char name[16];
67 } md3Frame_t;
68 
69 typedef struct md3Tag_s {
70  char name[MAX_MD3PATH]; // tag name
71  idVec3 origin;
72  idVec3 axis[3];
73 } md3Tag_t;
74 
75 /*
76 ** md3Surface_t
77 **
78 ** CHUNK SIZE
79 ** header sizeof( md3Surface_t )
80 ** shaders sizeof( md3Shader_t ) * numShaders
81 ** triangles[0] sizeof( md3Triangle_t ) * numTriangles
82 ** st sizeof( md3St_t ) * numVerts
83 ** XyzNormals sizeof( md3XyzNormal_t ) * numVerts * numFrames
84 */
85 
86 typedef struct md3Surface_s {
87  int ident; //
88 
89  char name[MAX_MD3PATH]; // polyset name
90 
91  int flags;
92  int numFrames; // all surfaces in a model should have the same
93 
94  int numShaders; // all surfaces in a model should have the same
95  int numVerts;
96 
99 
100  int ofsShaders; // offset from start of md3Surface_t
101  int ofsSt; // texture coords are common for all frames
102  int ofsXyzNormals; // numVerts * numFrames
103 
104  int ofsEnd; // next surface follows
105 } md3Surface_t;
106 
107 typedef struct {
108  char name[MAX_MD3PATH];
109  const idMaterial * shader; // for in-game use
110 } md3Shader_t;
111 
112 typedef struct {
113  int indexes[3];
114 } md3Triangle_t;
115 
116 typedef struct {
117  float st[2];
118 } md3St_t;
119 
120 typedef struct {
121  short xyz[3];
122  short normal;
124 
125 typedef struct md3Header_s {
126  int ident;
127  int version;
128 
129  char name[MAX_MD3PATH]; // model name
130 
131  int flags;
132 
134  int numTags;
136 
137  int numSkins;
138 
139  int ofsFrames; // offset for first frame
140  int ofsTags; // numFrames * numTags
141  int ofsSurfaces; // first surface, others follow
142 
143  int ofsEnd; // end of file
144 } md3Header_t;
145 
146 #endif /* !__MODEL_MD3_H__ */
int ofsTriangles
Definition: Model_md3.h:98
struct md3Frame_s md3Frame_t
struct md3Tag_s md3Tag_t
int ofsXyzNormals
Definition: Model_md3.h:102
int numTriangles
Definition: Model_md3.h:97
const idMaterial * shader
Definition: Model_md3.h:109
struct md3Surface_s md3Surface_t
#define MAX_MD3PATH
Definition: Model_md3.h:57
Definition: Vector.h:316
int ofsSurfaces
Definition: Model_md3.h:141
int numFrames
Definition: Model_md3.h:92
idVec3 bounds[2]
Definition: exporter.h:261
int numSurfaces
Definition: Model_md3.h:135
int ofsFrames
Definition: Model_md3.h:139
int numSkins
Definition: Model_md3.h:137
idVec3 origin
Definition: exporter.h:269
float radius
Definition: exporter.h:263
int ofsShaders
Definition: Model_md3.h:100
int numShaders
Definition: Model_md3.h:94
int numVerts
Definition: Model_md3.h:95
const GLcharARB * name
Definition: glext.h:3629
GLfloat * st
Definition: qgl.h:89
idVec3 localOrigin
Definition: exporter.h:262
struct md3Header_s md3Header_t
int numFrames
Definition: Model_md3.h:133
idVec3 axis[3]
Definition: exporter.h:270