Model_md3.h (4204B)
1 /* 2 =========================================================================== 3 4 Doom 3 BFG Edition GPL Source Code 5 Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. 6 7 This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). 8 9 Doom 3 BFG Edition 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 BFG Edition 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 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>. 21 22 In addition, the Doom 3 BFG Edition 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 BFG Edition 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]; 64 idVec3 localOrigin; 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 97 int numTriangles; 98 int ofsTriangles; 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; 123 } md3XyzNormal_t; 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 133 int numFrames; 134 int numTags; 135 int numSurfaces; 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__ */