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