vrshoot
diff libs/assimp/MDCFileData.h @ 0:b2f14e535253
initial commit
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 01 Feb 2014 19:58:19 +0200 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/libs/assimp/MDCFileData.h Sat Feb 01 19:58:19 2014 +0200 1.3 @@ -0,0 +1,203 @@ 1.4 +/* 1.5 +Open Asset Import Library (assimp) 1.6 +---------------------------------------------------------------------- 1.7 + 1.8 +Copyright (c) 2006-2012, assimp team 1.9 +All rights reserved. 1.10 + 1.11 +Redistribution and use of this software in source and binary forms, 1.12 +with or without modification, are permitted provided that the 1.13 +following conditions are met: 1.14 + 1.15 +* Redistributions of source code must retain the above 1.16 + copyright notice, this list of conditions and the 1.17 + following disclaimer. 1.18 + 1.19 +* Redistributions in binary form must reproduce the above 1.20 + copyright notice, this list of conditions and the 1.21 + following disclaimer in the documentation and/or other 1.22 + materials provided with the distribution. 1.23 + 1.24 +* Neither the name of the assimp team, nor the names of its 1.25 + contributors may be used to endorse or promote products 1.26 + derived from this software without specific prior 1.27 + written permission of the assimp team. 1.28 + 1.29 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1.30 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1.31 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 1.32 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 1.33 +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 1.34 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 1.35 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 1.36 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 1.37 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 1.38 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 1.39 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 1.40 + 1.41 +---------------------------------------------------------------------- 1.42 +*/ 1.43 + 1.44 +/** @file Defines the helper data structures for importing MDC files 1.45 + 1.46 +********************************************************************** 1.47 +File format specification: 1.48 +http://themdcfile.planetwolfenstein.gamespy.com/MDC_File_Format.pdf 1.49 +********************************************************************** 1.50 + 1.51 +*/ 1.52 +#ifndef AI_MDCFILEHELPER_H_INC 1.53 +#define AI_MDCFILEHELPER_H_INC 1.54 + 1.55 +#include "assimp/types.h" 1.56 +#include "assimp/mesh.h" 1.57 +#include "assimp/anim.h" 1.58 + 1.59 +#include "assimp/Compiler/pushpack1.h" 1.60 + 1.61 + 1.62 +namespace Assimp { 1.63 +namespace MDC { 1.64 + 1.65 + 1.66 +// to make it easier for us, we test the magic word against both "endianesses" 1.67 +#define AI_MDC_MAGIC_NUMBER_BE AI_MAKE_MAGIC("CPDI") 1.68 +#define AI_MDC_MAGIC_NUMBER_LE AI_MAKE_MAGIC("IDPC") 1.69 + 1.70 +// common limitations 1.71 +#define AI_MDC_VERSION 2 1.72 +#define AI_MDC_MAXQPATH 64 1.73 +#define AI_MDC_MAX_BONES 128 1.74 + 1.75 +#define AI_MDC_CVERT_BIAS 127.0f 1.76 +#define AI_MDC_DELTA_SCALING 4.0f 1.77 +#define AI_MDC_BASE_SCALING (1.0f / 64.0f) 1.78 + 1.79 + 1.80 +// --------------------------------------------------------------------------- 1.81 +/** \brief Data structure for a MDC file's main header 1.82 + */ 1.83 +struct Header 1.84 +{ 1.85 + uint32_t ulIdent ; 1.86 + uint32_t ulVersion ; 1.87 + char ucName [ AI_MDC_MAXQPATH ] ; 1.88 + uint32_t ulFlags ; 1.89 + uint32_t ulNumFrames ; 1.90 + uint32_t ulNumTags ; 1.91 + uint32_t ulNumSurfaces ; 1.92 + uint32_t ulNumSkins ; 1.93 + uint32_t ulOffsetBorderFrames ; 1.94 + uint32_t ulOffsetTagNames ; 1.95 + uint32_t ulOffsetTagFrames ; 1.96 + uint32_t ulOffsetSurfaces ; 1.97 + uint32_t ulOffsetEnd ; 1.98 +} PACK_STRUCT ; 1.99 + 1.100 + 1.101 +// --------------------------------------------------------------------------- 1.102 +/** \brief Data structure for a MDC file's surface header 1.103 + */ 1.104 +struct Surface 1.105 +{ 1.106 + uint32_t ulIdent ; 1.107 + char ucName [ AI_MDC_MAXQPATH ] ; 1.108 + uint32_t ulFlags ; 1.109 + uint32_t ulNumCompFrames ; 1.110 + uint32_t ulNumBaseFrames ; 1.111 + uint32_t ulNumShaders ; 1.112 + uint32_t ulNumVertices ; 1.113 + uint32_t ulNumTriangles ; 1.114 + uint32_t ulOffsetTriangles ; 1.115 + uint32_t ulOffsetShaders ; 1.116 + uint32_t ulOffsetTexCoords ; 1.117 + uint32_t ulOffsetBaseVerts ; 1.118 + uint32_t ulOffsetCompVerts ; 1.119 + uint32_t ulOffsetFrameBaseFrames ; 1.120 + uint32_t ulOffsetFrameCompFrames ; 1.121 + uint32_t ulOffsetEnd; 1.122 + Surface() 1.123 + { 1.124 + ucName[AI_MDC_MAXQPATH-1] = '\0'; 1.125 + } 1.126 +} PACK_STRUCT; 1.127 + 1.128 +// --------------------------------------------------------------------------- 1.129 +/** \brief Data structure for a MDC frame 1.130 + */ 1.131 +struct Frame 1.132 +{ 1.133 + //! bounding box minimum coords 1.134 + aiVector3D bboxMin ; 1.135 + 1.136 + //! bounding box maximum coords 1.137 + aiVector3D bboxMax ; 1.138 + 1.139 + //! local origin of the frame 1.140 + aiVector3D localOrigin ; 1.141 + 1.142 + //! radius of the BB 1.143 + float radius ; 1.144 + 1.145 + //! Name of the frame 1.146 + char name [ 16 ] ; 1.147 +} PACK_STRUCT; 1.148 + 1.149 +// --------------------------------------------------------------------------- 1.150 +/** \brief Data structure for a MDC triangle 1.151 + */ 1.152 +struct Triangle 1.153 +{ 1.154 + uint32_t aiIndices[3]; 1.155 +} PACK_STRUCT; 1.156 + 1.157 +// --------------------------------------------------------------------------- 1.158 +/** \brief Data structure for a MDC texture coordinate 1.159 + */ 1.160 +struct TexturCoord 1.161 +{ 1.162 + float u,v; 1.163 +} PACK_STRUCT; 1.164 + 1.165 +// --------------------------------------------------------------------------- 1.166 +/** \brief Data structure for a MDC base vertex 1.167 + */ 1.168 +struct BaseVertex 1.169 +{ 1.170 + int16_t x,y,z; 1.171 + uint16_t normal; 1.172 +} PACK_STRUCT; 1.173 + 1.174 +// --------------------------------------------------------------------------- 1.175 +/** \brief Data structure for a MDC compressed vertex 1.176 + */ 1.177 +struct CompressedVertex 1.178 +{ 1.179 + uint8_t xd,yd,zd,nd; 1.180 +} PACK_STRUCT; 1.181 + 1.182 + 1.183 +// --------------------------------------------------------------------------- 1.184 +/** \brief Data structure for a MDC shader 1.185 + */ 1.186 +struct Shader 1.187 +{ 1.188 + char ucName [ AI_MDC_MAXQPATH ] ; 1.189 + uint32_t ulPath; 1.190 + 1.191 +} PACK_STRUCT; 1.192 + 1.193 +#include "assimp/Compiler/poppack1.h" 1.194 + 1.195 + 1.196 +// --------------------------------------------------------------------------- 1.197 +/** Build a floating point vertex from the compressed data in MDC files 1.198 + */ 1.199 +void BuildVertex(const Frame& frame, 1.200 + const BaseVertex& bvert, 1.201 + const CompressedVertex& cvert, 1.202 + aiVector3D& vXYZOut, 1.203 + aiVector3D& vNorOut); 1.204 +}} 1.205 + 1.206 +#endif // !! AI_MDCFILEHELPER_H_INC