/src/assimp/code/AssetLib/MDC/MDCFileData.h
Line | Count | Source |
1 | | /* |
2 | | Open Asset Import Library (assimp) |
3 | | ---------------------------------------------------------------------- |
4 | | |
5 | | Copyright (c) 2006-2025, 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 | | // to make it easier for us, we test the magic word against both "endiannesses" |
64 | 0 | #define AI_MDC_MAGIC_NUMBER_BE AI_MAKE_MAGIC("CPDI") |
65 | 0 | #define AI_MDC_MAGIC_NUMBER_LE AI_MAKE_MAGIC("IDPC") |
66 | | |
67 | | // common limitations |
68 | 0 | #define AI_MDC_VERSION 2 |
69 | 0 | #define AI_MDC_MAXQPATH 64 |
70 | | #define AI_MDC_MAX_BONES 128 |
71 | | |
72 | 0 | #define AI_MDC_CVERT_BIAS 127.0f |
73 | 0 | #define AI_MDC_DELTA_SCALING 4.0f |
74 | 0 | #define AI_MDC_BASE_SCALING (1.0f / 64.0f) |
75 | | |
76 | | |
77 | | // --------------------------------------------------------------------------- |
78 | | /** \brief Data structure for a MDC file's main header |
79 | | */ |
80 | | struct Header { |
81 | | uint32_t ulIdent ; |
82 | | uint32_t ulVersion ; |
83 | | char ucName [ AI_MDC_MAXQPATH ] ; |
84 | | uint32_t ulFlags ; |
85 | | uint32_t ulNumFrames ; |
86 | | uint32_t ulNumTags ; |
87 | | uint32_t ulNumSurfaces ; |
88 | | uint32_t ulNumSkins ; |
89 | | uint32_t ulOffsetBorderFrames ; |
90 | | uint32_t ulOffsetTagNames ; |
91 | | uint32_t ulOffsetTagFrames ; |
92 | | uint32_t ulOffsetSurfaces ; |
93 | | uint32_t ulOffsetEnd ; |
94 | | } PACK_STRUCT ; |
95 | | |
96 | | |
97 | | // --------------------------------------------------------------------------- |
98 | | /** \brief Data structure for a MDC file's surface header |
99 | | */ |
100 | | struct Surface { |
101 | | uint32_t ulIdent ; |
102 | | char ucName [ AI_MDC_MAXQPATH ] ; |
103 | | uint32_t ulFlags ; |
104 | | uint32_t ulNumCompFrames ; |
105 | | uint32_t ulNumBaseFrames ; |
106 | | uint32_t ulNumShaders ; |
107 | | uint32_t ulNumVertices ; |
108 | | uint32_t ulNumTriangles ; |
109 | | uint32_t ulOffsetTriangles ; |
110 | | uint32_t ulOffsetShaders ; |
111 | | uint32_t ulOffsetTexCoords ; |
112 | | uint32_t ulOffsetBaseVerts ; |
113 | | uint32_t ulOffsetCompVerts ; |
114 | | uint32_t ulOffsetFrameBaseFrames ; |
115 | | uint32_t ulOffsetFrameCompFrames ; |
116 | | uint32_t ulOffsetEnd; |
117 | | Surface() AI_NO_EXCEPT |
118 | | : ulIdent() |
119 | | , ulFlags() |
120 | | , ulNumCompFrames() |
121 | | , ulNumBaseFrames() |
122 | | , ulNumShaders() |
123 | | , ulNumVertices() |
124 | | , ulNumTriangles() |
125 | | , ulOffsetTriangles() |
126 | | , ulOffsetShaders() |
127 | | , ulOffsetTexCoords() |
128 | | , ulOffsetBaseVerts() |
129 | | , ulOffsetCompVerts() |
130 | | , ulOffsetFrameBaseFrames() |
131 | | , ulOffsetFrameCompFrames() |
132 | 0 | , ulOffsetEnd() { |
133 | 0 | ucName[AI_MDC_MAXQPATH-1] = '\0'; |
134 | 0 | } |
135 | | } PACK_STRUCT; |
136 | | |
137 | | // --------------------------------------------------------------------------- |
138 | | /** \brief Data structure for a MDC frame |
139 | | */ |
140 | | struct Frame { |
141 | | //! bounding box minimum coords |
142 | | aiVector3D bboxMin ; |
143 | | |
144 | | //! bounding box maximum coords |
145 | | aiVector3D bboxMax ; |
146 | | |
147 | | //! local origin of the frame |
148 | | aiVector3D localOrigin ; |
149 | | |
150 | | //! radius of the BB |
151 | | float radius ; |
152 | | |
153 | | //! Name of the frame |
154 | | char name [ 16 ] ; |
155 | | } /*PACK_STRUCT*/; |
156 | | |
157 | | // --------------------------------------------------------------------------- |
158 | | /** \brief Data structure for a MDC triangle |
159 | | */ |
160 | | struct Triangle { |
161 | | uint32_t aiIndices[3]; |
162 | | } PACK_STRUCT; |
163 | | |
164 | | // --------------------------------------------------------------------------- |
165 | | /** \brief Data structure for a MDC texture coordinate |
166 | | */ |
167 | | struct TexturCoord { |
168 | | float u,v; |
169 | | } PACK_STRUCT; |
170 | | |
171 | | // --------------------------------------------------------------------------- |
172 | | /** \brief Data structure for a MDC base vertex |
173 | | */ |
174 | | struct BaseVertex { |
175 | | int16_t x,y,z; |
176 | | uint16_t normal; |
177 | | } PACK_STRUCT; |
178 | | |
179 | | // --------------------------------------------------------------------------- |
180 | | /** \brief Data structure for a MDC compressed vertex |
181 | | */ |
182 | | struct CompressedVertex { |
183 | | uint8_t xd,yd,zd,nd; |
184 | | } PACK_STRUCT; |
185 | | |
186 | | // --------------------------------------------------------------------------- |
187 | | /** \brief Data structure for a MDC shader |
188 | | */ |
189 | | struct Shader { |
190 | | char ucName [ AI_MDC_MAXQPATH ] ; |
191 | | uint32_t ulPath; |
192 | | } PACK_STRUCT; |
193 | | |
194 | | #include <assimp/Compiler/poppack1.h> |
195 | | |
196 | | // --------------------------------------------------------------------------- |
197 | | /** Build a floating point vertex from the compressed data in MDC files |
198 | | */ |
199 | | void BuildVertex(const Frame& frame, |
200 | | const BaseVertex& bvert, |
201 | | const CompressedVertex& cvert, |
202 | | aiVector3D& vXYZOut, |
203 | | aiVector3D& vNorOut); |
204 | | } |
205 | | } |
206 | | |
207 | | #endif // !! AI_MDCFILEHELPER_H_INC |