nuclear@0: /* nuclear@0: Open Asset Import Library (ASSIMP) nuclear@0: ---------------------------------------------------------------------- nuclear@0: nuclear@0: Copyright (c) 2006-2010, ASSIMP Development 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 Development 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: /** @file Defines the helper data structures for importing MD4 files */ nuclear@0: #ifndef AI_MD4FILEHELPER_H_INC nuclear@0: #define AI_MD4FILEHELPER_H_INC nuclear@0: nuclear@0: #include nuclear@0: #include nuclear@0: #include nuclear@0: nuclear@0: #include "../include/aiTypes.h" nuclear@0: #include "../include/aiMesh.h" nuclear@0: #include "../include/aiAnim.h" nuclear@0: nuclear@0: #if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) nuclear@0: # pragma pack(push,1) nuclear@0: # define PACK_STRUCT nuclear@0: #elif defined( __GNUC__ ) nuclear@0: # define PACK_STRUCT __attribute__((packed)) nuclear@0: #else nuclear@0: # error Compiler not supported nuclear@0: #endif nuclear@0: nuclear@0: nuclear@0: namespace Assimp nuclear@0: { nuclear@0: // http://gongo.quakedev.com/md4.html nuclear@0: namespace MD4 nuclear@0: { nuclear@0: nuclear@0: #define AI_MD4_MAGIC_NUMBER_BE 'IDP4' nuclear@0: #define AI_MD4_MAGIC_NUMBER_LE '4PDI' nuclear@0: nuclear@0: // common limitations nuclear@0: #define AI_MD4_VERSION 4 nuclear@0: #define AI_MD4_MAXQPATH 64 nuclear@0: #define AI_MD4_MAX_FRAMES 2028 nuclear@0: #define AI_MD4_MAX_SURFACES 32 nuclear@0: #define AI_MD4_MAX_BONES 256 nuclear@0: #define AI_MD4_MAX_VERTS 4096 nuclear@0: #define AI_MD4_MAX_TRIANGLES 8192 nuclear@0: nuclear@0: // --------------------------------------------------------------------------- nuclear@0: /** \brief Data structure for the MD4 main header nuclear@0: */ nuclear@0: // --------------------------------------------------------------------------- nuclear@0: struct Header nuclear@0: { nuclear@0: //! magic number nuclear@0: int32_t magic; nuclear@0: nuclear@0: //! file format version nuclear@0: int32_t version; nuclear@0: nuclear@0: //! original name in .pak archive nuclear@0: unsigned char name[ AI_MD4_MAXQPATH ]; nuclear@0: nuclear@0: //! number of frames in the file nuclear@0: int32_t NUM_FRAMES; nuclear@0: nuclear@0: //! number of bones in the file nuclear@0: int32_t NUM_BONES; nuclear@0: nuclear@0: //! number of surfaces in the file nuclear@0: int32_t NUM_SURFACES; nuclear@0: nuclear@0: //! offset of the first frame nuclear@0: int32_t OFS_FRAMES; nuclear@0: nuclear@0: //! offset of the first bone nuclear@0: int32_t OFS_BONES; nuclear@0: nuclear@0: //! offset of the first surface nuclear@0: int32_t OFS_SURFACES; nuclear@0: nuclear@0: //! end of file nuclear@0: int32_t OFS_EOF; nuclear@0: } PACK_STRUCT; nuclear@0: nuclear@0: // --------------------------------------------------------------------------- nuclear@0: /** \brief Stores the local transformation matrix of a bone nuclear@0: */ nuclear@0: // --------------------------------------------------------------------------- nuclear@0: struct BoneFrame nuclear@0: { nuclear@0: float matrix[3][4]; nuclear@0: } PACK_STRUCT; nuclear@0: nuclear@0: // --------------------------------------------------------------------------- nuclear@0: /** \brief Stores the name / parent index / flag of a node nuclear@0: */ nuclear@0: // --------------------------------------------------------------------------- nuclear@0: struct BoneName nuclear@0: { nuclear@0: char name[32] ; nuclear@0: int parent ; nuclear@0: int flags ; nuclear@0: } PACK_STRUCT; nuclear@0: nuclear@0: // --------------------------------------------------------------------------- nuclear@0: /** \brief Data structure for a surface in a MD4 file nuclear@0: */ nuclear@0: // --------------------------------------------------------------------------- nuclear@0: struct Surface nuclear@0: { nuclear@0: int32_t ident; nuclear@0: char name[64]; nuclear@0: char shader[64]; nuclear@0: int32_t shaderIndex; nuclear@0: int32_t lodBias; nuclear@0: int32_t minLod; nuclear@0: int32_t ofsHeader; nuclear@0: int32_t numVerts; nuclear@0: int32_t ofsVerts; nuclear@0: int32_t numTris; nuclear@0: int32_t ofsTris; nuclear@0: int32_t numBoneRefs; nuclear@0: int32_t ofsBoneRefs; nuclear@0: int32_t ofsCollapseMap; nuclear@0: int32_t ofsEnd; nuclear@0: } PACK_STRUCT; nuclear@0: nuclear@0: nuclear@0: // --------------------------------------------------------------------------- nuclear@0: /** \brief Data structure for a MD4 vertex' weight nuclear@0: */ nuclear@0: // --------------------------------------------------------------------------- nuclear@0: struct Weight nuclear@0: { nuclear@0: int32_t boneIndex; nuclear@0: float boneWeight; nuclear@0: float offset[3]; nuclear@0: } PACK_STRUCT; nuclear@0: nuclear@0: // --------------------------------------------------------------------------- nuclear@0: /** \brief Data structure for a vertex in a MD4 file nuclear@0: */ nuclear@0: // --------------------------------------------------------------------------- nuclear@0: struct Vertex nuclear@0: { nuclear@0: float vertex[3]; nuclear@0: float normal[3]; nuclear@0: float texCoords[2]; nuclear@0: int32_t numWeights; nuclear@0: Weight weights[1]; nuclear@0: } PACK_STRUCT; nuclear@0: nuclear@0: // --------------------------------------------------------------------------- nuclear@0: /** \brief Data structure for a triangle in a MD4 file nuclear@0: */ nuclear@0: // --------------------------------------------------------------------------- nuclear@0: struct Triangle nuclear@0: { nuclear@0: int32_t indexes[3]; nuclear@0: } PACK_STRUCT; nuclear@0: nuclear@0: // --------------------------------------------------------------------------- nuclear@0: /** \brief Data structure for a MD4 frame nuclear@0: */ nuclear@0: // --------------------------------------------------------------------------- nuclear@0: struct Frame nuclear@0: { nuclear@0: float bounds[3][2]; nuclear@0: float localOrigin[3]; nuclear@0: float radius; nuclear@0: BoneFrame bones[1]; nuclear@0: } PACK_STRUCT; nuclear@0: nuclear@0: nuclear@0: // reset packing to the original value nuclear@0: #if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) nuclear@0: # pragma pack( pop ) nuclear@0: #endif nuclear@0: #undef PACK_STRUCT nuclear@0: nuclear@0: nuclear@0: }; nuclear@0: }; nuclear@0: nuclear@0: #endif // !! AI_MD4FILEHELPER_H_INC