1 /* 2 Open Asset Import Library (assimp) 3 ---------------------------------------------------------------------- 4 5 Copyright (c) 2006-2016, 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 /** @file Defines the helper data structures for importing MDC files 42 43 ********************************************************************** 44 File format specification: 45 http://themdcfile.planetwolfenstein.gamespy.com/MDC_File_Format.pdf 46 ********************************************************************** 47 48 */ 49 #ifndef AI_MDCFILEHELPER_H_INC 50 #define AI_MDCFILEHELPER_H_INC 51 52 #include <assimp/types.h> 53 #include <assimp/mesh.h> 54 #include <assimp/anim.h> 55 56 #include <assimp/Compiler/pushpack1.h> 57 #include <stdint.h> 58 59 namespace Assimp { 60 namespace MDC { 61 62 63 // to make it easier for us, we test the magic word against both "endianesses" 64 #define AI_MDC_MAGIC_NUMBER_BE AI_MAKE_MAGIC("CPDI") 65 #define AI_MDC_MAGIC_NUMBER_LE AI_MAKE_MAGIC("IDPC") 66 67 // common limitations 68 #define AI_MDC_VERSION 2 69 #define AI_MDC_MAXQPATH 64 70 #define AI_MDC_MAX_BONES 128 71 72 #define AI_MDC_CVERT_BIAS 127.0f 73 #define AI_MDC_DELTA_SCALING 4.0f 74 #define AI_MDC_BASE_SCALING (1.0f / 64.0f) 75 76 77 // --------------------------------------------------------------------------- 78 /** \brief Data structure for a MDC file's main header 79 */ 80 struct Header 81 { 82 uint32_t ulIdent ; 83 uint32_t ulVersion ; 84 char ucName [ AI_MDC_MAXQPATH ] ; 85 uint32_t ulFlags ; 86 uint32_t ulNumFrames ; 87 uint32_t ulNumTags ; 88 uint32_t ulNumSurfaces ; 89 uint32_t ulNumSkins ; 90 uint32_t ulOffsetBorderFrames ; 91 uint32_t ulOffsetTagNames ; 92 uint32_t ulOffsetTagFrames ; 93 uint32_t ulOffsetSurfaces ; 94 uint32_t ulOffsetEnd ; 95 } PACK_STRUCT ; 96 97 98 // --------------------------------------------------------------------------- 99 /** \brief Data structure for a MDC file's surface header 100 */ 101 struct Surface 102 { 103 uint32_t ulIdent ; 104 char ucName [ AI_MDC_MAXQPATH ] ; 105 uint32_t ulFlags ; 106 uint32_t ulNumCompFrames ; 107 uint32_t ulNumBaseFrames ; 108 uint32_t ulNumShaders ; 109 uint32_t ulNumVertices ; 110 uint32_t ulNumTriangles ; 111 uint32_t ulOffsetTriangles ; 112 uint32_t ulOffsetShaders ; 113 uint32_t ulOffsetTexCoords ; 114 uint32_t ulOffsetBaseVerts ; 115 uint32_t ulOffsetCompVerts ; 116 uint32_t ulOffsetFrameBaseFrames ; 117 uint32_t ulOffsetFrameCompFrames ; 118 uint32_t ulOffsetEnd; SurfaceSurface119 Surface() 120 : ulIdent(), 121 ulFlags(), 122 ulNumCompFrames(), 123 ulNumBaseFrames(), 124 ulNumShaders(), 125 ulNumVertices(), 126 ulNumTriangles(), 127 ulOffsetTriangles(), 128 ulOffsetShaders(), 129 ulOffsetTexCoords(), 130 ulOffsetBaseVerts(), 131 ulOffsetCompVerts(), 132 ulOffsetFrameBaseFrames(), 133 ulOffsetFrameCompFrames(), 134 ulOffsetEnd() 135 { 136 ucName[AI_MDC_MAXQPATH-1] = '\0'; 137 } 138 } PACK_STRUCT; 139 140 // --------------------------------------------------------------------------- 141 /** \brief Data structure for a MDC frame 142 */ 143 struct Frame 144 { 145 //! bounding box minimum coords 146 aiVector3D bboxMin ; 147 148 //! bounding box maximum coords 149 aiVector3D bboxMax ; 150 151 //! local origin of the frame 152 aiVector3D localOrigin ; 153 154 //! radius of the BB 155 float radius ; 156 157 //! Name of the frame 158 char name [ 16 ] ; 159 } PACK_STRUCT; 160 161 // --------------------------------------------------------------------------- 162 /** \brief Data structure for a MDC triangle 163 */ 164 struct Triangle 165 { 166 uint32_t aiIndices[3]; 167 } PACK_STRUCT; 168 169 // --------------------------------------------------------------------------- 170 /** \brief Data structure for a MDC texture coordinate 171 */ 172 struct TexturCoord 173 { 174 float u,v; 175 } PACK_STRUCT; 176 177 // --------------------------------------------------------------------------- 178 /** \brief Data structure for a MDC base vertex 179 */ 180 struct BaseVertex 181 { 182 int16_t x,y,z; 183 uint16_t normal; 184 } PACK_STRUCT; 185 186 // --------------------------------------------------------------------------- 187 /** \brief Data structure for a MDC compressed vertex 188 */ 189 struct CompressedVertex 190 { 191 uint8_t xd,yd,zd,nd; 192 } PACK_STRUCT; 193 194 195 // --------------------------------------------------------------------------- 196 /** \brief Data structure for a MDC shader 197 */ 198 struct Shader 199 { 200 char ucName [ AI_MDC_MAXQPATH ] ; 201 uint32_t ulPath; 202 203 } PACK_STRUCT; 204 205 #include <assimp/Compiler/poppack1.h> 206 207 208 // --------------------------------------------------------------------------- 209 /** Build a floating point vertex from the compressed data in MDC files 210 */ 211 void BuildVertex(const Frame& frame, 212 const BaseVertex& bvert, 213 const CompressedVertex& cvert, 214 aiVector3D& vXYZOut, 215 aiVector3D& vNorOut); 216 }} 217 218 #endif // !! AI_MDCFILEHELPER_H_INC 219