|
@@ -1,6 +1,6 @@
|
1
|
1
|
/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: t; c-basic-offset: 3 -*- */
|
2
|
2
|
/*==========================================================================
|
3
|
|
- *
|
|
3
|
+ *
|
4
|
4
|
* Project : Freyja
|
5
|
5
|
* Author : Terry 'Mongoose' Hendrix II
|
6
|
6
|
* Website : http://gooseegg.sourceforge.net
|
|
@@ -17,11 +17,11 @@
|
17
|
17
|
* so - since this class is desgined using their specs...
|
18
|
18
|
*
|
19
|
19
|
*-- Test Defines -----------------------------------------------------
|
20
|
|
- *
|
21
|
|
- * UNIT_TEST_MD3 - Builds Md3 class as a console unit test program
|
|
20
|
+ *
|
|
21
|
+ * UNIT_TEST_MD3 - Builds Md3 class as a console unit test program
|
22
|
22
|
* UNIT_TEST_MD3_LV2 - Does more debugging when used with unit test
|
23
|
23
|
*
|
24
|
|
- *-- History ----------------------------------------------------------
|
|
24
|
+ *-- History ----------------------------------------------------------
|
25
|
25
|
*
|
26
|
26
|
* 2002.10.19:
|
27
|
27
|
* Mongoose - Interface update, Animation support starts
|
|
@@ -53,21 +53,21 @@ typedef float mat3_t[3][3];
|
53
|
53
|
|
54
|
54
|
typedef struct md3_tag_s
|
55
|
55
|
{
|
56
|
|
- char name[64]; /* Name of 'tag' as it's usually
|
57
|
|
- called in the md3 files try to
|
58
|
|
- see it as a sub-mesh/seperate
|
59
|
|
- mesh-part.
|
60
|
|
-
|
61
|
|
- Sometimes this 64 string may
|
62
|
|
- contain some garbage, but
|
|
56
|
+ char name[64]; /* Name of 'tag' as it's usually
|
|
57
|
+ called in the md3 files try to
|
|
58
|
+ see it as a sub-mesh/seperate
|
|
59
|
+ mesh-part.
|
|
60
|
+
|
|
61
|
+ Sometimes this 64 string may
|
|
62
|
+ contain some garbage, but
|
63
|
63
|
i've been told this is because
|
64
|
64
|
some tools leave garbage in
|
65
|
65
|
those strings, but they ARE
|
66
|
66
|
strings... */
|
67
|
67
|
|
68
|
68
|
vec3_t center; /* Relative position of tag */
|
69
|
|
-
|
70
|
|
- mat3_t rotation; /* The direction the tag is facing
|
|
69
|
+
|
|
70
|
+ mat3_t rotation; /* The direction the tag is facing
|
71
|
71
|
relative to the rest of the model */
|
72
|
72
|
|
73
|
73
|
} md3_tag_t;
|
|
@@ -79,7 +79,7 @@ typedef struct md3_boneframe_s
|
79
|
79
|
float maxs[3];
|
80
|
80
|
float center[3];
|
81
|
81
|
float scale;
|
82
|
|
- char creator[16];
|
|
82
|
+ char creator[16];
|
83
|
83
|
|
84
|
84
|
} md3_bone_t;
|
85
|
85
|
|
|
@@ -87,7 +87,7 @@ typedef struct md3_boneframe_s
|
87
|
87
|
typedef struct md3_skin_s
|
88
|
88
|
{
|
89
|
89
|
char name[68]; /* Name of skin used by mesh
|
90
|
|
- 65 chars,
|
|
90
|
+ 65 chars,
|
91
|
91
|
32 bit aligned == 68 chars */
|
92
|
92
|
|
93
|
93
|
int index; /* For shader use (skin is a shader) */
|
|
@@ -113,10 +113,10 @@ typedef struct md3_vertex_s
|
113
|
113
|
{
|
114
|
114
|
signed short pos[3]; /* Vertex X/Y/Z coordinate */
|
115
|
115
|
|
116
|
|
- unsigned char st[2]; /* Enviromental mapping
|
117
|
|
- texture coordinates
|
|
116
|
+ unsigned char st[2]; /* Enviromental mapping
|
|
117
|
+ texture coordinates
|
118
|
118
|
(Acutally encoded normal?) */
|
119
|
|
-
|
|
119
|
+
|
120
|
120
|
float norm[3]; /* Decoded normal from above decoded */
|
121
|
121
|
|
122
|
122
|
} md3_vertex_t;
|
|
@@ -128,37 +128,37 @@ typedef struct md3_mesh_s
|
128
|
128
|
|
129
|
129
|
char id[4]; /* Mesh alias id, must be IDP3 */
|
130
|
130
|
|
131
|
|
- char name[68]; /* Name of mesh
|
|
131
|
+ char name[68]; /* Name of mesh
|
132
|
132
|
65 chars,
|
133
|
133
|
32 bit aligned == 68 chars */
|
134
|
134
|
int flags;
|
135
|
135
|
|
136
|
136
|
|
137
|
|
- int num_frames; /* Number of VertexMorph frames
|
|
137
|
+ int num_frames; /* Number of VertexMorph frames
|
138
|
138
|
in mesh */
|
139
|
139
|
|
140
|
140
|
int num_shaders; /* Number of shaders in mesh*/
|
141
|
141
|
|
142
|
|
- int num_skins; /* Number of skins in mesh,
|
|
142
|
+ int num_skins; /* Number of skins in mesh,
|
143
|
143
|
for backwards compatibility with
|
144
|
144
|
incorrect/obsolete spec */
|
145
|
145
|
|
146
|
146
|
int num_vertices; /* Number of vertices */
|
147
|
|
-
|
|
147
|
+
|
148
|
148
|
int num_triangles; /* Number of triangles */
|
149
|
|
-
|
150
|
|
- int tris_offset; /* Starting position of
|
151
|
|
- Triangle data, relative
|
|
149
|
+
|
|
150
|
+ int tris_offset; /* Starting position of
|
|
151
|
+ Triangle data, relative
|
152
|
152
|
to start of Mesh_Header */
|
153
|
153
|
|
154
|
154
|
int header_size; /* Size of header */
|
155
|
|
-
|
156
|
|
- int texel_offset; /* Starting position of
|
157
|
|
- texvector data, relative
|
|
155
|
+
|
|
156
|
+ int texel_offset; /* Starting position of
|
|
157
|
+ texvector data, relative
|
158
|
158
|
to start of Mesh_Header */
|
159
|
|
-
|
160
|
|
- int vertex_offset; /* Starting position of
|
161
|
|
- vertex data,relative
|
|
159
|
+
|
|
160
|
+ int vertex_offset; /* Starting position of
|
|
161
|
+ vertex data,relative
|
162
|
162
|
to start of Mesh_Header */
|
163
|
163
|
|
164
|
164
|
int mesh_size; /* Size of mesh */
|
|
@@ -171,7 +171,7 @@ typedef struct md3_mesh_s
|
171
|
171
|
md3_tri_index_t *tris; /* Triangles */
|
172
|
172
|
|
173
|
173
|
md3_texel_t *texel; /* Texels */
|
174
|
|
-
|
|
174
|
+
|
175
|
175
|
md3_vertex_t *vertex; /* Vertices */
|
176
|
176
|
|
177
|
177
|
} md3_mesh_t;
|
|
@@ -192,7 +192,7 @@ public:
|
192
|
192
|
|
193
|
193
|
Md3();
|
194
|
194
|
/*------------------------------------------------------
|
195
|
|
- * Pre :
|
|
195
|
+ * Pre :
|
196
|
196
|
* Post : Md3 object is constructed
|
197
|
197
|
*
|
198
|
198
|
*-- History ------------------------------------------
|
|
@@ -230,10 +230,10 @@ public:
|
230
|
230
|
////////////////////////////////////////////////////////////
|
231
|
231
|
// Public Accessors
|
232
|
232
|
////////////////////////////////////////////////////////////
|
233
|
|
-
|
|
233
|
+
|
234
|
234
|
unsigned int getNumMeshes();
|
235
|
235
|
/*------------------------------------------------------
|
236
|
|
- * Pre :
|
|
236
|
+ * Pre :
|
237
|
237
|
* Post : Mesh count is returned
|
238
|
238
|
*
|
239
|
239
|
*-- History ------------------------------------------
|
|
@@ -245,7 +245,7 @@ public:
|
245
|
245
|
|
246
|
246
|
unsigned int getNumTags();
|
247
|
247
|
/*------------------------------------------------------
|
248
|
|
- * Pre :
|
|
248
|
+ * Pre :
|
249
|
249
|
* Post : Tag count is returned
|
250
|
250
|
*
|
251
|
251
|
*-- History ------------------------------------------
|
|
@@ -254,10 +254,10 @@ public:
|
254
|
254
|
* Mongoose - Created, Obsoletes:
|
255
|
255
|
* 2000.06.03, int NumTags();
|
256
|
256
|
------------------------------------------------------*/
|
257
|
|
-
|
|
257
|
+
|
258
|
258
|
unsigned int getNumBones();
|
259
|
259
|
/*------------------------------------------------------
|
260
|
|
- * Pre :
|
|
260
|
+ * Pre :
|
261
|
261
|
* Post : Bone count is returned
|
262
|
262
|
*
|
263
|
263
|
*-- History ------------------------------------------
|
|
@@ -269,7 +269,7 @@ public:
|
269
|
269
|
|
270
|
270
|
md3_mesh_t *getMeshes();
|
271
|
271
|
/*------------------------------------------------------
|
272
|
|
- * Pre :
|
|
272
|
+ * Pre :
|
273
|
273
|
* Post : Mesh list is returned
|
274
|
274
|
*
|
275
|
275
|
*-- History ------------------------------------------
|
|
@@ -278,10 +278,10 @@ public:
|
278
|
278
|
* Mongoose - Created, Obsoletes:
|
279
|
279
|
* 2000.06.03, md3_mesh_t *Mesh();
|
280
|
280
|
------------------------------------------------------*/
|
281
|
|
-
|
|
281
|
+
|
282
|
282
|
md3_tag_t *getTags();
|
283
|
283
|
/*------------------------------------------------------
|
284
|
|
- * Pre :
|
|
284
|
+ * Pre :
|
285
|
285
|
* Post : Tag list is returned
|
286
|
286
|
*
|
287
|
287
|
*-- History ------------------------------------------
|
|
@@ -290,10 +290,10 @@ public:
|
290
|
290
|
* Mongoose - Created, Obsoletes:
|
291
|
291
|
* 2000.06.03, md3_tag_t *Tag();
|
292
|
292
|
------------------------------------------------------*/
|
293
|
|
-
|
|
293
|
+
|
294
|
294
|
md3_bone_t *getBones();
|
295
|
295
|
/*------------------------------------------------------
|
296
|
|
- * Pre :
|
|
296
|
+ * Pre :
|
297
|
297
|
* Post : Bone list is returned
|
298
|
298
|
*
|
299
|
299
|
*-- History ------------------------------------------
|
|
@@ -307,10 +307,10 @@ public:
|
307
|
307
|
////////////////////////////////////////////////////////////
|
308
|
308
|
// Public Mutators
|
309
|
309
|
////////////////////////////////////////////////////////////
|
310
|
|
-
|
|
310
|
+
|
311
|
311
|
void toggleFlag(Md3Flag flag);
|
312
|
312
|
/*------------------------------------------------------
|
313
|
|
- * Pre :
|
|
313
|
+ * Pre :
|
314
|
314
|
* Post : Toggles a flag
|
315
|
315
|
*
|
316
|
316
|
*-- History ------------------------------------------
|
|
@@ -321,7 +321,7 @@ public:
|
321
|
321
|
|
322
|
322
|
void reset();
|
323
|
323
|
/*------------------------------------------------------
|
324
|
|
- * Pre :
|
|
324
|
+ * Pre :
|
325
|
325
|
* Post : Resets all model data
|
326
|
326
|
*
|
327
|
327
|
*-- History ------------------------------------------
|
|
@@ -332,7 +332,7 @@ public:
|
332
|
332
|
|
333
|
333
|
void setDebug(unsigned char level);
|
334
|
334
|
/*------------------------------------------------------
|
335
|
|
- * Pre :
|
|
335
|
+ * Pre :
|
336
|
336
|
* Post : level 0 = errors, 1 = warnings, 2 = debug1
|
337
|
337
|
*
|
338
|
338
|
*-- History ------------------------------------------
|
|
@@ -343,7 +343,7 @@ public:
|
343
|
343
|
|
344
|
344
|
int load(char *filename);
|
345
|
345
|
/*------------------------------------------------------
|
346
|
|
- * Pre :
|
|
346
|
+ * Pre :
|
347
|
347
|
* Post : Error code is returned, 0 no error
|
348
|
348
|
* Md3 filename is read into memory
|
349
|
349
|
*
|
|
@@ -355,7 +355,7 @@ public:
|
355
|
355
|
|
356
|
356
|
int save(char *filename);
|
357
|
357
|
/*------------------------------------------------------
|
358
|
|
- * Pre :
|
|
358
|
+ * Pre :
|
359
|
359
|
* Post : Error code is returned, 0 no error
|
360
|
360
|
* Md3 saved as filename
|
361
|
361
|
*
|
|
@@ -377,7 +377,7 @@ public:
|
377
|
377
|
unsigned int nextFrame;
|
378
|
378
|
float time;
|
379
|
379
|
float lastTime;
|
380
|
|
-
|
|
380
|
+
|
381
|
381
|
private:
|
382
|
382
|
|
383
|
383
|
////////////////////////////////////////////////////////////
|
|
@@ -389,9 +389,9 @@ private:
|
389
|
389
|
// Private Mutators
|
390
|
390
|
////////////////////////////////////////////////////////////
|
391
|
391
|
|
392
|
|
- void printError(char *method, char *s, ...);
|
|
392
|
+ void printError(const char *method, const char *s, ...);
|
393
|
393
|
/*------------------------------------------------------
|
394
|
|
- * Pre :
|
|
394
|
+ * Pre :
|
395
|
395
|
* Post : Dumps error to stderr
|
396
|
396
|
*
|
397
|
397
|
*-- History ------------------------------------------
|
|
@@ -400,9 +400,9 @@ private:
|
400
|
400
|
* Mongoose - Created
|
401
|
401
|
------------------------------------------------------*/
|
402
|
402
|
|
403
|
|
- void printWarning(char *method, char *s, ...);
|
|
403
|
+ void printWarning(const char *method, const char *s, ...);
|
404
|
404
|
/*------------------------------------------------------
|
405
|
|
- * Pre :
|
|
405
|
+ * Pre :
|
406
|
406
|
* Post : Dumps warning to stderr
|
407
|
407
|
*
|
408
|
408
|
*-- History ------------------------------------------
|
|
@@ -411,7 +411,7 @@ private:
|
411
|
411
|
* Mongoose - Created
|
412
|
412
|
------------------------------------------------------*/
|
413
|
413
|
|
414
|
|
- void printDebug(char *method, char *s, ...);
|
|
414
|
+ void printDebug(const char *method, const char *s, ...);
|
415
|
415
|
/*------------------------------------------------------
|
416
|
416
|
* Pre : Debugging is on
|
417
|
417
|
* Post : Dumps debug info
|
|
@@ -425,7 +425,7 @@ private:
|
425
|
425
|
void createMeshes(unsigned int num);
|
426
|
426
|
/*------------------------------------------------------
|
427
|
427
|
* Pre : Model hasn't been init yet
|
428
|
|
- * Post : Allocates num of meshes for model
|
|
428
|
+ * Post : Allocates num of meshes for model
|
429
|
429
|
*
|
430
|
430
|
*-- History ------------------------------------------
|
431
|
431
|
*
|
|
@@ -438,7 +438,7 @@ private:
|
438
|
438
|
void createTags(unsigned int num);
|
439
|
439
|
/*------------------------------------------------------
|
440
|
440
|
* Pre : Model hasn't been init yet
|
441
|
|
- * Post : Allocates num of tags for model
|
|
441
|
+ * Post : Allocates num of tags for model
|
442
|
442
|
*
|
443
|
443
|
*-- History ------------------------------------------
|
444
|
444
|
*
|
|
@@ -451,7 +451,7 @@ private:
|
451
|
451
|
void createBones(unsigned int num);
|
452
|
452
|
/*------------------------------------------------------
|
453
|
453
|
* Pre : Model hasn't been init yet
|
454
|
|
- * Post : Allocates num of bones for model
|
|
454
|
+ * Post : Allocates num of bones for model
|
455
|
455
|
*
|
456
|
456
|
*-- History ------------------------------------------
|
457
|
457
|
*
|
|
@@ -471,26 +471,26 @@ private:
|
471
|
471
|
|
472
|
472
|
int m_version; /* Version number, always 15 */
|
473
|
473
|
|
474
|
|
- char m_filename[68]; /* Sometimes left blank...
|
475
|
|
- 65 chars, 32bit aligned ==
|
|
474
|
+ char m_filename[68]; /* Sometimes left blank...
|
|
475
|
+ 65 chars, 32bit aligned ==
|
476
|
476
|
68 chars */
|
477
|
|
-
|
|
477
|
+
|
478
|
478
|
int m_num_bones; /* Number of Bone */
|
479
|
479
|
|
480
|
480
|
int m_num_tags; /* Number of 'tags' per Bone */
|
481
|
481
|
|
482
|
|
- int m_num_meshes; /* Number of meshes/skins */
|
|
482
|
+ int m_num_meshes; /* Number of meshes/skins */
|
483
|
483
|
|
484
|
484
|
int m_max_skins; /* Maximum number of unique skins
|
485
|
|
- used in md3 file */
|
|
485
|
+ used in md3 file */
|
486
|
486
|
|
487
|
|
- int m_header_length; /* Always equal to the length of
|
488
|
|
- this header */
|
|
487
|
+ int m_header_length; /* Always equal to the length of
|
|
488
|
+ this header */
|
489
|
489
|
|
490
|
|
- int m_tag_start; /* Starting position of
|
491
|
|
- tag-structures */
|
|
490
|
+ int m_tag_start; /* Starting position of
|
|
491
|
+ tag-structures */
|
492
|
492
|
|
493
|
|
- int m_surfaces_start; /* Starting position of
|
|
493
|
+ int m_surfaces_start; /* Starting position of
|
494
|
494
|
geometeric data (mesh structures) */
|
495
|
495
|
|
496
|
496
|
int m_file_size; /* Size of file */
|