vrshoot

view 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 source
1 /*
2 Open Asset Import Library (assimp)
3 ----------------------------------------------------------------------
5 Copyright (c) 2006-2012, assimp team
6 All rights reserved.
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:
12 * Redistributions of source code must retain the above
13 copyright notice, this list of conditions and the
14 following disclaimer.
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.
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.
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.
38 ----------------------------------------------------------------------
39 */
41 /** @file Defines the helper data structures for importing MDC files
43 **********************************************************************
44 File format specification:
45 http://themdcfile.planetwolfenstein.gamespy.com/MDC_File_Format.pdf
46 **********************************************************************
48 */
49 #ifndef AI_MDCFILEHELPER_H_INC
50 #define AI_MDCFILEHELPER_H_INC
52 #include "assimp/types.h"
53 #include "assimp/mesh.h"
54 #include "assimp/anim.h"
56 #include "assimp/Compiler/pushpack1.h"
59 namespace Assimp {
60 namespace MDC {
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")
67 // common limitations
68 #define AI_MDC_VERSION 2
69 #define AI_MDC_MAXQPATH 64
70 #define AI_MDC_MAX_BONES 128
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)
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 ;
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;
119 Surface()
120 {
121 ucName[AI_MDC_MAXQPATH-1] = '\0';
122 }
123 } PACK_STRUCT;
125 // ---------------------------------------------------------------------------
126 /** \brief Data structure for a MDC frame
127 */
128 struct Frame
129 {
130 //! bounding box minimum coords
131 aiVector3D bboxMin ;
133 //! bounding box maximum coords
134 aiVector3D bboxMax ;
136 //! local origin of the frame
137 aiVector3D localOrigin ;
139 //! radius of the BB
140 float radius ;
142 //! Name of the frame
143 char name [ 16 ] ;
144 } PACK_STRUCT;
146 // ---------------------------------------------------------------------------
147 /** \brief Data structure for a MDC triangle
148 */
149 struct Triangle
150 {
151 uint32_t aiIndices[3];
152 } PACK_STRUCT;
154 // ---------------------------------------------------------------------------
155 /** \brief Data structure for a MDC texture coordinate
156 */
157 struct TexturCoord
158 {
159 float u,v;
160 } PACK_STRUCT;
162 // ---------------------------------------------------------------------------
163 /** \brief Data structure for a MDC base vertex
164 */
165 struct BaseVertex
166 {
167 int16_t x,y,z;
168 uint16_t normal;
169 } PACK_STRUCT;
171 // ---------------------------------------------------------------------------
172 /** \brief Data structure for a MDC compressed vertex
173 */
174 struct CompressedVertex
175 {
176 uint8_t xd,yd,zd,nd;
177 } PACK_STRUCT;
180 // ---------------------------------------------------------------------------
181 /** \brief Data structure for a MDC shader
182 */
183 struct Shader
184 {
185 char ucName [ AI_MDC_MAXQPATH ] ;
186 uint32_t ulPath;
188 } PACK_STRUCT;
190 #include "assimp/Compiler/poppack1.h"
193 // ---------------------------------------------------------------------------
194 /** Build a floating point vertex from the compressed data in MDC files
195 */
196 void BuildVertex(const Frame& frame,
197 const BaseVertex& bvert,
198 const CompressedVertex& cvert,
199 aiVector3D& vXYZOut,
200 aiVector3D& vNorOut);
201 }}
203 #endif // !! AI_MDCFILEHELPER_H_INC