Warning: That file was not part of the compilation database. It may have many parsing errors.

1/*
2Open Asset Import Library (ASSIMP)
3----------------------------------------------------------------------
4
5Copyright (c) 2006-2010, ASSIMP Development Team
6All rights reserved.
7
8Redistribution and use of this software in source and binary forms,
9with or without modification, are permitted provided that the
10following conditions are met:
11
12* Redistributions of source code must retain the above
13 copyright notice, this list of conditions and the
14 following disclaimer.
15
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.
20
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 Development Team.
25
26THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37
38----------------------------------------------------------------------
39*/
40
41/** @file Defines the helper data structures for importing MD4 files */
42#ifndef AI_MD4FILEHELPER_H_INC
43#define AI_MD4FILEHELPER_H_INC
44
45#include <string>
46#include <vector>
47#include <sstream>
48
49#include "../include/assimp/types.h"
50#include "../include/assimp/mesh.h"
51#include "../include/assimp/anim.h"
52
53#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
54# pragma pack(push,1)
55# define PACK_STRUCT
56#elif defined( __GNUC__ )
57# define PACK_STRUCT __attribute__((packed))
58#else
59# error Compiler not supported
60#endif
61
62
63namespace Assimp
64{
65// http://gongo.quakedev.com/md4.html
66namespace MD4
67{
68
69#define AI_MD4_MAGIC_NUMBER_BE 'IDP4'
70#define AI_MD4_MAGIC_NUMBER_LE '4PDI'
71
72// common limitations
73#define AI_MD4_VERSION 4
74#define AI_MD4_MAXQPATH 64
75#define AI_MD4_MAX_FRAMES 2028
76#define AI_MD4_MAX_SURFACES 32
77#define AI_MD4_MAX_BONES 256
78#define AI_MD4_MAX_VERTS 4096
79#define AI_MD4_MAX_TRIANGLES 8192
80
81// ---------------------------------------------------------------------------
82/** \brief Data structure for the MD4 main header
83 */
84// ---------------------------------------------------------------------------
85struct Header
86{
87 //! magic number
88 int32_t magic;
89
90 //! file format version
91 int32_t version;
92
93 //! original name in .pak archive
94 unsigned char name[ AI_MD4_MAXQPATH ];
95
96 //! number of frames in the file
97 int32_t NUM_FRAMES;
98
99 //! number of bones in the file
100 int32_t NUM_BONES;
101
102 //! number of surfaces in the file
103 int32_t NUM_SURFACES;
104
105 //! offset of the first frame
106 int32_t OFS_FRAMES;
107
108 //! offset of the first bone
109 int32_t OFS_BONES;
110
111 //! offset of the first surface
112 int32_t OFS_SURFACES;
113
114 //! end of file
115 int32_t OFS_EOF;
116} PACK_STRUCT;
117
118// ---------------------------------------------------------------------------
119/** \brief Stores the local transformation matrix of a bone
120 */
121// ---------------------------------------------------------------------------
122struct BoneFrame
123{
124 float matrix[3][4];
125} PACK_STRUCT;
126
127// ---------------------------------------------------------------------------
128/** \brief Stores the name / parent index / flag of a node
129 */
130// ---------------------------------------------------------------------------
131struct BoneName
132{
133 char name[32] ;
134 int parent ;
135 int flags ;
136} PACK_STRUCT;
137
138// ---------------------------------------------------------------------------
139/** \brief Data structure for a surface in a MD4 file
140 */
141// ---------------------------------------------------------------------------
142struct Surface
143{
144 int32_t ident;
145 char name[64];
146 char shader[64];
147 int32_t shaderIndex;
148 int32_t lodBias;
149 int32_t minLod;
150 int32_t ofsHeader;
151 int32_t numVerts;
152 int32_t ofsVerts;
153 int32_t numTris;
154 int32_t ofsTris;
155 int32_t numBoneRefs;
156 int32_t ofsBoneRefs;
157 int32_t ofsCollapseMap;
158 int32_t ofsEnd;
159} PACK_STRUCT;
160
161
162// ---------------------------------------------------------------------------
163/** \brief Data structure for a MD4 vertex' weight
164 */
165// ---------------------------------------------------------------------------
166struct Weight
167{
168 int32_t boneIndex;
169 float boneWeight;
170 float offset[3];
171} PACK_STRUCT;
172
173// ---------------------------------------------------------------------------
174/** \brief Data structure for a vertex in a MD4 file
175 */
176// ---------------------------------------------------------------------------
177struct Vertex
178{
179 float vertex[3];
180 float normal[3];
181 float texCoords[2];
182 int32_t numWeights;
183 Weight weights[1];
184} PACK_STRUCT;
185
186// ---------------------------------------------------------------------------
187/** \brief Data structure for a triangle in a MD4 file
188 */
189// ---------------------------------------------------------------------------
190struct Triangle
191{
192 int32_t indexes[3];
193} PACK_STRUCT;
194
195// ---------------------------------------------------------------------------
196/** \brief Data structure for a MD4 frame
197 */
198// ---------------------------------------------------------------------------
199struct Frame
200{
201 float bounds[3][2];
202 float localOrigin[3];
203 float radius;
204 BoneFrame bones[1];
205} PACK_STRUCT;
206
207
208// reset packing to the original value
209#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
210# pragma pack( pop )
211#endif
212#undef PACK_STRUCT
213
214
215};
216};
217
218#endif // !! AI_MD4FILEHELPER_H_INC
219

Warning: That file was not part of the compilation database. It may have many parsing errors.