1 /* 2 Open Asset Import Library (assimp) 3 ---------------------------------------------------------------------- 4 5 Copyright (c) 2006-2021, assimp team 6 7 8 All rights reserved. 9 10 Redistribution and use of this software in source and binary forms, 11 with or without modification, are permitted provided that the 12 following conditions are met: 13 14 * Redistributions of source code must retain the above 15 copyright notice, this list of conditions and the 16 following disclaimer. 17 18 * Redistributions in binary form must reproduce the above 19 copyright notice, this list of conditions and the 20 following disclaimer in the documentation and/or other 21 materials provided with the distribution. 22 23 * Neither the name of the assimp team, nor the names of its 24 contributors may be used to endorse or promote products 25 derived from this software without specific prior 26 written permission of the assimp team. 27 28 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 29 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 30 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 31 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 32 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 33 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 34 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 35 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 36 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 37 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 38 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 40 ---------------------------------------------------------------------- 41 */ 42 43 /** @file MD2FileData.h 44 * @brief Defines helper data structures for importing MD2 files 45 * http://linux.ucla.edu/~phaethon/q3/formats/md2-schoenblum.html 46 */ 47 #ifndef AI_MD2FILEHELPER_H_INC 48 #define AI_MD2FILEHELPER_H_INC 49 50 #include <assimp/types.h> 51 #include <stdint.h> 52 53 #include <assimp/Compiler/pushpack1.h> 54 55 namespace Assimp { 56 namespace MD2 { 57 58 // to make it easier for us, we test the magic word against both "endianesses" 59 #define AI_MD2_MAGIC_NUMBER_BE AI_MAKE_MAGIC("IDP2") 60 #define AI_MD2_MAGIC_NUMBER_LE AI_MAKE_MAGIC("2PDI") 61 62 // common limitations 63 #define AI_MD2_VERSION 15 64 #define AI_MD2_MAXQPATH 64 65 #define AI_MD2_MAX_FRAMES 512 66 #define AI_MD2_MAX_SKINS 32 67 #define AI_MD2_MAX_VERTS 2048 68 #define AI_MD2_MAX_TRIANGLES 4096 69 70 // --------------------------------------------------------------------------- 71 /** \brief Data structure for the MD2 main header 72 */ 73 struct Header 74 { 75 uint32_t magic; 76 uint32_t version; 77 uint32_t skinWidth; 78 uint32_t skinHeight; 79 uint32_t frameSize; 80 uint32_t numSkins; 81 uint32_t numVertices; 82 uint32_t numTexCoords; 83 uint32_t numTriangles; 84 uint32_t numGlCommands; 85 uint32_t numFrames; 86 uint32_t offsetSkins; 87 uint32_t offsetTexCoords; 88 uint32_t offsetTriangles; 89 uint32_t offsetFrames; 90 uint32_t offsetGlCommands; 91 uint32_t offsetEnd; 92 93 } PACK_STRUCT; 94 95 // --------------------------------------------------------------------------- 96 /** \brief Data structure for a MD2 OpenGl draw command 97 */ 98 struct GLCommand 99 { 100 float s, t; 101 uint32_t vertexIndex; 102 } PACK_STRUCT; 103 104 // --------------------------------------------------------------------------- 105 /** \brief Data structure for a MD2 triangle 106 */ 107 struct Triangle 108 { 109 uint16_t vertexIndices[3]; 110 uint16_t textureIndices[3]; 111 } PACK_STRUCT; 112 113 // --------------------------------------------------------------------------- 114 /** \brief Data structure for a MD2 vertex 115 */ 116 struct Vertex 117 { 118 uint8_t vertex[3]; 119 uint8_t lightNormalIndex; 120 } PACK_STRUCT; 121 122 // --------------------------------------------------------------------------- 123 /** \brief Data structure for a MD2 frame 124 */ 125 struct Frame 126 { 127 float scale[3]; 128 float translate[3]; 129 char name[16]; 130 Vertex vertices[1]; 131 } PACK_STRUCT; 132 133 // --------------------------------------------------------------------------- 134 /** \brief Data structure for a MD2 texture coordinate 135 */ 136 struct TexCoord 137 { 138 uint16_t s; 139 uint16_t t; 140 } PACK_STRUCT; 141 142 // --------------------------------------------------------------------------- 143 /** \brief Data structure for a MD2 skin 144 */ 145 struct Skin 146 { 147 char name[AI_MD2_MAXQPATH]; /* texture file name */ 148 } PACK_STRUCT; 149 150 #include <assimp/Compiler/poppack1.h> 151 152 153 // --------------------------------------------------------------------------- 154 //! Lookup a normal vector from Quake's normal lookup table 155 //! \param index Input index (0-161) 156 //! \param vOut Receives the output normal 157 void LookupNormalIndex(uint8_t index,aiVector3D& vOut); 158 159 160 } 161 } 162 163 #endif // !! include guard 164 165