vrshoot
diff libs/assimp/MDLFileData.h @ 0:b2f14e535253
initial commit
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 01 Feb 2014 19:58:19 +0200 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/libs/assimp/MDLFileData.h Sat Feb 01 19:58:19 2014 +0200 1.3 @@ -0,0 +1,959 @@ 1.4 +/* 1.5 +Open Asset Import Library (assimp) 1.6 +---------------------------------------------------------------------- 1.7 + 1.8 +Copyright (c) 2006-2012, assimp team 1.9 +All rights reserved. 1.10 + 1.11 +Redistribution and use of this software in source and binary forms, 1.12 +with or without modification, are permitted provided that the 1.13 +following conditions are met: 1.14 + 1.15 +* Redistributions of source code must retain the above 1.16 + copyright notice, this list of conditions and the 1.17 + following disclaimer. 1.18 + 1.19 +* Redistributions in binary form must reproduce the above 1.20 + copyright notice, this list of conditions and the 1.21 + following disclaimer in the documentation and/or other 1.22 + materials provided with the distribution. 1.23 + 1.24 +* Neither the name of the assimp team, nor the names of its 1.25 + contributors may be used to endorse or promote products 1.26 + derived from this software without specific prior 1.27 + written permission of the assimp team. 1.28 + 1.29 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1.30 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1.31 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1.32 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1.33 +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 1.34 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 1.35 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 1.36 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 1.37 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 1.38 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 1.39 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 1.40 + 1.41 +---------------------------------------------------------------------- 1.42 +*/ 1.43 + 1.44 + 1.45 +/** 1.46 + * @file MDLFileData.h 1.47 + * @brief Definition of in-memory structures for the MDL file format. 1.48 + * 1.49 + * The specification has been taken from various sources on the internet. 1.50 + * - http://tfc.duke.free.fr/coding/mdl-specs-en.html 1.51 + * - Conitec's MED SDK 1.52 + * - Many quite long HEX-editor sessions 1.53 + */ 1.54 + 1.55 +#ifndef AI_MDLFILEHELPER_H_INC 1.56 +#define AI_MDLFILEHELPER_H_INC 1.57 + 1.58 +#include "assimp/Compiler/pushpack1.h" 1.59 + 1.60 +namespace Assimp { 1.61 +namespace MDL { 1.62 + 1.63 +// ------------------------------------------------------------------------------------- 1.64 +// to make it easier for us, we test the magic word against both "endianesses" 1.65 + 1.66 +// magic bytes used in Quake 1 MDL meshes 1.67 +#define AI_MDL_MAGIC_NUMBER_BE AI_MAKE_MAGIC("IDPO") 1.68 +#define AI_MDL_MAGIC_NUMBER_LE AI_MAKE_MAGIC("OPDI") 1.69 + 1.70 +// magic bytes used in GameStudio A<very low> MDL meshes 1.71 +#define AI_MDL_MAGIC_NUMBER_BE_GS3 AI_MAKE_MAGIC("MDL2") 1.72 +#define AI_MDL_MAGIC_NUMBER_LE_GS3 AI_MAKE_MAGIC("2LDM") 1.73 + 1.74 +// magic bytes used in GameStudio A4 MDL meshes 1.75 +#define AI_MDL_MAGIC_NUMBER_BE_GS4 AI_MAKE_MAGIC("MDL3") 1.76 +#define AI_MDL_MAGIC_NUMBER_LE_GS4 AI_MAKE_MAGIC("3LDM") 1.77 + 1.78 +// magic bytes used in GameStudio A5+ MDL meshes 1.79 +#define AI_MDL_MAGIC_NUMBER_BE_GS5a AI_MAKE_MAGIC("MDL4") 1.80 +#define AI_MDL_MAGIC_NUMBER_LE_GS5a AI_MAKE_MAGIC("4LDM") 1.81 +#define AI_MDL_MAGIC_NUMBER_BE_GS5b AI_MAKE_MAGIC("MDL5") 1.82 +#define AI_MDL_MAGIC_NUMBER_LE_GS5b AI_MAKE_MAGIC("5LDM") 1.83 + 1.84 +// magic bytes used in GameStudio A7+ MDL meshes 1.85 +#define AI_MDL_MAGIC_NUMBER_BE_GS7 AI_MAKE_MAGIC("MDL7") 1.86 +#define AI_MDL_MAGIC_NUMBER_LE_GS7 AI_MAKE_MAGIC("7LDM") 1.87 + 1.88 + 1.89 +// common limitations for Quake1 meshes. The loader does not check them, 1.90 +// (however it warns) but models should not exceed these limits. 1.91 +#if (!defined AI_MDL_VERSION) 1.92 +# define AI_MDL_VERSION 6 1.93 +#endif 1.94 +#if (!defined AI_MDL_MAX_FRAMES) 1.95 +# define AI_MDL_MAX_FRAMES 256 1.96 +#endif 1.97 +#if (!defined AI_MDL_MAX_UVS) 1.98 +# define AI_MDL_MAX_UVS 1024 1.99 +#endif 1.100 +#if (!defined AI_MDL_MAX_VERTS) 1.101 +# define AI_MDL_MAX_VERTS 1024 1.102 +#endif 1.103 +#if (!defined AI_MDL_MAX_TRIANGLES) 1.104 +# define AI_MDL_MAX_TRIANGLES 2048 1.105 +#endif 1.106 + 1.107 +// material key that is set for dummy materials that are 1.108 +// just referencing another material 1.109 +#if (!defined AI_MDL7_REFERRER_MATERIAL) 1.110 +# define AI_MDL7_REFERRER_MATERIAL "&&&referrer&&&",0,0 1.111 +#endif 1.112 + 1.113 +// ------------------------------------------------------------------------------------- 1.114 +/** \struct Header 1.115 + * \brief Data structure for the MDL main header 1.116 + */ 1.117 +struct Header 1.118 +{ 1.119 + //! magic number: "IDPO" 1.120 + uint32_t ident; 1.121 + 1.122 + //! version number: 6 1.123 + int32_t version; 1.124 + 1.125 + //! scale factors for each axis 1.126 + aiVector3D scale; 1.127 + 1.128 + //! translation factors for each axis 1.129 + aiVector3D translate; 1.130 + 1.131 + //! bounding radius of the mesh 1.132 + float boundingradius; 1.133 + 1.134 + //! Position of the viewer's exe. Ignored 1.135 + aiVector3D vEyePos; 1.136 + 1.137 + //! Number of textures 1.138 + int32_t num_skins; 1.139 + 1.140 + //! Texture width in pixels 1.141 + int32_t skinwidth; 1.142 + 1.143 + //! Texture height in pixels 1.144 + int32_t skinheight; 1.145 + 1.146 + //! Number of vertices contained in the file 1.147 + int32_t num_verts; 1.148 + 1.149 + //! Number of triangles contained in the file 1.150 + int32_t num_tris; 1.151 + 1.152 + //! Number of frames contained in the file 1.153 + int32_t num_frames; 1.154 + 1.155 + //! 0 = synchron, 1 = random . Ignored 1.156 + //! (MDLn formats: number of texture coordinates) 1.157 + int32_t synctype; 1.158 + 1.159 + //! State flag 1.160 + int32_t flags; 1.161 + 1.162 + //! Could be the total size of the file (and not a float) 1.163 + float size; 1.164 +} PACK_STRUCT; 1.165 + 1.166 + 1.167 +// ------------------------------------------------------------------------------------- 1.168 +/** \struct Header_MDL7 1.169 + * \brief Data structure for the MDL 7 main header 1.170 + */ 1.171 +struct Header_MDL7 1.172 +{ 1.173 + //! magic number: "MDL7" 1.174 + char ident[4]; 1.175 + 1.176 + //! Version number. Ignored 1.177 + int32_t version; 1.178 + 1.179 + //! Number of bones in file 1.180 + uint32_t bones_num; 1.181 + 1.182 + //! Number of groups in file 1.183 + uint32_t groups_num; 1.184 + 1.185 + //! Size of data in the file 1.186 + uint32_t data_size; 1.187 + 1.188 + //! Ignored. Used to store entity specific information 1.189 + int32_t entlump_size; 1.190 + 1.191 + //! Ignored. Used to store MED related data 1.192 + int32_t medlump_size; 1.193 + 1.194 + //! Size of the Bone_MDL7 data structure used in the file 1.195 + uint16_t bone_stc_size; 1.196 + 1.197 + //! Size of the Skin_MDL 7 data structure used in the file 1.198 + uint16_t skin_stc_size; 1.199 + 1.200 + //! Size of a single color (e.g. in a material) 1.201 + uint16_t colorvalue_stc_size; 1.202 + 1.203 + //! Size of the Material_MDL7 data structure used in the file 1.204 + uint16_t material_stc_size; 1.205 + 1.206 + //! Size of a texture coordinate set in the file 1.207 + uint16_t skinpoint_stc_size; 1.208 + 1.209 + //! Size of a triangle in the file 1.210 + uint16_t triangle_stc_size; 1.211 + 1.212 + //! Size of a normal vertex in the file 1.213 + uint16_t mainvertex_stc_size; 1.214 + 1.215 + //! Size of a per-frame animated vertex in the file 1.216 + //! (this is not supported) 1.217 + uint16_t framevertex_stc_size; 1.218 + 1.219 + //! Size of a bone animation matrix 1.220 + uint16_t bonetrans_stc_size; 1.221 + 1.222 + //! Size of the Frame_MDL7 data structure used in the file 1.223 + uint16_t frame_stc_size; 1.224 +} PACK_STRUCT; 1.225 + 1.226 + 1.227 +// ------------------------------------------------------------------------------------- 1.228 +/** \struct Bone_MDL7 1.229 + * \brief Data structure for a bone in a MDL7 file 1.230 + */ 1.231 +struct Bone_MDL7 1.232 +{ 1.233 + //! Index of the parent bone of *this* bone. 0xffff means: 1.234 + //! "hey, I have no parent, I'm an orphan" 1.235 + uint16_t parent_index; 1.236 + uint8_t _unused_[2]; 1.237 + 1.238 + //! Relative position of the bone (relative to the 1.239 + //! parent bone) 1.240 + float x,y,z; 1.241 + 1.242 + //! Optional name of the bone 1.243 + char name[1 /* DUMMY SIZE */]; 1.244 +} PACK_STRUCT; 1.245 + 1.246 +#if (!defined AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_20_CHARS) 1.247 +# define AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_20_CHARS (16 + 20) 1.248 +#endif 1.249 + 1.250 +#if (!defined AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_32_CHARS) 1.251 +# define AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_32_CHARS (16 + 32) 1.252 +#endif 1.253 + 1.254 +#if (!defined AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_NOT_THERE) 1.255 +# define AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_NOT_THERE (16) 1.256 +#endif 1.257 + 1.258 +#if (!defined AI_MDL7_MAX_GROUPNAMESIZE) 1.259 +# define AI_MDL7_MAX_GROUPNAMESIZE 16 1.260 +#endif // ! AI_MDL7_MAX_GROUPNAMESIZE 1.261 + 1.262 +// ------------------------------------------------------------------------------------- 1.263 +/** \struct Group_MDL7 1.264 + * \brief Group in a MDL7 file 1.265 + */ 1.266 +struct Group_MDL7 1.267 +{ 1.268 + //! = '1' -> triangle based Mesh 1.269 + unsigned char typ; 1.270 + 1.271 + int8_t deformers; 1.272 + int8_t max_weights; 1.273 + int8_t _unused_; 1.274 + 1.275 + //! size of data for this group in bytes ( MD7_GROUP stc. included). 1.276 + int32_t groupdata_size; 1.277 + char name[AI_MDL7_MAX_GROUPNAMESIZE]; 1.278 + 1.279 + //! Number of skins 1.280 + int32_t numskins; 1.281 + 1.282 + //! Number of texture coordinates 1.283 + int32_t num_stpts; 1.284 + 1.285 + //! Number of triangles 1.286 + int32_t numtris; 1.287 + 1.288 + //! Number of vertices 1.289 + int32_t numverts; 1.290 + 1.291 + //! Number of frames 1.292 + int32_t numframes; 1.293 +} PACK_STRUCT; 1.294 + 1.295 +#define AI_MDL7_SKINTYPE_MIPFLAG 0x08 1.296 +#define AI_MDL7_SKINTYPE_MATERIAL 0x10 1.297 +#define AI_MDL7_SKINTYPE_MATERIAL_ASCDEF 0x20 1.298 +#define AI_MDL7_SKINTYPE_RGBFLAG 0x80 1.299 + 1.300 +#if (!defined AI_MDL7_MAX_BONENAMESIZE) 1.301 +# define AI_MDL7_MAX_BONENAMESIZE 20 1.302 +#endif // !! AI_MDL7_MAX_BONENAMESIZE 1.303 + 1.304 +// ------------------------------------------------------------------------------------- 1.305 +/** \struct Deformer_MDL7 1.306 + * \brief Deformer in a MDL7 file 1.307 + */ 1.308 +struct Deformer_MDL7 1.309 +{ 1.310 + int8_t deformer_version; // 0 1.311 + int8_t deformer_typ; // 0 - bones 1.312 + int8_t _unused_[2]; 1.313 + int32_t group_index; 1.314 + int32_t elements; 1.315 + int32_t deformerdata_size; 1.316 +} PACK_STRUCT; 1.317 + 1.318 + 1.319 +// ------------------------------------------------------------------------------------- 1.320 +/** \struct DeformerElement_MDL7 1.321 + * \brief Deformer element in a MDL7 file 1.322 + */ 1.323 +struct DeformerElement_MDL7 1.324 +{ 1.325 + //! bei deformer_typ==0 (==bones) element_index == bone index 1.326 + int32_t element_index; 1.327 + char element_name[AI_MDL7_MAX_BONENAMESIZE]; 1.328 + int32_t weights; 1.329 +} PACK_STRUCT; 1.330 + 1.331 + 1.332 +// ------------------------------------------------------------------------------------- 1.333 +/** \struct DeformerWeight_MDL7 1.334 + * \brief Deformer weight in a MDL7 file 1.335 + */ 1.336 +struct DeformerWeight_MDL7 1.337 +{ 1.338 + //! for deformer_typ==0 (==bones) index == vertex index 1.339 + int32_t index; 1.340 + float weight; 1.341 +} PACK_STRUCT; 1.342 + 1.343 + 1.344 +// don't know why this was in the original headers ... 1.345 +typedef int32_t MD7_MATERIAL_ASCDEFSIZE; 1.346 + 1.347 +// ------------------------------------------------------------------------------------- 1.348 +/** \struct ColorValue_MDL7 1.349 + * \brief Data structure for a color value in a MDL7 file 1.350 + */ 1.351 +struct ColorValue_MDL7 1.352 +{ 1.353 + float r,g,b,a; 1.354 +} PACK_STRUCT; 1.355 + 1.356 +// ------------------------------------------------------------------------------------- 1.357 +/** \struct Material_MDL7 1.358 + * \brief Data structure for a Material in a MDL7 file 1.359 + */ 1.360 +struct Material_MDL7 1.361 +{ 1.362 + //! Diffuse base color of the material 1.363 + ColorValue_MDL7 Diffuse; 1.364 + 1.365 + //! Ambient base color of the material 1.366 + ColorValue_MDL7 Ambient; 1.367 + 1.368 + //! Specular base color of the material 1.369 + ColorValue_MDL7 Specular; 1.370 + 1.371 + //! Emissive base color of the material 1.372 + ColorValue_MDL7 Emissive; 1.373 + 1.374 + //! Phong power 1.375 + float Power; 1.376 +} PACK_STRUCT; 1.377 + 1.378 + 1.379 +// ------------------------------------------------------------------------------------- 1.380 +/** \struct Skin 1.381 + * \brief Skin data structure #1 - used by Quake1, MDL2, MDL3 and MDL4 1.382 + */ 1.383 +struct Skin 1.384 +{ 1.385 + //! 0 = single (Skin), 1 = group (GroupSkin) 1.386 + //! For MDL3-5: Defines the type of the skin and there 1.387 + //! fore the size of the data to skip: 1.388 + //------------------------------------------------------- 1.389 + //! 2 for 565 RGB, 1.390 + //! 3 for 4444 ARGB, 1.391 + //! 10 for 565 mipmapped, 1.392 + //! 11 for 4444 mipmapped (bpp = 2), 1.393 + //! 12 for 888 RGB mipmapped (bpp = 3), 1.394 + //! 13 for 8888 ARGB mipmapped (bpp = 4) 1.395 + //------------------------------------------------------- 1.396 + int32_t group; 1.397 + 1.398 + //! Texture data 1.399 + uint8_t *data; 1.400 +} PACK_STRUCT; 1.401 + 1.402 + 1.403 +// ------------------------------------------------------------------------------------- 1.404 +/** \struct Skin 1.405 + * \brief Skin data structure #2 - used by MDL5, MDL6 and MDL7 1.406 + * \see Skin 1.407 + */ 1.408 +struct Skin_MDL5 1.409 +{ 1.410 + int32_t size, width, height; 1.411 + uint8_t *data; 1.412 +} PACK_STRUCT; 1.413 + 1.414 +// maximum length of texture file name 1.415 +#if (!defined AI_MDL7_MAX_TEXNAMESIZE) 1.416 +# define AI_MDL7_MAX_TEXNAMESIZE 0x10 1.417 +#endif 1.418 + 1.419 +// --------------------------------------------------------------------------- 1.420 +/** \struct Skin_MDL7 1.421 + * \brief Skin data structure #3 - used by MDL7 and HMP7 1.422 + */ 1.423 +struct Skin_MDL7 1.424 +{ 1.425 + uint8_t typ; 1.426 + int8_t _unused_[3]; 1.427 + int32_t width; 1.428 + int32_t height; 1.429 + char texture_name[AI_MDL7_MAX_TEXNAMESIZE]; 1.430 +} PACK_STRUCT; 1.431 + 1.432 +// ------------------------------------------------------------------------------------- 1.433 +/** \struct RGB565 1.434 + * \brief Data structure for a RGB565 pixel in a texture 1.435 + */ 1.436 +struct RGB565 1.437 +{ 1.438 + uint16_t r : 5; 1.439 + uint16_t g : 6; 1.440 + uint16_t b : 5; 1.441 +} PACK_STRUCT; 1.442 + 1.443 +// ------------------------------------------------------------------------------------- 1.444 +/** \struct ARGB4 1.445 + * \brief Data structure for a ARGB4444 pixel in a texture 1.446 + */ 1.447 +struct ARGB4 1.448 +{ 1.449 + uint16_t a : 4; 1.450 + uint16_t r : 4; 1.451 + uint16_t g : 4; 1.452 + uint16_t b : 4; 1.453 +} PACK_STRUCT; 1.454 + 1.455 +// ------------------------------------------------------------------------------------- 1.456 +/** \struct GroupSkin 1.457 + * \brief Skin data structure #2 (group of pictures) 1.458 + */ 1.459 +struct GroupSkin 1.460 +{ 1.461 + //! 0 = single (Skin), 1 = group (GroupSkin) 1.462 + int32_t group; 1.463 + 1.464 + //! Number of images 1.465 + int32_t nb; 1.466 + 1.467 + //! Time for each image 1.468 + float *time; 1.469 + 1.470 + //! Data of each image 1.471 + uint8_t **data; 1.472 +} PACK_STRUCT; 1.473 + 1.474 +// ------------------------------------------------------------------------------------- 1.475 +/** \struct TexCoord 1.476 + * \brief Texture coordinate data structure used by the Quake1 MDL format 1.477 + */ 1.478 +struct TexCoord 1.479 +{ 1.480 + //! Is the vertex on the noundary between front and back piece? 1.481 + int32_t onseam; 1.482 + 1.483 + //! Texture coordinate in the tx direction 1.484 + int32_t s; 1.485 + 1.486 + //! Texture coordinate in the ty direction 1.487 + int32_t t; 1.488 +} PACK_STRUCT; 1.489 + 1.490 +// ------------------------------------------------------------------------------------- 1.491 +/** \struct TexCoord_MDL3 1.492 + * \brief Data structure for an UV coordinate in the 3DGS MDL3 format 1.493 + */ 1.494 +struct TexCoord_MDL3 1.495 +{ 1.496 + //! position, horizontally in range 0..skinwidth-1 1.497 + int16_t u; 1.498 + 1.499 + //! position, vertically in range 0..skinheight-1 1.500 + int16_t v; 1.501 +} PACK_STRUCT; 1.502 + 1.503 +// ------------------------------------------------------------------------------------- 1.504 +/** \struct TexCoord_MDL7 1.505 + * \brief Data structure for an UV coordinate in the 3DGS MDL7 format 1.506 + */ 1.507 +struct TexCoord_MDL7 1.508 +{ 1.509 + //! position, horizontally in range 0..1 1.510 + float u; 1.511 + 1.512 + //! position, vertically in range 0..1 1.513 + float v; 1.514 +} PACK_STRUCT; 1.515 + 1.516 +// ------------------------------------------------------------------------------------- 1.517 +/** \struct SkinSet_MDL7 1.518 + * \brief Skin set data structure for the 3DGS MDL7 format 1.519 + * MDL7 references UV coordinates per face via an index list. 1.520 + * This allows the use of multiple skins per face with just one 1.521 + * UV coordinate set. 1.522 + */ 1.523 +struct SkinSet_MDL7 1.524 +{ 1.525 + //! Index into the UV coordinate list 1.526 + uint16_t st_index[3]; // size 6 1.527 + 1.528 + //! Material index 1.529 + int32_t material; // size 4 1.530 +} PACK_STRUCT; 1.531 + 1.532 +// ------------------------------------------------------------------------------------- 1.533 +/** \struct Triangle 1.534 + * \brief Triangle data structure for the Quake1 MDL format 1.535 + */ 1.536 +struct Triangle 1.537 +{ 1.538 + //! 0 = backface, 1 = frontface 1.539 + int32_t facesfront; 1.540 + 1.541 + //! Vertex indices 1.542 + int32_t vertex[3]; 1.543 +} PACK_STRUCT; 1.544 + 1.545 +// ------------------------------------------------------------------------------------- 1.546 +/** \struct Triangle_MDL3 1.547 + * \brief Triangle data structure for the 3DGS MDL3 format 1.548 + */ 1.549 +struct Triangle_MDL3 1.550 +{ 1.551 + //! Index of 3 3D vertices in range 0..numverts 1.552 + uint16_t index_xyz[3]; 1.553 + 1.554 + //! Index of 3 skin vertices in range 0..numskinverts 1.555 + uint16_t index_uv[3]; 1.556 +} PACK_STRUCT; 1.557 + 1.558 +// ------------------------------------------------------------------------------------- 1.559 +/** \struct Triangle_MDL7 1.560 + * \brief Triangle data structure for the 3DGS MDL7 format 1.561 + */ 1.562 +struct Triangle_MDL7 1.563 +{ 1.564 + //! Vertex indices 1.565 + uint16_t v_index[3]; // size 6 1.566 + 1.567 + //! Two skinsets. The second will be used for multi-texturing 1.568 + SkinSet_MDL7 skinsets[2]; 1.569 +} PACK_STRUCT; 1.570 + 1.571 +#if (!defined AI_MDL7_TRIANGLE_STD_SIZE_ONE_UV) 1.572 +# define AI_MDL7_TRIANGLE_STD_SIZE_ONE_UV (6+sizeof(SkinSet_MDL7)-sizeof(uint32_t)) 1.573 +#endif 1.574 +#if (!defined AI_MDL7_TRIANGLE_STD_SIZE_ONE_UV_WITH_MATINDEX) 1.575 +# define AI_MDL7_TRIANGLE_STD_SIZE_ONE_UV_WITH_MATINDEX (6+sizeof(SkinSet_MDL7)) 1.576 +#endif 1.577 +#if (!defined AI_MDL7_TRIANGLE_STD_SIZE_TWO_UV) 1.578 +# define AI_MDL7_TRIANGLE_STD_SIZE_TWO_UV (6+2*sizeof(SkinSet_MDL7)) 1.579 +#endif 1.580 + 1.581 +// Helper constants for Triangle::facesfront 1.582 +#if (!defined AI_MDL_BACKFACE) 1.583 +# define AI_MDL_BACKFACE 0x0 1.584 +#endif 1.585 +#if (!defined AI_MDL_FRONTFACE) 1.586 +# define AI_MDL_FRONTFACE 0x1 1.587 +#endif 1.588 + 1.589 +// ------------------------------------------------------------------------------------- 1.590 +/** \struct Vertex 1.591 + * \brief Vertex data structure 1.592 + */ 1.593 +struct Vertex 1.594 +{ 1.595 + uint8_t v[3]; 1.596 + uint8_t normalIndex; 1.597 +} PACK_STRUCT; 1.598 + 1.599 + 1.600 +// ------------------------------------------------------------------------------------- 1.601 +struct Vertex_MDL4 1.602 +{ 1.603 + uint16_t v[3]; 1.604 + uint8_t normalIndex; 1.605 + uint8_t unused; 1.606 +} PACK_STRUCT; 1.607 + 1.608 +#define AI_MDL7_FRAMEVERTEX120503_STCSIZE 16 1.609 +#define AI_MDL7_FRAMEVERTEX030305_STCSIZE 26 1.610 + 1.611 +// ------------------------------------------------------------------------------------- 1.612 +/** \struct Vertex_MDL7 1.613 + * \brief Vertex data structure used in MDL7 files 1.614 + */ 1.615 +struct Vertex_MDL7 1.616 +{ 1.617 + float x,y,z; 1.618 + uint16_t vertindex; // = bone index 1.619 + union { 1.620 + uint8_t norm162index; 1.621 + float norm[3]; 1.622 + }; 1.623 +} PACK_STRUCT; 1.624 + 1.625 + 1.626 +// ------------------------------------------------------------------------------------- 1.627 +/** \struct BoneTransform_MDL7 1.628 + * \brief bone transformation matrix structure used in MDL7 files 1.629 + */ 1.630 +struct BoneTransform_MDL7 1.631 +{ 1.632 + //! 4*3 1.633 + float m [4*4]; 1.634 + 1.635 + //! the index of this vertex, 0.. header::bones_num - 1 1.636 + uint16_t bone_index; 1.637 + 1.638 + //! I HATE 3DGS AND THE SILLY DEVELOPER WHO DESIGNED 1.639 + //! THIS STUPID FILE FORMAT! 1.640 + int8_t _unused_[2]; 1.641 +} PACK_STRUCT; 1.642 + 1.643 + 1.644 +#define AI_MDL7_MAX_FRAMENAMESIZE 16 1.645 + 1.646 + 1.647 +// ------------------------------------------------------------------------------------- 1.648 +/** \struct Frame_MDL7 1.649 + * \brief Frame data structure used by MDL7 files 1.650 + */ 1.651 +struct Frame_MDL7 1.652 +{ 1.653 + char frame_name[AI_MDL7_MAX_FRAMENAMESIZE]; 1.654 + uint32_t vertices_count; 1.655 + uint32_t transmatrix_count; 1.656 +}; 1.657 + 1.658 + 1.659 +// ------------------------------------------------------------------------------------- 1.660 +/** \struct SimpleFrame 1.661 + * \brief Data structure for a simple frame 1.662 + */ 1.663 +struct SimpleFrame 1.664 +{ 1.665 + //! Minimum vertex of the bounding box 1.666 + Vertex bboxmin; 1.667 + 1.668 + //! Maximum vertex of the bounding box 1.669 + Vertex bboxmax; 1.670 + 1.671 + //! Name of the frame 1.672 + char name[16]; 1.673 + 1.674 + //! Vertex list of the frame 1.675 + Vertex *verts; 1.676 +} PACK_STRUCT; 1.677 + 1.678 +// ------------------------------------------------------------------------------------- 1.679 +/** \struct Frame 1.680 + * \brief Model frame data structure 1.681 + */ 1.682 +struct Frame 1.683 +{ 1.684 + //! 0 = simple frame, !0 = group frame 1.685 + int32_t type; 1.686 + 1.687 + //! Frame data 1.688 + SimpleFrame frame; 1.689 +} PACK_STRUCT; 1.690 + 1.691 + 1.692 +// ------------------------------------------------------------------------------------- 1.693 +struct SimpleFrame_MDLn_SP 1.694 +{ 1.695 + //! Minimum vertex of the bounding box 1.696 + Vertex_MDL4 bboxmin; 1.697 + 1.698 + //! Maximum vertex of the bounding box 1.699 + Vertex_MDL4 bboxmax; 1.700 + 1.701 + //! Name of the frame 1.702 + char name[16]; 1.703 + 1.704 + //! Vertex list of the frame 1.705 + Vertex_MDL4 *verts; 1.706 +} PACK_STRUCT; 1.707 + 1.708 +// ------------------------------------------------------------------------------------- 1.709 +/** \struct GroupFrame 1.710 + * \brief Data structure for a group of frames 1.711 + */ 1.712 +struct GroupFrame 1.713 +{ 1.714 + //! 0 = simple frame, !0 = group frame 1.715 + int32_t type; 1.716 + 1.717 + //! Minimum vertex for all single frames 1.718 + Vertex min; 1.719 + 1.720 + //! Maximum vertex for all single frames 1.721 + Vertex max; 1.722 + 1.723 + //! Time for all single frames 1.724 + float *time; 1.725 + 1.726 + //! List of single frames 1.727 + SimpleFrame *frames; 1.728 +} PACK_STRUCT; 1.729 + 1.730 +#include "assimp/Compiler/poppack1.h" 1.731 + 1.732 +// ------------------------------------------------------------------------------------- 1.733 +/** \struct IntFace_MDL7 1.734 + * \brief Internal data structure to temporarily represent a face 1.735 + */ 1.736 +struct IntFace_MDL7 1.737 +{ 1.738 + // provide a constructor for our own convenience 1.739 + IntFace_MDL7() 1.740 + { 1.741 + // set everything to zero 1.742 + mIndices[0] = mIndices[1] = mIndices[2] = 0; 1.743 + iMatIndex[0] = iMatIndex[1] = 0; 1.744 + } 1.745 + 1.746 + //! Vertex indices 1.747 + uint32_t mIndices[3]; 1.748 + 1.749 + //! Material index (maximally two channels, which are joined later) 1.750 + unsigned int iMatIndex[2]; 1.751 +}; 1.752 + 1.753 +// ------------------------------------------------------------------------------------- 1.754 +/** \struct IntMaterial_MDL7 1.755 + * \brief Internal data structure to temporarily represent a material 1.756 + * which has been created from two single materials along with the 1.757 + * original material indices. 1.758 + */ 1.759 +struct IntMaterial_MDL7 1.760 +{ 1.761 + // provide a constructor for our own convenience 1.762 + IntMaterial_MDL7() 1.763 + { 1.764 + pcMat = NULL; 1.765 + iOldMatIndices[0] = iOldMatIndices[1] = 0; 1.766 + } 1.767 + 1.768 + //! Material instance 1.769 + aiMaterial* pcMat; 1.770 + 1.771 + //! Old material indices 1.772 + unsigned int iOldMatIndices[2]; 1.773 +}; 1.774 + 1.775 +// ------------------------------------------------------------------------------------- 1.776 +/** \struct IntBone_MDL7 1.777 + * \brief Internal data structure to represent a bone in a MDL7 file with 1.778 + * all of its animation channels assigned to it. 1.779 + */ 1.780 +struct IntBone_MDL7 : aiBone 1.781 +{ 1.782 + //! Default constructor 1.783 + IntBone_MDL7() : iParent (0xffff) 1.784 + { 1.785 + pkeyPositions.reserve(30); 1.786 + pkeyScalings.reserve(30); 1.787 + pkeyRotations.reserve(30); 1.788 + } 1.789 + 1.790 + //! Parent bone of the bone 1.791 + uint64_t iParent; 1.792 + 1.793 + //! Relative position of the bone 1.794 + aiVector3D vPosition; 1.795 + 1.796 + //! Array of position keys 1.797 + std::vector<aiVectorKey> pkeyPositions; 1.798 + 1.799 + //! Array of scaling keys 1.800 + std::vector<aiVectorKey> pkeyScalings; 1.801 + 1.802 + //! Array of rotation keys 1.803 + std::vector<aiQuatKey> pkeyRotations; 1.804 +}; 1.805 + 1.806 +// ------------------------------------------------------------------------------------- 1.807 +//! Describes a MDL7 frame 1.808 +struct IntFrameInfo_MDL7 1.809 +{ 1.810 + //! Construction from an existing frame header 1.811 + IntFrameInfo_MDL7(BE_NCONST MDL::Frame_MDL7* _pcFrame,unsigned int _iIndex) 1.812 + : iIndex(_iIndex) 1.813 + , pcFrame(_pcFrame) 1.814 + {} 1.815 + 1.816 + //! Index of the frame 1.817 + unsigned int iIndex; 1.818 + 1.819 + //! Points to the header of the frame 1.820 + BE_NCONST MDL::Frame_MDL7* pcFrame; 1.821 +}; 1.822 + 1.823 +// ------------------------------------------------------------------------------------- 1.824 +//! Describes a MDL7 mesh group 1.825 +struct IntGroupInfo_MDL7 1.826 +{ 1.827 + //! Default constructor 1.828 + IntGroupInfo_MDL7() 1.829 + : iIndex(0) 1.830 + , pcGroup(NULL) 1.831 + , pcGroupUVs(NULL) 1.832 + , pcGroupTris(NULL) 1.833 + , pcGroupVerts(NULL) 1.834 + {} 1.835 + 1.836 + //! Construction from an existing group header 1.837 + IntGroupInfo_MDL7(BE_NCONST MDL::Group_MDL7* _pcGroup, unsigned int _iIndex) 1.838 + : iIndex(_iIndex) 1.839 + , pcGroup(_pcGroup) 1.840 + {} 1.841 + 1.842 + //! Index of the group 1.843 + unsigned int iIndex; 1.844 + 1.845 + //! Points to the header of the group 1.846 + BE_NCONST MDL::Group_MDL7* pcGroup; 1.847 + 1.848 + //! Points to the beginning of the uv coordinate section 1.849 + BE_NCONST MDL::TexCoord_MDL7* pcGroupUVs; 1.850 + 1.851 + //! Points to the beginning of the triangle section 1.852 + MDL::Triangle_MDL7* pcGroupTris; 1.853 + 1.854 + //! Points to the beginning of the vertex section 1.855 + BE_NCONST MDL::Vertex_MDL7* pcGroupVerts; 1.856 +}; 1.857 + 1.858 +// ------------------------------------------------------------------------------------- 1.859 +//! Holds the data that belongs to a MDL7 mesh group 1.860 +struct IntGroupData_MDL7 1.861 +{ 1.862 + IntGroupData_MDL7() 1.863 + : pcFaces(NULL), bNeed2UV(false) 1.864 + {} 1.865 + 1.866 + //! Array of faces that belong to the group 1.867 + MDL::IntFace_MDL7* pcFaces; 1.868 + 1.869 + //! Array of vertex positions 1.870 + std::vector<aiVector3D> vPositions; 1.871 + 1.872 + //! Array of vertex normals 1.873 + std::vector<aiVector3D> vNormals; 1.874 + 1.875 + //! Array of bones indices 1.876 + std::vector<unsigned int> aiBones; 1.877 + 1.878 + //! First UV coordinate set 1.879 + std::vector<aiVector3D> vTextureCoords1; 1.880 + 1.881 + //! Optional second UV coordinate set 1.882 + std::vector<aiVector3D> vTextureCoords2; 1.883 + 1.884 + //! Specifies whether there are two texture 1.885 + //! coordinate sets required 1.886 + bool bNeed2UV; 1.887 +}; 1.888 + 1.889 +// ------------------------------------------------------------------------------------- 1.890 +//! Holds data from an MDL7 file that is shared by all mesh groups 1.891 +struct IntSharedData_MDL7 1.892 +{ 1.893 + //! Default constructor 1.894 + IntSharedData_MDL7() 1.895 + { 1.896 + abNeedMaterials.reserve(10); 1.897 + } 1.898 + 1.899 + //! Destruction: properly delete all allocated resources 1.900 + ~IntSharedData_MDL7() 1.901 + { 1.902 + // kill all bones 1.903 + if (this->apcOutBones) 1.904 + { 1.905 + for (unsigned int m = 0; m < iNum;++m) 1.906 + delete this->apcOutBones[m]; 1.907 + delete[] this->apcOutBones; 1.908 + } 1.909 + } 1.910 + 1.911 + //! Specifies which materials are used 1.912 + std::vector<bool> abNeedMaterials; 1.913 + 1.914 + //! List of all materials 1.915 + std::vector<aiMaterial*> pcMats; 1.916 + 1.917 + //! List of all bones 1.918 + IntBone_MDL7** apcOutBones; 1.919 + 1.920 + //! number of bones 1.921 + unsigned int iNum; 1.922 +}; 1.923 + 1.924 +// ------------------------------------------------------------------------------------- 1.925 +//! Contains input data for GenerateOutputMeshes_3DGS_MDL7 1.926 +struct IntSplitGroupData_MDL7 1.927 +{ 1.928 + //! Construction from a given shared data set 1.929 + IntSplitGroupData_MDL7(IntSharedData_MDL7& _shared, 1.930 + std::vector<aiMesh*>& _avOutList) 1.931 + 1.932 + : shared(_shared), avOutList(_avOutList) 1.933 + { 1.934 + } 1.935 + 1.936 + //! Destruction: properly delete all allocated resources 1.937 + ~IntSplitGroupData_MDL7() 1.938 + { 1.939 + // kill all face lists 1.940 + if(this->aiSplit) 1.941 + { 1.942 + for (unsigned int m = 0; m < shared.pcMats.size();++m) 1.943 + delete this->aiSplit[m]; 1.944 + delete[] this->aiSplit; 1.945 + } 1.946 + } 1.947 + 1.948 + //! Contains a list of all faces per material 1.949 + std::vector<unsigned int>** aiSplit; 1.950 + 1.951 + //! Shared data for all groups of the model 1.952 + IntSharedData_MDL7& shared; 1.953 + 1.954 + //! List of meshes 1.955 + std::vector<aiMesh*>& avOutList; 1.956 +}; 1.957 + 1.958 + 1.959 +} 1.960 +} // end namespaces 1.961 + 1.962 +#endif // !! AI_MDLFILEHELPER_H_INC