1 /* 2 Open Asset Import Library (assimp) 3 ---------------------------------------------------------------------- 4 5 Copyright (c) 2006-2017, assimp team 6 7 All rights reserved. 8 9 Redistribution and use of this software in source and binary forms, 10 with or without modification, are permitted provided that the 11 following conditions are met: 12 13 * Redistributions of source code must retain the above 14 copyright notice, this list of conditions and the 15 following disclaimer. 16 17 * Redistributions in binary form must reproduce the above 18 copyright notice, this list of conditions and the 19 following disclaimer in the documentation and/or other 20 materials provided with the distribution. 21 22 * Neither the name of the assimp team, nor the names of its 23 contributors may be used to endorse or promote products 24 derived from this software without specific prior 25 written permission of the assimp team. 26 27 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 28 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 29 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 30 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 31 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 32 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 33 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 34 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 35 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 36 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 37 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 38 39 ---------------------------------------------------------------------- 40 */ 41 42 /** @file Defines the helper data structures for importing MDC files 43 44 ********************************************************************** 45 File format specification: 46 http://themdcfile.planetwolfenstein.gamespy.com/MDC_File_Format.pdf 47 ********************************************************************** 48 49 */ 50 #ifndef AI_MDCFILEHELPER_H_INC 51 #define AI_MDCFILEHELPER_H_INC 52 53 #include <assimp/types.h> 54 #include <assimp/mesh.h> 55 #include <assimp/anim.h> 56 57 #include <assimp/Compiler/pushpack1.h> 58 #include <stdint.h> 59 60 namespace Assimp { 61 namespace MDC { 62 63 64 // to make it easier for us, we test the magic word against both "endianesses" 65 #define AI_MDC_MAGIC_NUMBER_BE AI_MAKE_MAGIC("CPDI") 66 #define AI_MDC_MAGIC_NUMBER_LE AI_MAKE_MAGIC("IDPC") 67 68 // common limitations 69 #define AI_MDC_VERSION 2 70 #define AI_MDC_MAXQPATH 64 71 #define AI_MDC_MAX_BONES 128 72 73 #define AI_MDC_CVERT_BIAS 127.0f 74 #define AI_MDC_DELTA_SCALING 4.0f 75 #define AI_MDC_BASE_SCALING (1.0f / 64.0f) 76 77 78 // --------------------------------------------------------------------------- 79 /** \brief Data structure for a MDC file's main header 80 */ 81 struct Header 82 { 83 uint32_t ulIdent ; 84 uint32_t ulVersion ; 85 char ucName [ AI_MDC_MAXQPATH ] ; 86 uint32_t ulFlags ; 87 uint32_t ulNumFrames ; 88 uint32_t ulNumTags ; 89 uint32_t ulNumSurfaces ; 90 uint32_t ulNumSkins ; 91 uint32_t ulOffsetBorderFrames ; 92 uint32_t ulOffsetTagNames ; 93 uint32_t ulOffsetTagFrames ; 94 uint32_t ulOffsetSurfaces ; 95 uint32_t ulOffsetEnd ; 96 } PACK_STRUCT ; 97 98 99 // --------------------------------------------------------------------------- 100 /** \brief Data structure for a MDC file's surface header 101 */ 102 struct Surface 103 { 104 uint32_t ulIdent ; 105 char ucName [ AI_MDC_MAXQPATH ] ; 106 uint32_t ulFlags ; 107 uint32_t ulNumCompFrames ; 108 uint32_t ulNumBaseFrames ; 109 uint32_t ulNumShaders ; 110 uint32_t ulNumVertices ; 111 uint32_t ulNumTriangles ; 112 uint32_t ulOffsetTriangles ; 113 uint32_t ulOffsetShaders ; 114 uint32_t ulOffsetTexCoords ; 115 uint32_t ulOffsetBaseVerts ; 116 uint32_t ulOffsetCompVerts ; 117 uint32_t ulOffsetFrameBaseFrames ; 118 uint32_t ulOffsetFrameCompFrames ; 119 uint32_t ulOffsetEnd; SurfaceSurface120 Surface() 121 : ulIdent(), 122 ulFlags(), 123 ulNumCompFrames(), 124 ulNumBaseFrames(), 125 ulNumShaders(), 126 ulNumVertices(), 127 ulNumTriangles(), 128 ulOffsetTriangles(), 129 ulOffsetShaders(), 130 ulOffsetTexCoords(), 131 ulOffsetBaseVerts(), 132 ulOffsetCompVerts(), 133 ulOffsetFrameBaseFrames(), 134 ulOffsetFrameCompFrames(), 135 ulOffsetEnd() 136 { 137 ucName[AI_MDC_MAXQPATH-1] = '\0'; 138 } 139 } PACK_STRUCT; 140 141 // --------------------------------------------------------------------------- 142 /** \brief Data structure for a MDC frame 143 */ 144 struct Frame 145 { 146 //! bounding box minimum coords 147 aiVector3D bboxMin ; 148 149 //! bounding box maximum coords 150 aiVector3D bboxMax ; 151 152 //! local origin of the frame 153 aiVector3D localOrigin ; 154 155 //! radius of the BB 156 float radius ; 157 158 //! Name of the frame 159 char name [ 16 ] ; 160 } /*PACK_STRUCT*/; 161 162 // --------------------------------------------------------------------------- 163 /** \brief Data structure for a MDC triangle 164 */ 165 struct Triangle 166 { 167 uint32_t aiIndices[3]; 168 } PACK_STRUCT; 169 170 // --------------------------------------------------------------------------- 171 /** \brief Data structure for a MDC texture coordinate 172 */ 173 struct TexturCoord 174 { 175 float u,v; 176 } PACK_STRUCT; 177 178 // --------------------------------------------------------------------------- 179 /** \brief Data structure for a MDC base vertex 180 */ 181 struct BaseVertex 182 { 183 int16_t x,y,z; 184 uint16_t normal; 185 } PACK_STRUCT; 186 187 // --------------------------------------------------------------------------- 188 /** \brief Data structure for a MDC compressed vertex 189 */ 190 struct CompressedVertex 191 { 192 uint8_t xd,yd,zd,nd; 193 } PACK_STRUCT; 194 195 196 // --------------------------------------------------------------------------- 197 /** \brief Data structure for a MDC shader 198 */ 199 struct Shader 200 { 201 char ucName [ AI_MDC_MAXQPATH ] ; 202 uint32_t ulPath; 203 204 } PACK_STRUCT; 205 206 #include <assimp/Compiler/poppack1.h> 207 208 209 // --------------------------------------------------------------------------- 210 /** Build a floating point vertex from the compressed data in MDC files 211 */ 212 void BuildVertex(const Frame& frame, 213 const BaseVertex& bvert, 214 const CompressedVertex& cvert, 215 aiVector3D& vXYZOut, 216 aiVector3D& vNorOut); 217 }} 218 219 #endif // !! AI_MDCFILEHELPER_H_INC 220