nuclear@0: /* nuclear@0: Open Asset Import Library (assimp) nuclear@0: ---------------------------------------------------------------------- nuclear@0: nuclear@0: Copyright (c) 2006-2012, assimp team nuclear@0: All rights reserved. nuclear@0: nuclear@0: Redistribution and use of this software in source and binary forms, nuclear@0: with or without modification, are permitted provided that the nuclear@0: following conditions are met: nuclear@0: nuclear@0: * Redistributions of source code must retain the above nuclear@0: copyright notice, this list of conditions and the nuclear@0: following disclaimer. nuclear@0: nuclear@0: * Redistributions in binary form must reproduce the above nuclear@0: copyright notice, this list of conditions and the nuclear@0: following disclaimer in the documentation and/or other nuclear@0: materials provided with the distribution. nuclear@0: nuclear@0: * Neither the name of the assimp team, nor the names of its nuclear@0: contributors may be used to endorse or promote products nuclear@0: derived from this software without specific prior nuclear@0: written permission of the assimp team. nuclear@0: nuclear@0: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS nuclear@0: "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT nuclear@0: LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR nuclear@0: A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT nuclear@0: OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, nuclear@0: SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT nuclear@0: LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, nuclear@0: DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY nuclear@0: THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT nuclear@0: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE nuclear@0: OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. nuclear@0: nuclear@0: ---------------------------------------------------------------------- nuclear@0: */ nuclear@0: nuclear@0: nuclear@0: /** nuclear@0: * @file MDLFileData.h nuclear@0: * @brief Definition of in-memory structures for the MDL file format. nuclear@0: * nuclear@0: * The specification has been taken from various sources on the internet. nuclear@0: * - http://tfc.duke.free.fr/coding/mdl-specs-en.html nuclear@0: * - Conitec's MED SDK nuclear@0: * - Many quite long HEX-editor sessions nuclear@0: */ nuclear@0: nuclear@0: #ifndef AI_MDLFILEHELPER_H_INC nuclear@0: #define AI_MDLFILEHELPER_H_INC nuclear@0: nuclear@0: #include "assimp/Compiler/pushpack1.h" nuclear@0: nuclear@0: namespace Assimp { nuclear@0: namespace MDL { nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------- nuclear@0: // to make it easier for us, we test the magic word against both "endianesses" nuclear@0: nuclear@0: // magic bytes used in Quake 1 MDL meshes nuclear@0: #define AI_MDL_MAGIC_NUMBER_BE AI_MAKE_MAGIC("IDPO") nuclear@0: #define AI_MDL_MAGIC_NUMBER_LE AI_MAKE_MAGIC("OPDI") nuclear@0: nuclear@0: // magic bytes used in GameStudio A MDL meshes nuclear@0: #define AI_MDL_MAGIC_NUMBER_BE_GS3 AI_MAKE_MAGIC("MDL2") nuclear@0: #define AI_MDL_MAGIC_NUMBER_LE_GS3 AI_MAKE_MAGIC("2LDM") nuclear@0: nuclear@0: // magic bytes used in GameStudio A4 MDL meshes nuclear@0: #define AI_MDL_MAGIC_NUMBER_BE_GS4 AI_MAKE_MAGIC("MDL3") nuclear@0: #define AI_MDL_MAGIC_NUMBER_LE_GS4 AI_MAKE_MAGIC("3LDM") nuclear@0: nuclear@0: // magic bytes used in GameStudio A5+ MDL meshes nuclear@0: #define AI_MDL_MAGIC_NUMBER_BE_GS5a AI_MAKE_MAGIC("MDL4") nuclear@0: #define AI_MDL_MAGIC_NUMBER_LE_GS5a AI_MAKE_MAGIC("4LDM") nuclear@0: #define AI_MDL_MAGIC_NUMBER_BE_GS5b AI_MAKE_MAGIC("MDL5") nuclear@0: #define AI_MDL_MAGIC_NUMBER_LE_GS5b AI_MAKE_MAGIC("5LDM") nuclear@0: nuclear@0: // magic bytes used in GameStudio A7+ MDL meshes nuclear@0: #define AI_MDL_MAGIC_NUMBER_BE_GS7 AI_MAKE_MAGIC("MDL7") nuclear@0: #define AI_MDL_MAGIC_NUMBER_LE_GS7 AI_MAKE_MAGIC("7LDM") nuclear@0: nuclear@0: nuclear@0: // common limitations for Quake1 meshes. The loader does not check them, nuclear@0: // (however it warns) but models should not exceed these limits. nuclear@0: #if (!defined AI_MDL_VERSION) nuclear@0: # define AI_MDL_VERSION 6 nuclear@0: #endif nuclear@0: #if (!defined AI_MDL_MAX_FRAMES) nuclear@0: # define AI_MDL_MAX_FRAMES 256 nuclear@0: #endif nuclear@0: #if (!defined AI_MDL_MAX_UVS) nuclear@0: # define AI_MDL_MAX_UVS 1024 nuclear@0: #endif nuclear@0: #if (!defined AI_MDL_MAX_VERTS) nuclear@0: # define AI_MDL_MAX_VERTS 1024 nuclear@0: #endif nuclear@0: #if (!defined AI_MDL_MAX_TRIANGLES) nuclear@0: # define AI_MDL_MAX_TRIANGLES 2048 nuclear@0: #endif nuclear@0: nuclear@0: // material key that is set for dummy materials that are nuclear@0: // just referencing another material nuclear@0: #if (!defined AI_MDL7_REFERRER_MATERIAL) nuclear@0: # define AI_MDL7_REFERRER_MATERIAL "&&&referrer&&&",0,0 nuclear@0: #endif nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------- nuclear@0: /** \struct Header nuclear@0: * \brief Data structure for the MDL main header nuclear@0: */ nuclear@0: struct Header nuclear@0: { nuclear@0: //! magic number: "IDPO" nuclear@0: uint32_t ident; nuclear@0: nuclear@0: //! version number: 6 nuclear@0: int32_t version; nuclear@0: nuclear@0: //! scale factors for each axis nuclear@0: aiVector3D scale; nuclear@0: nuclear@0: //! translation factors for each axis nuclear@0: aiVector3D translate; nuclear@0: nuclear@0: //! bounding radius of the mesh nuclear@0: float boundingradius; nuclear@0: nuclear@0: //! Position of the viewer's exe. Ignored nuclear@0: aiVector3D vEyePos; nuclear@0: nuclear@0: //! Number of textures nuclear@0: int32_t num_skins; nuclear@0: nuclear@0: //! Texture width in pixels nuclear@0: int32_t skinwidth; nuclear@0: nuclear@0: //! Texture height in pixels nuclear@0: int32_t skinheight; nuclear@0: nuclear@0: //! Number of vertices contained in the file nuclear@0: int32_t num_verts; nuclear@0: nuclear@0: //! Number of triangles contained in the file nuclear@0: int32_t num_tris; nuclear@0: nuclear@0: //! Number of frames contained in the file nuclear@0: int32_t num_frames; nuclear@0: nuclear@0: //! 0 = synchron, 1 = random . Ignored nuclear@0: //! (MDLn formats: number of texture coordinates) nuclear@0: int32_t synctype; nuclear@0: nuclear@0: //! State flag nuclear@0: int32_t flags; nuclear@0: nuclear@0: //! Could be the total size of the file (and not a float) nuclear@0: float size; nuclear@0: } PACK_STRUCT; nuclear@0: nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------- nuclear@0: /** \struct Header_MDL7 nuclear@0: * \brief Data structure for the MDL 7 main header nuclear@0: */ nuclear@0: struct Header_MDL7 nuclear@0: { nuclear@0: //! magic number: "MDL7" nuclear@0: char ident[4]; nuclear@0: nuclear@0: //! Version number. Ignored nuclear@0: int32_t version; nuclear@0: nuclear@0: //! Number of bones in file nuclear@0: uint32_t bones_num; nuclear@0: nuclear@0: //! Number of groups in file nuclear@0: uint32_t groups_num; nuclear@0: nuclear@0: //! Size of data in the file nuclear@0: uint32_t data_size; nuclear@0: nuclear@0: //! Ignored. Used to store entity specific information nuclear@0: int32_t entlump_size; nuclear@0: nuclear@0: //! Ignored. Used to store MED related data nuclear@0: int32_t medlump_size; nuclear@0: nuclear@0: //! Size of the Bone_MDL7 data structure used in the file nuclear@0: uint16_t bone_stc_size; nuclear@0: nuclear@0: //! Size of the Skin_MDL 7 data structure used in the file nuclear@0: uint16_t skin_stc_size; nuclear@0: nuclear@0: //! Size of a single color (e.g. in a material) nuclear@0: uint16_t colorvalue_stc_size; nuclear@0: nuclear@0: //! Size of the Material_MDL7 data structure used in the file nuclear@0: uint16_t material_stc_size; nuclear@0: nuclear@0: //! Size of a texture coordinate set in the file nuclear@0: uint16_t skinpoint_stc_size; nuclear@0: nuclear@0: //! Size of a triangle in the file nuclear@0: uint16_t triangle_stc_size; nuclear@0: nuclear@0: //! Size of a normal vertex in the file nuclear@0: uint16_t mainvertex_stc_size; nuclear@0: nuclear@0: //! Size of a per-frame animated vertex in the file nuclear@0: //! (this is not supported) nuclear@0: uint16_t framevertex_stc_size; nuclear@0: nuclear@0: //! Size of a bone animation matrix nuclear@0: uint16_t bonetrans_stc_size; nuclear@0: nuclear@0: //! Size of the Frame_MDL7 data structure used in the file nuclear@0: uint16_t frame_stc_size; nuclear@0: } PACK_STRUCT; nuclear@0: nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------- nuclear@0: /** \struct Bone_MDL7 nuclear@0: * \brief Data structure for a bone in a MDL7 file nuclear@0: */ nuclear@0: struct Bone_MDL7 nuclear@0: { nuclear@0: //! Index of the parent bone of *this* bone. 0xffff means: nuclear@0: //! "hey, I have no parent, I'm an orphan" nuclear@0: uint16_t parent_index; nuclear@0: uint8_t _unused_[2]; nuclear@0: nuclear@0: //! Relative position of the bone (relative to the nuclear@0: //! parent bone) nuclear@0: float x,y,z; nuclear@0: nuclear@0: //! Optional name of the bone nuclear@0: char name[1 /* DUMMY SIZE */]; nuclear@0: } PACK_STRUCT; nuclear@0: nuclear@0: #if (!defined AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_20_CHARS) nuclear@0: # define AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_20_CHARS (16 + 20) nuclear@0: #endif nuclear@0: nuclear@0: #if (!defined AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_32_CHARS) nuclear@0: # define AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_32_CHARS (16 + 32) nuclear@0: #endif nuclear@0: nuclear@0: #if (!defined AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_NOT_THERE) nuclear@0: # define AI_MDL7_BONE_STRUCT_SIZE__NAME_IS_NOT_THERE (16) nuclear@0: #endif nuclear@0: nuclear@0: #if (!defined AI_MDL7_MAX_GROUPNAMESIZE) nuclear@0: # define AI_MDL7_MAX_GROUPNAMESIZE 16 nuclear@0: #endif // ! AI_MDL7_MAX_GROUPNAMESIZE nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------- nuclear@0: /** \struct Group_MDL7 nuclear@0: * \brief Group in a MDL7 file nuclear@0: */ nuclear@0: struct Group_MDL7 nuclear@0: { nuclear@0: //! = '1' -> triangle based Mesh nuclear@0: unsigned char typ; nuclear@0: nuclear@0: int8_t deformers; nuclear@0: int8_t max_weights; nuclear@0: int8_t _unused_; nuclear@0: nuclear@0: //! size of data for this group in bytes ( MD7_GROUP stc. included). nuclear@0: int32_t groupdata_size; nuclear@0: char name[AI_MDL7_MAX_GROUPNAMESIZE]; nuclear@0: nuclear@0: //! Number of skins nuclear@0: int32_t numskins; nuclear@0: nuclear@0: //! Number of texture coordinates nuclear@0: int32_t num_stpts; nuclear@0: nuclear@0: //! Number of triangles nuclear@0: int32_t numtris; nuclear@0: nuclear@0: //! Number of vertices nuclear@0: int32_t numverts; nuclear@0: nuclear@0: //! Number of frames nuclear@0: int32_t numframes; nuclear@0: } PACK_STRUCT; nuclear@0: nuclear@0: #define AI_MDL7_SKINTYPE_MIPFLAG 0x08 nuclear@0: #define AI_MDL7_SKINTYPE_MATERIAL 0x10 nuclear@0: #define AI_MDL7_SKINTYPE_MATERIAL_ASCDEF 0x20 nuclear@0: #define AI_MDL7_SKINTYPE_RGBFLAG 0x80 nuclear@0: nuclear@0: #if (!defined AI_MDL7_MAX_BONENAMESIZE) nuclear@0: # define AI_MDL7_MAX_BONENAMESIZE 20 nuclear@0: #endif // !! AI_MDL7_MAX_BONENAMESIZE nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------- nuclear@0: /** \struct Deformer_MDL7 nuclear@0: * \brief Deformer in a MDL7 file nuclear@0: */ nuclear@0: struct Deformer_MDL7 nuclear@0: { nuclear@0: int8_t deformer_version; // 0 nuclear@0: int8_t deformer_typ; // 0 - bones nuclear@0: int8_t _unused_[2]; nuclear@0: int32_t group_index; nuclear@0: int32_t elements; nuclear@0: int32_t deformerdata_size; nuclear@0: } PACK_STRUCT; nuclear@0: nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------- nuclear@0: /** \struct DeformerElement_MDL7 nuclear@0: * \brief Deformer element in a MDL7 file nuclear@0: */ nuclear@0: struct DeformerElement_MDL7 nuclear@0: { nuclear@0: //! bei deformer_typ==0 (==bones) element_index == bone index nuclear@0: int32_t element_index; nuclear@0: char element_name[AI_MDL7_MAX_BONENAMESIZE]; nuclear@0: int32_t weights; nuclear@0: } PACK_STRUCT; nuclear@0: nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------- nuclear@0: /** \struct DeformerWeight_MDL7 nuclear@0: * \brief Deformer weight in a MDL7 file nuclear@0: */ nuclear@0: struct DeformerWeight_MDL7 nuclear@0: { nuclear@0: //! for deformer_typ==0 (==bones) index == vertex index nuclear@0: int32_t index; nuclear@0: float weight; nuclear@0: } PACK_STRUCT; nuclear@0: nuclear@0: nuclear@0: // don't know why this was in the original headers ... nuclear@0: typedef int32_t MD7_MATERIAL_ASCDEFSIZE; nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------- nuclear@0: /** \struct ColorValue_MDL7 nuclear@0: * \brief Data structure for a color value in a MDL7 file nuclear@0: */ nuclear@0: struct ColorValue_MDL7 nuclear@0: { nuclear@0: float r,g,b,a; nuclear@0: } PACK_STRUCT; nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------- nuclear@0: /** \struct Material_MDL7 nuclear@0: * \brief Data structure for a Material in a MDL7 file nuclear@0: */ nuclear@0: struct Material_MDL7 nuclear@0: { nuclear@0: //! Diffuse base color of the material nuclear@0: ColorValue_MDL7 Diffuse; nuclear@0: nuclear@0: //! Ambient base color of the material nuclear@0: ColorValue_MDL7 Ambient; nuclear@0: nuclear@0: //! Specular base color of the material nuclear@0: ColorValue_MDL7 Specular; nuclear@0: nuclear@0: //! Emissive base color of the material nuclear@0: ColorValue_MDL7 Emissive; nuclear@0: nuclear@0: //! Phong power nuclear@0: float Power; nuclear@0: } PACK_STRUCT; nuclear@0: nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------- nuclear@0: /** \struct Skin nuclear@0: * \brief Skin data structure #1 - used by Quake1, MDL2, MDL3 and MDL4 nuclear@0: */ nuclear@0: struct Skin nuclear@0: { nuclear@0: //! 0 = single (Skin), 1 = group (GroupSkin) nuclear@0: //! For MDL3-5: Defines the type of the skin and there nuclear@0: //! fore the size of the data to skip: nuclear@0: //------------------------------------------------------- nuclear@0: //! 2 for 565 RGB, nuclear@0: //! 3 for 4444 ARGB, nuclear@0: //! 10 for 565 mipmapped, nuclear@0: //! 11 for 4444 mipmapped (bpp = 2), nuclear@0: //! 12 for 888 RGB mipmapped (bpp = 3), nuclear@0: //! 13 for 8888 ARGB mipmapped (bpp = 4) nuclear@0: //------------------------------------------------------- nuclear@0: int32_t group; nuclear@0: nuclear@0: //! Texture data nuclear@0: uint8_t *data; nuclear@0: } PACK_STRUCT; nuclear@0: nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------- nuclear@0: /** \struct Skin nuclear@0: * \brief Skin data structure #2 - used by MDL5, MDL6 and MDL7 nuclear@0: * \see Skin nuclear@0: */ nuclear@0: struct Skin_MDL5 nuclear@0: { nuclear@0: int32_t size, width, height; nuclear@0: uint8_t *data; nuclear@0: } PACK_STRUCT; nuclear@0: nuclear@0: // maximum length of texture file name nuclear@0: #if (!defined AI_MDL7_MAX_TEXNAMESIZE) nuclear@0: # define AI_MDL7_MAX_TEXNAMESIZE 0x10 nuclear@0: #endif nuclear@0: nuclear@0: // --------------------------------------------------------------------------- nuclear@0: /** \struct Skin_MDL7 nuclear@0: * \brief Skin data structure #3 - used by MDL7 and HMP7 nuclear@0: */ nuclear@0: struct Skin_MDL7 nuclear@0: { nuclear@0: uint8_t typ; nuclear@0: int8_t _unused_[3]; nuclear@0: int32_t width; nuclear@0: int32_t height; nuclear@0: char texture_name[AI_MDL7_MAX_TEXNAMESIZE]; nuclear@0: } PACK_STRUCT; nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------- nuclear@0: /** \struct RGB565 nuclear@0: * \brief Data structure for a RGB565 pixel in a texture nuclear@0: */ nuclear@0: struct RGB565 nuclear@0: { nuclear@0: uint16_t r : 5; nuclear@0: uint16_t g : 6; nuclear@0: uint16_t b : 5; nuclear@0: } PACK_STRUCT; nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------- nuclear@0: /** \struct ARGB4 nuclear@0: * \brief Data structure for a ARGB4444 pixel in a texture nuclear@0: */ nuclear@0: struct ARGB4 nuclear@0: { nuclear@0: uint16_t a : 4; nuclear@0: uint16_t r : 4; nuclear@0: uint16_t g : 4; nuclear@0: uint16_t b : 4; nuclear@0: } PACK_STRUCT; nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------- nuclear@0: /** \struct GroupSkin nuclear@0: * \brief Skin data structure #2 (group of pictures) nuclear@0: */ nuclear@0: struct GroupSkin nuclear@0: { nuclear@0: //! 0 = single (Skin), 1 = group (GroupSkin) nuclear@0: int32_t group; nuclear@0: nuclear@0: //! Number of images nuclear@0: int32_t nb; nuclear@0: nuclear@0: //! Time for each image nuclear@0: float *time; nuclear@0: nuclear@0: //! Data of each image nuclear@0: uint8_t **data; nuclear@0: } PACK_STRUCT; nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------- nuclear@0: /** \struct TexCoord nuclear@0: * \brief Texture coordinate data structure used by the Quake1 MDL format nuclear@0: */ nuclear@0: struct TexCoord nuclear@0: { nuclear@0: //! Is the vertex on the noundary between front and back piece? nuclear@0: int32_t onseam; nuclear@0: nuclear@0: //! Texture coordinate in the tx direction nuclear@0: int32_t s; nuclear@0: nuclear@0: //! Texture coordinate in the ty direction nuclear@0: int32_t t; nuclear@0: } PACK_STRUCT; nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------- nuclear@0: /** \struct TexCoord_MDL3 nuclear@0: * \brief Data structure for an UV coordinate in the 3DGS MDL3 format nuclear@0: */ nuclear@0: struct TexCoord_MDL3 nuclear@0: { nuclear@0: //! position, horizontally in range 0..skinwidth-1 nuclear@0: int16_t u; nuclear@0: nuclear@0: //! position, vertically in range 0..skinheight-1 nuclear@0: int16_t v; nuclear@0: } PACK_STRUCT; nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------- nuclear@0: /** \struct TexCoord_MDL7 nuclear@0: * \brief Data structure for an UV coordinate in the 3DGS MDL7 format nuclear@0: */ nuclear@0: struct TexCoord_MDL7 nuclear@0: { nuclear@0: //! position, horizontally in range 0..1 nuclear@0: float u; nuclear@0: nuclear@0: //! position, vertically in range 0..1 nuclear@0: float v; nuclear@0: } PACK_STRUCT; nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------- nuclear@0: /** \struct SkinSet_MDL7 nuclear@0: * \brief Skin set data structure for the 3DGS MDL7 format nuclear@0: * MDL7 references UV coordinates per face via an index list. nuclear@0: * This allows the use of multiple skins per face with just one nuclear@0: * UV coordinate set. nuclear@0: */ nuclear@0: struct SkinSet_MDL7 nuclear@0: { nuclear@0: //! Index into the UV coordinate list nuclear@0: uint16_t st_index[3]; // size 6 nuclear@0: nuclear@0: //! Material index nuclear@0: int32_t material; // size 4 nuclear@0: } PACK_STRUCT; nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------- nuclear@0: /** \struct Triangle nuclear@0: * \brief Triangle data structure for the Quake1 MDL format nuclear@0: */ nuclear@0: struct Triangle nuclear@0: { nuclear@0: //! 0 = backface, 1 = frontface nuclear@0: int32_t facesfront; nuclear@0: nuclear@0: //! Vertex indices nuclear@0: int32_t vertex[3]; nuclear@0: } PACK_STRUCT; nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------- nuclear@0: /** \struct Triangle_MDL3 nuclear@0: * \brief Triangle data structure for the 3DGS MDL3 format nuclear@0: */ nuclear@0: struct Triangle_MDL3 nuclear@0: { nuclear@0: //! Index of 3 3D vertices in range 0..numverts nuclear@0: uint16_t index_xyz[3]; nuclear@0: nuclear@0: //! Index of 3 skin vertices in range 0..numskinverts nuclear@0: uint16_t index_uv[3]; nuclear@0: } PACK_STRUCT; nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------- nuclear@0: /** \struct Triangle_MDL7 nuclear@0: * \brief Triangle data structure for the 3DGS MDL7 format nuclear@0: */ nuclear@0: struct Triangle_MDL7 nuclear@0: { nuclear@0: //! Vertex indices nuclear@0: uint16_t v_index[3]; // size 6 nuclear@0: nuclear@0: //! Two skinsets. The second will be used for multi-texturing nuclear@0: SkinSet_MDL7 skinsets[2]; nuclear@0: } PACK_STRUCT; nuclear@0: nuclear@0: #if (!defined AI_MDL7_TRIANGLE_STD_SIZE_ONE_UV) nuclear@0: # define AI_MDL7_TRIANGLE_STD_SIZE_ONE_UV (6+sizeof(SkinSet_MDL7)-sizeof(uint32_t)) nuclear@0: #endif nuclear@0: #if (!defined AI_MDL7_TRIANGLE_STD_SIZE_ONE_UV_WITH_MATINDEX) nuclear@0: # define AI_MDL7_TRIANGLE_STD_SIZE_ONE_UV_WITH_MATINDEX (6+sizeof(SkinSet_MDL7)) nuclear@0: #endif nuclear@0: #if (!defined AI_MDL7_TRIANGLE_STD_SIZE_TWO_UV) nuclear@0: # define AI_MDL7_TRIANGLE_STD_SIZE_TWO_UV (6+2*sizeof(SkinSet_MDL7)) nuclear@0: #endif nuclear@0: nuclear@0: // Helper constants for Triangle::facesfront nuclear@0: #if (!defined AI_MDL_BACKFACE) nuclear@0: # define AI_MDL_BACKFACE 0x0 nuclear@0: #endif nuclear@0: #if (!defined AI_MDL_FRONTFACE) nuclear@0: # define AI_MDL_FRONTFACE 0x1 nuclear@0: #endif nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------- nuclear@0: /** \struct Vertex nuclear@0: * \brief Vertex data structure nuclear@0: */ nuclear@0: struct Vertex nuclear@0: { nuclear@0: uint8_t v[3]; nuclear@0: uint8_t normalIndex; nuclear@0: } PACK_STRUCT; nuclear@0: nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------- nuclear@0: struct Vertex_MDL4 nuclear@0: { nuclear@0: uint16_t v[3]; nuclear@0: uint8_t normalIndex; nuclear@0: uint8_t unused; nuclear@0: } PACK_STRUCT; nuclear@0: nuclear@0: #define AI_MDL7_FRAMEVERTEX120503_STCSIZE 16 nuclear@0: #define AI_MDL7_FRAMEVERTEX030305_STCSIZE 26 nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------- nuclear@0: /** \struct Vertex_MDL7 nuclear@0: * \brief Vertex data structure used in MDL7 files nuclear@0: */ nuclear@0: struct Vertex_MDL7 nuclear@0: { nuclear@0: float x,y,z; nuclear@0: uint16_t vertindex; // = bone index nuclear@0: union { nuclear@0: uint8_t norm162index; nuclear@0: float norm[3]; nuclear@0: }; nuclear@0: } PACK_STRUCT; nuclear@0: nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------- nuclear@0: /** \struct BoneTransform_MDL7 nuclear@0: * \brief bone transformation matrix structure used in MDL7 files nuclear@0: */ nuclear@0: struct BoneTransform_MDL7 nuclear@0: { nuclear@0: //! 4*3 nuclear@0: float m [4*4]; nuclear@0: nuclear@0: //! the index of this vertex, 0.. header::bones_num - 1 nuclear@0: uint16_t bone_index; nuclear@0: nuclear@0: //! I HATE 3DGS AND THE SILLY DEVELOPER WHO DESIGNED nuclear@0: //! THIS STUPID FILE FORMAT! nuclear@0: int8_t _unused_[2]; nuclear@0: } PACK_STRUCT; nuclear@0: nuclear@0: nuclear@0: #define AI_MDL7_MAX_FRAMENAMESIZE 16 nuclear@0: nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------- nuclear@0: /** \struct Frame_MDL7 nuclear@0: * \brief Frame data structure used by MDL7 files nuclear@0: */ nuclear@0: struct Frame_MDL7 nuclear@0: { nuclear@0: char frame_name[AI_MDL7_MAX_FRAMENAMESIZE]; nuclear@0: uint32_t vertices_count; nuclear@0: uint32_t transmatrix_count; nuclear@0: }; nuclear@0: nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------- nuclear@0: /** \struct SimpleFrame nuclear@0: * \brief Data structure for a simple frame nuclear@0: */ nuclear@0: struct SimpleFrame nuclear@0: { nuclear@0: //! Minimum vertex of the bounding box nuclear@0: Vertex bboxmin; nuclear@0: nuclear@0: //! Maximum vertex of the bounding box nuclear@0: Vertex bboxmax; nuclear@0: nuclear@0: //! Name of the frame nuclear@0: char name[16]; nuclear@0: nuclear@0: //! Vertex list of the frame nuclear@0: Vertex *verts; nuclear@0: } PACK_STRUCT; nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------- nuclear@0: /** \struct Frame nuclear@0: * \brief Model frame data structure nuclear@0: */ nuclear@0: struct Frame nuclear@0: { nuclear@0: //! 0 = simple frame, !0 = group frame nuclear@0: int32_t type; nuclear@0: nuclear@0: //! Frame data nuclear@0: SimpleFrame frame; nuclear@0: } PACK_STRUCT; nuclear@0: nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------- nuclear@0: struct SimpleFrame_MDLn_SP nuclear@0: { nuclear@0: //! Minimum vertex of the bounding box nuclear@0: Vertex_MDL4 bboxmin; nuclear@0: nuclear@0: //! Maximum vertex of the bounding box nuclear@0: Vertex_MDL4 bboxmax; nuclear@0: nuclear@0: //! Name of the frame nuclear@0: char name[16]; nuclear@0: nuclear@0: //! Vertex list of the frame nuclear@0: Vertex_MDL4 *verts; nuclear@0: } PACK_STRUCT; nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------- nuclear@0: /** \struct GroupFrame nuclear@0: * \brief Data structure for a group of frames nuclear@0: */ nuclear@0: struct GroupFrame nuclear@0: { nuclear@0: //! 0 = simple frame, !0 = group frame nuclear@0: int32_t type; nuclear@0: nuclear@0: //! Minimum vertex for all single frames nuclear@0: Vertex min; nuclear@0: nuclear@0: //! Maximum vertex for all single frames nuclear@0: Vertex max; nuclear@0: nuclear@0: //! Time for all single frames nuclear@0: float *time; nuclear@0: nuclear@0: //! List of single frames nuclear@0: SimpleFrame *frames; nuclear@0: } PACK_STRUCT; nuclear@0: nuclear@0: #include "assimp/Compiler/poppack1.h" nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------- nuclear@0: /** \struct IntFace_MDL7 nuclear@0: * \brief Internal data structure to temporarily represent a face nuclear@0: */ nuclear@0: struct IntFace_MDL7 nuclear@0: { nuclear@0: // provide a constructor for our own convenience nuclear@0: IntFace_MDL7() nuclear@0: { nuclear@0: // set everything to zero nuclear@0: mIndices[0] = mIndices[1] = mIndices[2] = 0; nuclear@0: iMatIndex[0] = iMatIndex[1] = 0; nuclear@0: } nuclear@0: nuclear@0: //! Vertex indices nuclear@0: uint32_t mIndices[3]; nuclear@0: nuclear@0: //! Material index (maximally two channels, which are joined later) nuclear@0: unsigned int iMatIndex[2]; nuclear@0: }; nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------- nuclear@0: /** \struct IntMaterial_MDL7 nuclear@0: * \brief Internal data structure to temporarily represent a material nuclear@0: * which has been created from two single materials along with the nuclear@0: * original material indices. nuclear@0: */ nuclear@0: struct IntMaterial_MDL7 nuclear@0: { nuclear@0: // provide a constructor for our own convenience nuclear@0: IntMaterial_MDL7() nuclear@0: { nuclear@0: pcMat = NULL; nuclear@0: iOldMatIndices[0] = iOldMatIndices[1] = 0; nuclear@0: } nuclear@0: nuclear@0: //! Material instance nuclear@0: aiMaterial* pcMat; nuclear@0: nuclear@0: //! Old material indices nuclear@0: unsigned int iOldMatIndices[2]; nuclear@0: }; nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------- nuclear@0: /** \struct IntBone_MDL7 nuclear@0: * \brief Internal data structure to represent a bone in a MDL7 file with nuclear@0: * all of its animation channels assigned to it. nuclear@0: */ nuclear@0: struct IntBone_MDL7 : aiBone nuclear@0: { nuclear@0: //! Default constructor nuclear@0: IntBone_MDL7() : iParent (0xffff) nuclear@0: { nuclear@0: pkeyPositions.reserve(30); nuclear@0: pkeyScalings.reserve(30); nuclear@0: pkeyRotations.reserve(30); nuclear@0: } nuclear@0: nuclear@0: //! Parent bone of the bone nuclear@0: uint64_t iParent; nuclear@0: nuclear@0: //! Relative position of the bone nuclear@0: aiVector3D vPosition; nuclear@0: nuclear@0: //! Array of position keys nuclear@0: std::vector pkeyPositions; nuclear@0: nuclear@0: //! Array of scaling keys nuclear@0: std::vector pkeyScalings; nuclear@0: nuclear@0: //! Array of rotation keys nuclear@0: std::vector pkeyRotations; nuclear@0: }; nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------- nuclear@0: //! Describes a MDL7 frame nuclear@0: struct IntFrameInfo_MDL7 nuclear@0: { nuclear@0: //! Construction from an existing frame header nuclear@0: IntFrameInfo_MDL7(BE_NCONST MDL::Frame_MDL7* _pcFrame,unsigned int _iIndex) nuclear@0: : iIndex(_iIndex) nuclear@0: , pcFrame(_pcFrame) nuclear@0: {} nuclear@0: nuclear@0: //! Index of the frame nuclear@0: unsigned int iIndex; nuclear@0: nuclear@0: //! Points to the header of the frame nuclear@0: BE_NCONST MDL::Frame_MDL7* pcFrame; nuclear@0: }; nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------- nuclear@0: //! Describes a MDL7 mesh group nuclear@0: struct IntGroupInfo_MDL7 nuclear@0: { nuclear@0: //! Default constructor nuclear@0: IntGroupInfo_MDL7() nuclear@0: : iIndex(0) nuclear@0: , pcGroup(NULL) nuclear@0: , pcGroupUVs(NULL) nuclear@0: , pcGroupTris(NULL) nuclear@0: , pcGroupVerts(NULL) nuclear@0: {} nuclear@0: nuclear@0: //! Construction from an existing group header nuclear@0: IntGroupInfo_MDL7(BE_NCONST MDL::Group_MDL7* _pcGroup, unsigned int _iIndex) nuclear@0: : iIndex(_iIndex) nuclear@0: , pcGroup(_pcGroup) nuclear@0: {} nuclear@0: nuclear@0: //! Index of the group nuclear@0: unsigned int iIndex; nuclear@0: nuclear@0: //! Points to the header of the group nuclear@0: BE_NCONST MDL::Group_MDL7* pcGroup; nuclear@0: nuclear@0: //! Points to the beginning of the uv coordinate section nuclear@0: BE_NCONST MDL::TexCoord_MDL7* pcGroupUVs; nuclear@0: nuclear@0: //! Points to the beginning of the triangle section nuclear@0: MDL::Triangle_MDL7* pcGroupTris; nuclear@0: nuclear@0: //! Points to the beginning of the vertex section nuclear@0: BE_NCONST MDL::Vertex_MDL7* pcGroupVerts; nuclear@0: }; nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------- nuclear@0: //! Holds the data that belongs to a MDL7 mesh group nuclear@0: struct IntGroupData_MDL7 nuclear@0: { nuclear@0: IntGroupData_MDL7() nuclear@0: : pcFaces(NULL), bNeed2UV(false) nuclear@0: {} nuclear@0: nuclear@0: //! Array of faces that belong to the group nuclear@0: MDL::IntFace_MDL7* pcFaces; nuclear@0: nuclear@0: //! Array of vertex positions nuclear@0: std::vector vPositions; nuclear@0: nuclear@0: //! Array of vertex normals nuclear@0: std::vector vNormals; nuclear@0: nuclear@0: //! Array of bones indices nuclear@0: std::vector aiBones; nuclear@0: nuclear@0: //! First UV coordinate set nuclear@0: std::vector vTextureCoords1; nuclear@0: nuclear@0: //! Optional second UV coordinate set nuclear@0: std::vector vTextureCoords2; nuclear@0: nuclear@0: //! Specifies whether there are two texture nuclear@0: //! coordinate sets required nuclear@0: bool bNeed2UV; nuclear@0: }; nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------- nuclear@0: //! Holds data from an MDL7 file that is shared by all mesh groups nuclear@0: struct IntSharedData_MDL7 nuclear@0: { nuclear@0: //! Default constructor nuclear@0: IntSharedData_MDL7() nuclear@0: { nuclear@0: abNeedMaterials.reserve(10); nuclear@0: } nuclear@0: nuclear@0: //! Destruction: properly delete all allocated resources nuclear@0: ~IntSharedData_MDL7() nuclear@0: { nuclear@0: // kill all bones nuclear@0: if (this->apcOutBones) nuclear@0: { nuclear@0: for (unsigned int m = 0; m < iNum;++m) nuclear@0: delete this->apcOutBones[m]; nuclear@0: delete[] this->apcOutBones; nuclear@0: } nuclear@0: } nuclear@0: nuclear@0: //! Specifies which materials are used nuclear@0: std::vector abNeedMaterials; nuclear@0: nuclear@0: //! List of all materials nuclear@0: std::vector pcMats; nuclear@0: nuclear@0: //! List of all bones nuclear@0: IntBone_MDL7** apcOutBones; nuclear@0: nuclear@0: //! number of bones nuclear@0: unsigned int iNum; nuclear@0: }; nuclear@0: nuclear@0: // ------------------------------------------------------------------------------------- nuclear@0: //! Contains input data for GenerateOutputMeshes_3DGS_MDL7 nuclear@0: struct IntSplitGroupData_MDL7 nuclear@0: { nuclear@0: //! Construction from a given shared data set nuclear@0: IntSplitGroupData_MDL7(IntSharedData_MDL7& _shared, nuclear@0: std::vector& _avOutList) nuclear@0: nuclear@0: : shared(_shared), avOutList(_avOutList) nuclear@0: { nuclear@0: } nuclear@0: nuclear@0: //! Destruction: properly delete all allocated resources nuclear@0: ~IntSplitGroupData_MDL7() nuclear@0: { nuclear@0: // kill all face lists nuclear@0: if(this->aiSplit) nuclear@0: { nuclear@0: for (unsigned int m = 0; m < shared.pcMats.size();++m) nuclear@0: delete this->aiSplit[m]; nuclear@0: delete[] this->aiSplit; nuclear@0: } nuclear@0: } nuclear@0: nuclear@0: //! Contains a list of all faces per material nuclear@0: std::vector** aiSplit; nuclear@0: nuclear@0: //! Shared data for all groups of the model nuclear@0: IntSharedData_MDL7& shared; nuclear@0: nuclear@0: //! List of meshes nuclear@0: std::vector& avOutList; nuclear@0: }; nuclear@0: nuclear@0: nuclear@0: } nuclear@0: } // end namespaces nuclear@0: nuclear@0: #endif // !! AI_MDLFILEHELPER_H_INC