1 /* 2 Open Asset Import Library (assimp) 3 ---------------------------------------------------------------------- 4 5 Copyright (c) 2006-2012, assimp team 6 All rights reserved. 7 8 Redistribution and use of this software in source and binary forms, 9 with or without modification, are permitted provided that the 10 following conditions are met: 11 12 * Redistributions of source code must retain the above 13 copyright notice, this list of conditions and the 14 following disclaimer. 15 16 * Redistributions in binary form must reproduce the above 17 copyright notice, this list of conditions and the 18 following disclaimer in the documentation and/or other 19 materials provided with the distribution. 20 21 * Neither the name of the assimp team, nor the names of its 22 contributors may be used to endorse or promote products 23 derived from this software without specific prior 24 written permission of the assimp team. 25 26 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 38 ---------------------------------------------------------------------- 39 */ 40 41 42 /** 43 * @file MDLFileData.h 44 * @brief Definition of in-memory structures for the MDL file format. 45 * 46 * The specification has been taken from various sources on the internet. 47 * - http://tfc.duke.free.fr/coding/mdl-specs-en.html 48 * - Conitec's MED SDK 49 * - Many quite long HEX-editor sessions 50 */ 51 52 #ifndef AI_MDLFILEHELPER_H_INC 53 #define AI_MDLFILEHELPER_H_INC 54 55 #include "./../include/assimp/Compiler/pushpack1.h" 56 57 namespace Assimp { 58 namespace MDL { 59 60 // ------------------------------------------------------------------------------------- 61 // to make it easier for us, we test the magic word against both "endianesses" 62 63 // magic bytes used in Quake 1 MDL meshes 64 #define AI_MDL_MAGIC_NUMBER_BE AI_MAKE_MAGIC("IDPO") 65 #define AI_MDL_MAGIC_NUMBER_LE AI_MAKE_MAGIC("OPDI") 66 67 // magic bytes used in GameStudio A<very low> MDL meshes 68 #define AI_MDL_MAGIC_NUMBER_BE_GS3 AI_MAKE_MAGIC("MDL2") 69 #define AI_MDL_MAGIC_NUMBER_LE_GS3 AI_MAKE_MAGIC("2LDM") 70 71 // magic bytes used in GameStudio A4 MDL meshes 72 #define AI_MDL_MAGIC_NUMBER_BE_GS4 AI_MAKE_MAGIC("MDL3") 73 #define AI_MDL_MAGIC_NUMBER_LE_GS4 AI_MAKE_MAGIC("3LDM") 74 75 // magic bytes used in GameStudio A5+ MDL meshes 76 #define AI_MDL_MAGIC_NUMBER_BE_GS5a AI_MAKE_MAGIC("MDL4") 77 #define AI_MDL_MAGIC_NUMBER_LE_GS5a AI_MAKE_MAGIC("4LDM") 78 #define AI_MDL_MAGIC_NUMBER_BE_GS5b AI_MAKE_MAGIC("MDL5") 79 #define AI_MDL_MAGIC_NUMBER_LE_GS5b AI_MAKE_MAGIC("5LDM") 80 81 // magic bytes used in GameStudio A7+ MDL meshes 82 #define AI_MDL_MAGIC_NUMBER_BE_GS7 AI_MAKE_MAGIC("MDL7") 83 #define AI_MDL_MAGIC_NUMBER_LE_GS7 AI_MAKE_MAGIC("7LDM") 84 85 86 // common limitations for Quake1 meshes. The loader does not check them, 87 // (however it warns) but models should not exceed these limits. 88 #if (!defined AI_MDL_VERSION) 89 # define AI_MDL_VERSION 6 90 #endif 91 #if (!defined AI_MDL_MAX_FRAMES) 92 # define AI_MDL_MAX_FRAMES 256 93 #endif 94 #if (!defined AI_MDL_MAX_UVS) 95 # define AI_MDL_MAX_UVS 1024 96 #endif 97 #if (!defined AI_MDL_MAX_VERTS) 98 # define AI_MDL_MAX_VERTS 1024 99 #endif 100 #if (!defined AI_MDL_MAX_TRIANGLES) 101 # define AI_MDL_MAX_TRIANGLES 2048 102 #endif 103 104 // material key that is set for dummy materials that are 105 // just referencing another material 106 #if (!defined AI_MDL7_REFERRER_MATERIAL) 107 # define AI_MDL7_REFERRER_MATERIAL "&&&referrer&&&",0,0 108 #endif 109 110 // ------------------------------------------------------------------------------------- 111 /** \struct Header 112 * \brief Data structure for the MDL main header 113 */ 114 struct Header 115 { 116 //! magic number: "IDPO" 117 uint32_t ident; 118 119 //! version number: 6 120 int32_t version; 121 122 //! scale factors for each axis 123 aiVector3D scale; 124 125 //! translation factors for each axis 126 aiVector3D translate; 127 128 //! bounding radius of the mesh 129 float boundingradius; 130 131 //! Position of the viewer's exe. Ignored 132 aiVector3D vEyePos; 133 134 //! Number of textures 135 int32_t num_skins; 136 137 //! Texture width in pixels 138 int32_t skinwidth; 139 140 //! Texture height in pixels 141 int32_t skinheight; 142 143 //! Number of vertices contained in the file 144 int32_t num_verts; 145 146 //! Number of triangles contained in the file 147 int32_t num_tris; 148 149 //! Number of frames contained in the file 150 int32_t num_frames; 151 152 //! 0 = synchron, 1 = random . Ignored 153 //! (MDLn formats: number of texture coordinates) 154 int32_t synctype; 155 156 //! State flag 157 int32_t flags; 158 159 //! Could be the total size of the file (and not a float) 160 float size; 161 } PACK_STRUCT; 162 163 164 // ------------------------------------------------------------------------------------- 165 /** \struct Header_MDL7 166 * \brief Data structure for the MDL 7 main header 167 */ 168 struct Header_MDL7 169 { 170 //! magic number: "MDL7" 171 char ident[4]; 172 173 //! Version number. Ignored 174 int32_t version; 175 176 //! Number of bones in file 177 uint32_t bones_num; 178 179 //! Number of groups in file 180 uint32_t groups_num; 181 182 //! Size of data in the file 183 uint32_t data_size; 184 185 //! Ignored. Used to store entity specific information 186 int32_t entlump_size; 187 188 //! Ignored. Used to store MED related data 189 int32_t medlump_size; 190 191 //! Size of the Bone_MDL7 data structure used in the file 192 uint16_t bone_stc_size; 193 194 //! Size of the Skin_MDL 7 data structure used in the file 195 uint16_t skin_stc_size; 196 197 //! Size of a single color (e.g. in a material) 198 uint16_t colorvalue_stc_size; 199 200 //! Size of the Material_MDL7 data structure used in the file 201 uint16_t material_stc_size; 202 203 //! Size of a texture coordinate set in the file 204 uint16_t skinpoint_stc_size; 205 206 //! Size of a triangle in the file 207 uint16_t triangle_stc_size; 208 209 //! Size of a normal vertex in the file 210 uint16_t mainvertex_stc_size; 211 212 //! Size of a per-frame animated vertex in the file 213 //! (this is not supported) 214 uint16_t framevertex_stc_size; 215 216 //! Size of a bone animation matrix 217 uint16_t bonetrans_stc_size; 218 219 //! Size of the Frame_MDL7 data structure used in the file 220 uint16_t frame_stc_size; 221 } PACK_STRUCT; 222 223 224 // ------------------------------------------------------------------------------------- 225 /** \struct Bone_MDL7 226 * \brief Data structure for a bone in a MDL7 file 227 */ 228 struct Bone_MDL7 229 { 230 //! Index of the parent bone of *this* bone. 0xffff means: 231 //! "hey, I have no parent, I'm an orphan" 232 uint16_t parent_index; 233 uint8_t _unused_[2]; 234 235 //! Relative position of the bone (relative to the 236 //! parent bone) 237 float x,y,z; 238 239 //! Optional name of the bone 240 char name[1 /* DUMMY SIZE */]; 241 } PACK_STRUCT; 242 243 #if (!defined AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_20_CHARS) 244 # define AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_20_CHARS (16 + 20) 245 #endif 246 247 #if (!defined AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_32_CHARS) 248 # define AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_32_CHARS (16 + 32) 249 #endif 250 251 #if (!defined AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_NOT_THERE) 252 # define AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_NOT_THERE (16) 253 #endif 254 255 #if (!defined AI_MDL7_MAX_GROUPNAMESIZE) 256 # define AI_MDL7_MAX_GROUPNAMESIZE 16 257 #endif // ! AI_MDL7_MAX_GROUPNAMESIZE 258 259 // ------------------------------------------------------------------------------------- 260 /** \struct Group_MDL7 261 * \brief Group in a MDL7 file 262 */ 263 struct Group_MDL7 264 { 265 //! = '1' -> triangle based Mesh 266 unsigned char typ; 267 268 int8_t deformers; 269 int8_t max_weights; 270 int8_t _unused_; 271 272 //! size of data for this group in bytes ( MD7_GROUP stc. included). 273 int32_t groupdata_size; 274 char name[AI_MDL7_MAX_GROUPNAMESIZE]; 275 276 //! Number of skins 277 int32_t numskins; 278 279 //! Number of texture coordinates 280 int32_t num_stpts; 281 282 //! Number of triangles 283 int32_t numtris; 284 285 //! Number of vertices 286 int32_t numverts; 287 288 //! Number of frames 289 int32_t numframes; 290 } PACK_STRUCT; 291 292 #define AI_MDL7_SKINTYPE_MIPFLAG 0x08 293 #define AI_MDL7_SKINTYPE_MATERIAL 0x10 294 #define AI_MDL7_SKINTYPE_MATERIAL_ASCDEF 0x20 295 #define AI_MDL7_SKINTYPE_RGBFLAG 0x80 296 297 #if (!defined AI_MDL7_MAX_BONENAMESIZE) 298 # define AI_MDL7_MAX_BONENAMESIZE 20 299 #endif // !! AI_MDL7_MAX_BONENAMESIZE 300 301 // ------------------------------------------------------------------------------------- 302 /** \struct Deformer_MDL7 303 * \brief Deformer in a MDL7 file 304 */ 305 struct Deformer_MDL7 306 { 307 int8_t deformer_version; // 0 308 int8_t deformer_typ; // 0 - bones 309 int8_t _unused_[2]; 310 int32_t group_index; 311 int32_t elements; 312 int32_t deformerdata_size; 313 } PACK_STRUCT; 314 315 316 // ------------------------------------------------------------------------------------- 317 /** \struct DeformerElement_MDL7 318 * \brief Deformer element in a MDL7 file 319 */ 320 struct DeformerElement_MDL7 321 { 322 //! bei deformer_typ==0 (==bones) element_index == bone index 323 int32_t element_index; 324 char element_name[AI_MDL7_MAX_BONENAMESIZE]; 325 int32_t weights; 326 } PACK_STRUCT; 327 328 329 // ------------------------------------------------------------------------------------- 330 /** \struct DeformerWeight_MDL7 331 * \brief Deformer weight in a MDL7 file 332 */ 333 struct DeformerWeight_MDL7 334 { 335 //! for deformer_typ==0 (==bones) index == vertex index 336 int32_t index; 337 float weight; 338 } PACK_STRUCT; 339 340 341 // don't know why this was in the original headers ... 342 typedef int32_t MD7_MATERIAL_ASCDEFSIZE; 343 344 // ------------------------------------------------------------------------------------- 345 /** \struct ColorValue_MDL7 346 * \brief Data structure for a color value in a MDL7 file 347 */ 348 struct ColorValue_MDL7 349 { 350 float r,g,b,a; 351 } PACK_STRUCT; 352 353 // ------------------------------------------------------------------------------------- 354 /** \struct Material_MDL7 355 * \brief Data structure for a Material in a MDL7 file 356 */ 357 struct Material_MDL7 358 { 359 //! Diffuse base color of the material 360 ColorValue_MDL7 Diffuse; 361 362 //! Ambient base color of the material 363 ColorValue_MDL7 Ambient; 364 365 //! Specular base color of the material 366 ColorValue_MDL7 Specular; 367 368 //! Emissive base color of the material 369 ColorValue_MDL7 Emissive; 370 371 //! Phong power 372 float Power; 373 } PACK_STRUCT; 374 375 376 // ------------------------------------------------------------------------------------- 377 /** \struct Skin 378 * \brief Skin data structure #1 - used by Quake1, MDL2, MDL3 and MDL4 379 */ 380 struct Skin 381 { 382 //! 0 = single (Skin), 1 = group (GroupSkin) 383 //! For MDL3-5: Defines the type of the skin and there 384 //! fore the size of the data to skip: 385 //------------------------------------------------------- 386 //! 2 for 565 RGB, 387 //! 3 for 4444 ARGB, 388 //! 10 for 565 mipmapped, 389 //! 11 for 4444 mipmapped (bpp = 2), 390 //! 12 for 888 RGB mipmapped (bpp = 3), 391 //! 13 for 8888 ARGB mipmapped (bpp = 4) 392 //------------------------------------------------------- 393 int32_t group; 394 395 //! Texture data 396 uint8_t *data; 397 } PACK_STRUCT; 398 399 400 // ------------------------------------------------------------------------------------- 401 /** \struct Skin 402 * \brief Skin data structure #2 - used by MDL5, MDL6 and MDL7 403 * \see Skin 404 */ 405 struct Skin_MDL5 406 { 407 int32_t size, width, height; 408 uint8_t *data; 409 } PACK_STRUCT; 410 411 // maximum length of texture file name 412 #if (!defined AI_MDL7_MAX_TEXNAMESIZE) 413 # define AI_MDL7_MAX_TEXNAMESIZE 0x10 414 #endif 415 416 // --------------------------------------------------------------------------- 417 /** \struct Skin_MDL7 418 * \brief Skin data structure #3 - used by MDL7 and HMP7 419 */ 420 struct Skin_MDL7 421 { 422 uint8_t typ; 423 int8_t _unused_[3]; 424 int32_t width; 425 int32_t height; 426 char texture_name[AI_MDL7_MAX_TEXNAMESIZE]; 427 } PACK_STRUCT; 428 429 // ------------------------------------------------------------------------------------- 430 /** \struct RGB565 431 * \brief Data structure for a RGB565 pixel in a texture 432 */ 433 struct RGB565 434 { 435 uint16_t r : 5; 436 uint16_t g : 6; 437 uint16_t b : 5; 438 } PACK_STRUCT; 439 440 // ------------------------------------------------------------------------------------- 441 /** \struct ARGB4 442 * \brief Data structure for a ARGB4444 pixel in a texture 443 */ 444 struct ARGB4 445 { 446 uint16_t a : 4; 447 uint16_t r : 4; 448 uint16_t g : 4; 449 uint16_t b : 4; 450 } PACK_STRUCT; 451 452 // ------------------------------------------------------------------------------------- 453 /** \struct GroupSkin 454 * \brief Skin data structure #2 (group of pictures) 455 */ 456 struct GroupSkin 457 { 458 //! 0 = single (Skin), 1 = group (GroupSkin) 459 int32_t group; 460 461 //! Number of images 462 int32_t nb; 463 464 //! Time for each image 465 float *time; 466 467 //! Data of each image 468 uint8_t **data; 469 } PACK_STRUCT; 470 471 // ------------------------------------------------------------------------------------- 472 /** \struct TexCoord 473 * \brief Texture coordinate data structure used by the Quake1 MDL format 474 */ 475 struct TexCoord 476 { 477 //! Is the vertex on the noundary between front and back piece? 478 int32_t onseam; 479 480 //! Texture coordinate in the tx direction 481 int32_t s; 482 483 //! Texture coordinate in the ty direction 484 int32_t t; 485 } PACK_STRUCT; 486 487 // ------------------------------------------------------------------------------------- 488 /** \struct TexCoord_MDL3 489 * \brief Data structure for an UV coordinate in the 3DGS MDL3 format 490 */ 491 struct TexCoord_MDL3 492 { 493 //! position, horizontally in range 0..skinwidth-1 494 int16_t u; 495 496 //! position, vertically in range 0..skinheight-1 497 int16_t v; 498 } PACK_STRUCT; 499 500 // ------------------------------------------------------------------------------------- 501 /** \struct TexCoord_MDL7 502 * \brief Data structure for an UV coordinate in the 3DGS MDL7 format 503 */ 504 struct TexCoord_MDL7 505 { 506 //! position, horizontally in range 0..1 507 float u; 508 509 //! position, vertically in range 0..1 510 float v; 511 } PACK_STRUCT; 512 513 // ------------------------------------------------------------------------------------- 514 /** \struct SkinSet_MDL7 515 * \brief Skin set data structure for the 3DGS MDL7 format 516 * MDL7 references UV coordinates per face via an index list. 517 * This allows the use of multiple skins per face with just one 518 * UV coordinate set. 519 */ 520 struct SkinSet_MDL7 521 { 522 //! Index into the UV coordinate list 523 uint16_t st_index[3]; // size 6 524 525 //! Material index 526 int32_t material; // size 4 527 } PACK_STRUCT; 528 529 // ------------------------------------------------------------------------------------- 530 /** \struct Triangle 531 * \brief Triangle data structure for the Quake1 MDL format 532 */ 533 struct Triangle 534 { 535 //! 0 = backface, 1 = frontface 536 int32_t facesfront; 537 538 //! Vertex indices 539 int32_t vertex[3]; 540 } PACK_STRUCT; 541 542 // ------------------------------------------------------------------------------------- 543 /** \struct Triangle_MDL3 544 * \brief Triangle data structure for the 3DGS MDL3 format 545 */ 546 struct Triangle_MDL3 547 { 548 //! Index of 3 3D vertices in range 0..numverts 549 uint16_t index_xyz[3]; 550 551 //! Index of 3 skin vertices in range 0..numskinverts 552 uint16_t index_uv[3]; 553 } PACK_STRUCT; 554 555 // ------------------------------------------------------------------------------------- 556 /** \struct Triangle_MDL7 557 * \brief Triangle data structure for the 3DGS MDL7 format 558 */ 559 struct Triangle_MDL7 560 { 561 //! Vertex indices 562 uint16_t v_index[3]; // size 6 563 564 //! Two skinsets. The second will be used for multi-texturing 565 SkinSet_MDL7 skinsets[2]; 566 } PACK_STRUCT; 567 568 #if (!defined AI_MDL7_TRIANGLE_STD_SIZE_ONE_UV) 569 # define AI_MDL7_TRIANGLE_STD_SIZE_ONE_UV (6+sizeof(SkinSet_MDL7)-sizeof(uint32_t)) 570 #endif 571 #if (!defined AI_MDL7_TRIANGLE_STD_SIZE_ONE_UV_WITH_MATINDEX) 572 # define AI_MDL7_TRIANGLE_STD_SIZE_ONE_UV_WITH_MATINDEX (6+sizeof(SkinSet_MDL7)) 573 #endif 574 #if (!defined AI_MDL7_TRIANGLE_STD_SIZE_TWO_UV) 575 # define AI_MDL7_TRIANGLE_STD_SIZE_TWO_UV (6+2*sizeof(SkinSet_MDL7)) 576 #endif 577 578 // Helper constants for Triangle::facesfront 579 #if (!defined AI_MDL_BACKFACE) 580 # define AI_MDL_BACKFACE 0x0 581 #endif 582 #if (!defined AI_MDL_FRONTFACE) 583 # define AI_MDL_FRONTFACE 0x1 584 #endif 585 586 // ------------------------------------------------------------------------------------- 587 /** \struct Vertex 588 * \brief Vertex data structure 589 */ 590 struct Vertex 591 { 592 uint8_t v[3]; 593 uint8_t normalIndex; 594 } PACK_STRUCT; 595 596 597 // ------------------------------------------------------------------------------------- 598 struct Vertex_MDL4 599 { 600 uint16_t v[3]; 601 uint8_t normalIndex; 602 uint8_t unused; 603 } PACK_STRUCT; 604 605 #define AI_MDL7_FRAMEVERTEX120503_STCSIZE 16 606 #define AI_MDL7_FRAMEVERTEX030305_STCSIZE 26 607 608 // ------------------------------------------------------------------------------------- 609 /** \struct Vertex_MDL7 610 * \brief Vertex data structure used in MDL7 files 611 */ 612 struct Vertex_MDL7 613 { 614 float x,y,z; 615 uint16_t vertindex; // = bone index 616 union { 617 uint8_t norm162index; 618 float norm[3]; 619 }; 620 } PACK_STRUCT; 621 622 623 // ------------------------------------------------------------------------------------- 624 /** \struct BoneTransform_MDL7 625 * \brief bone transformation matrix structure used in MDL7 files 626 */ 627 struct BoneTransform_MDL7 628 { 629 //! 4*3 630 float m [4*4]; 631 632 //! the index of this vertex, 0.. header::bones_num - 1 633 uint16_t bone_index; 634 635 //! I HATE 3DGS AND THE SILLY DEVELOPER WHO DESIGNED 636 //! THIS STUPID FILE FORMAT! 637 int8_t _unused_[2]; 638 } PACK_STRUCT; 639 640 641 #define AI_MDL7_MAX_FRAMENAMESIZE 16 642 643 644 // ------------------------------------------------------------------------------------- 645 /** \struct Frame_MDL7 646 * \brief Frame data structure used by MDL7 files 647 */ 648 struct Frame_MDL7 649 { 650 char frame_name[AI_MDL7_MAX_FRAMENAMESIZE]; 651 uint32_t vertices_count; 652 uint32_t transmatrix_count; 653 }; 654 655 656 // ------------------------------------------------------------------------------------- 657 /** \struct SimpleFrame 658 * \brief Data structure for a simple frame 659 */ 660 struct SimpleFrame 661 { 662 //! Minimum vertex of the bounding box 663 Vertex bboxmin; 664 665 //! Maximum vertex of the bounding box 666 Vertex bboxmax; 667 668 //! Name of the frame 669 char name[16]; 670 671 //! Vertex list of the frame 672 Vertex *verts; 673 } PACK_STRUCT; 674 675 // ------------------------------------------------------------------------------------- 676 /** \struct Frame 677 * \brief Model frame data structure 678 */ 679 struct Frame 680 { 681 //! 0 = simple frame, !0 = group frame 682 int32_t type; 683 684 //! Frame data 685 SimpleFrame frame; 686 } PACK_STRUCT; 687 688 689 // ------------------------------------------------------------------------------------- 690 struct SimpleFrame_MDLn_SP 691 { 692 //! Minimum vertex of the bounding box 693 Vertex_MDL4 bboxmin; 694 695 //! Maximum vertex of the bounding box 696 Vertex_MDL4 bboxmax; 697 698 //! Name of the frame 699 char name[16]; 700 701 //! Vertex list of the frame 702 Vertex_MDL4 *verts; 703 } PACK_STRUCT; 704 705 // ------------------------------------------------------------------------------------- 706 /** \struct GroupFrame 707 * \brief Data structure for a group of frames 708 */ 709 struct GroupFrame 710 { 711 //! 0 = simple frame, !0 = group frame 712 int32_t type; 713 714 //! Minimum vertex for all single frames 715 Vertex min; 716 717 //! Maximum vertex for all single frames 718 Vertex max; 719 720 //! Time for all single frames 721 float *time; 722 723 //! List of single frames 724 SimpleFrame *frames; 725 } PACK_STRUCT; 726 727 #include "./../include/assimp/Compiler/poppack1.h" 728 729 // ------------------------------------------------------------------------------------- 730 /** \struct IntFace_MDL7 731 * \brief Internal data structure to temporarily represent a face 732 */ 733 struct IntFace_MDL7 734 { 735 // provide a constructor for our own convenience IntFace_MDL7IntFace_MDL7736 IntFace_MDL7() 737 { 738 // set everything to zero 739 mIndices[0] = mIndices[1] = mIndices[2] = 0; 740 iMatIndex[0] = iMatIndex[1] = 0; 741 } 742 743 //! Vertex indices 744 uint32_t mIndices[3]; 745 746 //! Material index (maximally two channels, which are joined later) 747 unsigned int iMatIndex[2]; 748 }; 749 750 // ------------------------------------------------------------------------------------- 751 /** \struct IntMaterial_MDL7 752 * \brief Internal data structure to temporarily represent a material 753 * which has been created from two single materials along with the 754 * original material indices. 755 */ 756 struct IntMaterial_MDL7 757 { 758 // provide a constructor for our own convenience IntMaterial_MDL7IntMaterial_MDL7759 IntMaterial_MDL7() 760 { 761 pcMat = NULL; 762 iOldMatIndices[0] = iOldMatIndices[1] = 0; 763 } 764 765 //! Material instance 766 aiMaterial* pcMat; 767 768 //! Old material indices 769 unsigned int iOldMatIndices[2]; 770 }; 771 772 // ------------------------------------------------------------------------------------- 773 /** \struct IntBone_MDL7 774 * \brief Internal data structure to represent a bone in a MDL7 file with 775 * all of its animation channels assigned to it. 776 */ 777 struct IntBone_MDL7 : aiBone 778 { 779 //! Default constructor IntBone_MDL7IntBone_MDL7780 IntBone_MDL7() : iParent (0xffff) 781 { 782 pkeyPositions.reserve(30); 783 pkeyScalings.reserve(30); 784 pkeyRotations.reserve(30); 785 } 786 787 //! Parent bone of the bone 788 uint64_t iParent; 789 790 //! Relative position of the bone 791 aiVector3D vPosition; 792 793 //! Array of position keys 794 std::vector<aiVectorKey> pkeyPositions; 795 796 //! Array of scaling keys 797 std::vector<aiVectorKey> pkeyScalings; 798 799 //! Array of rotation keys 800 std::vector<aiQuatKey> pkeyRotations; 801 }; 802 803 // ------------------------------------------------------------------------------------- 804 //! Describes a MDL7 frame 805 struct IntFrameInfo_MDL7 806 { 807 //! Construction from an existing frame header IntFrameInfo_MDL7IntFrameInfo_MDL7808 IntFrameInfo_MDL7(BE_NCONST MDL::Frame_MDL7* _pcFrame,unsigned int _iIndex) 809 : iIndex(_iIndex) 810 , pcFrame(_pcFrame) 811 {} 812 813 //! Index of the frame 814 unsigned int iIndex; 815 816 //! Points to the header of the frame 817 BE_NCONST MDL::Frame_MDL7* pcFrame; 818 }; 819 820 // ------------------------------------------------------------------------------------- 821 //! Describes a MDL7 mesh group 822 struct IntGroupInfo_MDL7 823 { 824 //! Default constructor IntGroupInfo_MDL7IntGroupInfo_MDL7825 IntGroupInfo_MDL7() 826 : iIndex(0) 827 , pcGroup(NULL) 828 , pcGroupUVs(NULL) 829 , pcGroupTris(NULL) 830 , pcGroupVerts(NULL) 831 {} 832 833 //! Construction from an existing group header IntGroupInfo_MDL7IntGroupInfo_MDL7834 IntGroupInfo_MDL7(BE_NCONST MDL::Group_MDL7* _pcGroup, unsigned int _iIndex) 835 : iIndex(_iIndex) 836 , pcGroup(_pcGroup) 837 {} 838 839 //! Index of the group 840 unsigned int iIndex; 841 842 //! Points to the header of the group 843 BE_NCONST MDL::Group_MDL7* pcGroup; 844 845 //! Points to the beginning of the uv coordinate section 846 BE_NCONST MDL::TexCoord_MDL7* pcGroupUVs; 847 848 //! Points to the beginning of the triangle section 849 MDL::Triangle_MDL7* pcGroupTris; 850 851 //! Points to the beginning of the vertex section 852 BE_NCONST MDL::Vertex_MDL7* pcGroupVerts; 853 }; 854 855 // ------------------------------------------------------------------------------------- 856 //! Holds the data that belongs to a MDL7 mesh group 857 struct IntGroupData_MDL7 858 { IntGroupData_MDL7IntGroupData_MDL7859 IntGroupData_MDL7() 860 : pcFaces(NULL), bNeed2UV(false) 861 {} 862 863 //! Array of faces that belong to the group 864 MDL::IntFace_MDL7* pcFaces; 865 866 //! Array of vertex positions 867 std::vector<aiVector3D> vPositions; 868 869 //! Array of vertex normals 870 std::vector<aiVector3D> vNormals; 871 872 //! Array of bones indices 873 std::vector<unsigned int> aiBones; 874 875 //! First UV coordinate set 876 std::vector<aiVector3D> vTextureCoords1; 877 878 //! Optional second UV coordinate set 879 std::vector<aiVector3D> vTextureCoords2; 880 881 //! Specifies whether there are two texture 882 //! coordinate sets required 883 bool bNeed2UV; 884 }; 885 886 // ------------------------------------------------------------------------------------- 887 //! Holds data from an MDL7 file that is shared by all mesh groups 888 struct IntSharedData_MDL7 889 { 890 //! Default constructor IntSharedData_MDL7IntSharedData_MDL7891 IntSharedData_MDL7() 892 { 893 abNeedMaterials.reserve(10); 894 } 895 896 //! Destruction: properly delete all allocated resources ~IntSharedData_MDL7IntSharedData_MDL7897 ~IntSharedData_MDL7() 898 { 899 // kill all bones 900 if (this->apcOutBones) 901 { 902 for (unsigned int m = 0; m < iNum;++m) 903 delete this->apcOutBones[m]; 904 delete[] this->apcOutBones; 905 } 906 } 907 908 //! Specifies which materials are used 909 std::vector<bool> abNeedMaterials; 910 911 //! List of all materials 912 std::vector<aiMaterial*> pcMats; 913 914 //! List of all bones 915 IntBone_MDL7** apcOutBones; 916 917 //! number of bones 918 unsigned int iNum; 919 }; 920 921 // ------------------------------------------------------------------------------------- 922 //! Contains input data for GenerateOutputMeshes_3DGS_MDL7 923 struct IntSplitGroupData_MDL7 924 { 925 //! Construction from a given shared data set IntSplitGroupData_MDL7IntSplitGroupData_MDL7926 IntSplitGroupData_MDL7(IntSharedData_MDL7& _shared, 927 std::vector<aiMesh*>& _avOutList) 928 929 : shared(_shared), avOutList(_avOutList) 930 { 931 } 932 933 //! Destruction: properly delete all allocated resources ~IntSplitGroupData_MDL7IntSplitGroupData_MDL7934 ~IntSplitGroupData_MDL7() 935 { 936 // kill all face lists 937 if(this->aiSplit) 938 { 939 for (unsigned int m = 0; m < shared.pcMats.size();++m) 940 delete this->aiSplit[m]; 941 delete[] this->aiSplit; 942 } 943 } 944 945 //! Contains a list of all faces per material 946 std::vector<unsigned int>** aiSplit; 947 948 //! Shared data for all groups of the model 949 IntSharedData_MDL7& shared; 950 951 //! List of meshes 952 std::vector<aiMesh*>& avOutList; 953 }; 954 955 956 } 957 } // end namespaces 958 959 #endif // !! AI_MDLFILEHELPER_H_INC 960