00001 00009 /* 00010 Copyright (C) 1997-2001 Id Software, Inc. 00011 00012 This program is free software; you can redistribute it and/or 00013 modify it under the terms of the GNU General Public License 00014 as published by the Free Software Foundation; either version 2 00015 of the License, or (at your option) any later version. 00016 00017 This program is distributed in the hope that it will be useful, 00018 but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00020 00021 See the GNU General Public License for more details. 00022 00023 You should have received a copy of the GNU General Public License 00024 along with this program; if not, write to the Free Software 00025 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00026 00027 */ 00028 00029 #ifndef QFILES_H 00030 #define QFILES_H 00031 00032 #include "../shared/defines.h" 00033 #include "unzip.h" 00034 00035 #define IDMDXHEADER "UFOMDX" 00036 #define MDX_VERSION 1 00037 00038 /*======================================================================== 00039 .MD2 triangle model file format 00040 ========================================================================*/ 00041 00042 #define IDALIASHEADER (('2'<<24)+('P'<<16)+('D'<<8)+'I') 00043 #define IDTAGHEADER (('2'<<24)+('P'<<16)+('D'<<8)+'J') 00044 #define MD2_ALIAS_VERSION 8 00045 #define TAG_VERSION 1 00046 00047 #define MD2_MAX_TRIANGLES 4096 00048 #define MD2_MAX_VERTS 2048 00049 #define MD2_MAX_FRAMES 512 00050 #define MD2_MAX_SKINS 32 00051 #define MD2_MAX_SKINNAME 64 00052 #define MD2_MAX_TAGNAME 64 00053 00059 typedef struct { 00060 uint16_t s; 00061 uint16_t t; 00062 } dMD2Coord_t; 00063 00064 typedef struct { 00065 uint16_t index_verts[3]; 00071 uint16_t index_st[3]; 00072 } dMD2Triangle_t; 00073 00074 typedef struct { 00075 byte v[3]; 00085 byte unused; 00086 } dMD2TriangleVertex_t; 00087 00092 typedef struct dAliasFrame_s { 00093 float scale[3]; 00094 float translate[3]; 00095 char name[16]; 00096 dMD2TriangleVertex_t verts[1]; 00097 } dMD2Frame_t; 00098 00099 00111 typedef struct { 00112 uint32_t ident; 00117 uint32_t version; 00119 uint32_t skinwidth; 00120 uint32_t skinheight; 00121 uint32_t framesize; 00123 uint32_t num_skins; 00124 uint32_t num_verts; 00125 uint32_t num_st; 00126 uint32_t num_tris; 00127 uint32_t num_glcmds; 00128 uint32_t num_frames; 00130 uint32_t ofs_skins; 00131 uint32_t ofs_st; 00132 uint32_t ofs_tris; 00133 uint32_t ofs_frames; 00134 uint32_t ofs_glcmds; 00135 uint32_t ofs_end; 00136 } dMD2Model_t; 00137 00138 00143 typedef struct { 00144 uint32_t ident; 00145 uint32_t version; 00147 uint32_t num_tags; 00148 uint32_t num_frames; 00151 uint32_t ofs_names; 00152 uint32_t ofs_tags; 00153 uint32_t ofs_end; 00154 uint32_t ofs_extractend; 00155 } dMD2tag_t; 00156 00157 /*======================================================================== 00158 .MD3 model file format 00159 ========================================================================*/ 00160 00161 #define IDMD3HEADER (('3'<<24)+('P'<<16)+('D'<<8)+'I') 00162 00163 #define MD3_ALIAS_VERSION 15 00164 #define MD3_ALIAS_MAX_LODS 4 00165 00166 #define MD3_MAX_TRIANGLES 8192 /* per mesh */ 00167 #define MD3_MAX_VERTS 4096 /* per mesh */ 00168 #define MD3_MAX_SHADERS 256 /* per mesh */ 00169 #define MD3_MAX_FRAMES 1024 /* per model */ 00170 #define MD3_MAX_MESHES 32 /* per model */ 00171 #define MD3_MAX_TAGS 16 /* per frame */ 00172 #define MD3_MAX_PATH 64 00173 00175 #define MD3_XYZ_SCALE (1.0f/64.0f) 00176 00177 typedef struct { 00178 float st[2]; 00179 } dmd3coord_t; 00180 00181 typedef struct { 00182 int16_t point[3]; 00183 int16_t norm; 00184 } dmd3vertex_t; 00185 00186 typedef struct { 00187 float mins[3]; 00188 float maxs[3]; 00189 float translate[3]; 00190 float radius; 00191 char creator[16]; 00192 } dmd3frame_t; 00193 00194 typedef struct { 00195 float origin[3]; 00196 float axis[3][3]; 00197 } dorientation_t; 00198 00199 typedef struct { 00200 char name[MD3_MAX_PATH]; 00201 dorientation_t orient; 00202 } dmd3tag_t; 00203 00204 typedef struct { 00205 char name[MD3_MAX_PATH]; 00206 uint32_t unused; 00207 } dmd3skin_t; 00208 00209 typedef struct { 00210 char id[4]; 00211 00212 char name[MD3_MAX_PATH]; 00213 00214 uint32_t flags; 00215 00216 uint32_t num_frames; 00217 uint32_t num_skins; 00218 uint32_t num_verts; 00219 uint32_t num_tris; 00220 00221 uint32_t ofs_tris; 00222 uint32_t ofs_skins; 00223 uint32_t ofs_tcs; 00224 uint32_t ofs_verts; 00225 00226 uint32_t meshsize; 00227 } dmd3mesh_t; 00228 00229 typedef struct { 00230 uint32_t id; 00231 uint32_t version; 00232 00233 char filename[MD3_MAX_PATH]; 00234 00235 uint32_t flags; 00236 00237 uint32_t num_frames; 00238 uint32_t num_tags; 00239 uint32_t num_meshes; 00240 uint32_t num_skins; 00241 00242 uint32_t ofs_frames; 00243 uint32_t ofs_tags; 00244 uint32_t ofs_meshes; 00245 uint32_t ofs_end; 00246 } dmd3_t; 00247 00248 /*============================================================================== 00249 dpm file format 00250 ==============================================================================*/ 00251 00252 #define DPMHEADER (('K'<<24)+('R'<<16)+('A'<<8)+'D') 00253 00289 typedef struct dpmheader_s { 00290 char id[16]; 00291 uint32_t type; 00292 uint32_t filesize; 00293 float mins[3], maxs[3], yawradius, allradius; 00296 uint32_t num_bones; 00297 uint32_t num_meshs; 00298 uint32_t num_frames; 00299 uint32_t ofs_bones; 00300 uint32_t ofs_meshs; 00301 uint32_t ofs_frames; 00302 } dpmheader_t; 00303 00305 typedef struct dpmmesh_s { 00307 char shadername[32]; 00308 uint32_t num_verts; 00309 uint32_t num_tris; 00310 uint32_t ofs_verts; 00311 uint32_t ofs_texcoords; 00312 uint32_t ofs_indices; 00313 uint32_t ofs_groupids; 00314 } dpmmesh_t; 00315 00317 #define DPMBONEFLAG_ATTACHMENT 1 00318 00320 typedef struct dpmbone_s { 00322 char name[32]; 00324 int32_t parent; 00326 uint32_t flags; 00327 } dpmbone_t; 00328 00334 typedef struct dpmbonepose_s { 00335 float matrix[3][4]; 00336 } dpmbonepose_t; 00337 00339 typedef struct dpmframe_s { 00341 char name[32]; 00342 float mins[3], maxs[3], yawradius, allradius; 00343 uint32_t ofs_bonepositions; 00344 } dpmframe_t; 00345 00347 typedef struct dpmbonevert_s { 00351 float origin[3]; 00352 float influence; 00356 float normal[3]; 00357 uint32_t bonenum; 00358 } dpmbonevert_t; 00359 00361 typedef struct dpmvertex_s { 00362 uint32_t numbones; 00364 } dpmvertex_t; 00365 00366 /*============================================================================== 00367 .BSP file format 00368 ==============================================================================*/ 00369 00371 #define IDBSPHEADER (('P'<<24)+('S'<<16)+('B'<<8)+'I') 00372 00373 #define BSPVERSION 78 00374 00376 typedef struct { 00377 uint32_t fileofs; 00378 uint32_t filelen; 00379 } lump_t; 00380 00382 typedef struct { 00383 uint32_t ident; 00384 uint32_t version; 00385 lump_t lumps[HEADER_LUMPS]; 00386 } dBspHeader_t; 00387 00388 00389 #endif /* QFILES_H */