vrshoot

view libs/assimp/MD4FileData.h @ 2:334d17aed7de

visual studio project files
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 02 Feb 2014 18:36:38 +0200
parents
children
line source
1 /*
2 Open Asset Import Library (ASSIMP)
3 ----------------------------------------------------------------------
5 Copyright (c) 2006-2010, ASSIMP Development 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 Development 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 MD4 files */
42 #ifndef AI_MD4FILEHELPER_H_INC
43 #define AI_MD4FILEHELPER_H_INC
45 #include <string>
46 #include <vector>
47 #include <sstream>
49 #include "../include/aiTypes.h"
50 #include "../include/aiMesh.h"
51 #include "../include/aiAnim.h"
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
63 namespace Assimp
64 {
65 // http://gongo.quakedev.com/md4.html
66 namespace MD4
67 {
69 #define AI_MD4_MAGIC_NUMBER_BE 'IDP4'
70 #define AI_MD4_MAGIC_NUMBER_LE '4PDI'
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
81 // ---------------------------------------------------------------------------
82 /** \brief Data structure for the MD4 main header
83 */
84 // ---------------------------------------------------------------------------
85 struct Header
86 {
87 //! magic number
88 int32_t magic;
90 //! file format version
91 int32_t version;
93 //! original name in .pak archive
94 unsigned char name[ AI_MD4_MAXQPATH ];
96 //! number of frames in the file
97 int32_t NUM_FRAMES;
99 //! number of bones in the file
100 int32_t NUM_BONES;
102 //! number of surfaces in the file
103 int32_t NUM_SURFACES;
105 //! offset of the first frame
106 int32_t OFS_FRAMES;
108 //! offset of the first bone
109 int32_t OFS_BONES;
111 //! offset of the first surface
112 int32_t OFS_SURFACES;
114 //! end of file
115 int32_t OFS_EOF;
116 } PACK_STRUCT;
118 // ---------------------------------------------------------------------------
119 /** \brief Stores the local transformation matrix of a bone
120 */
121 // ---------------------------------------------------------------------------
122 struct BoneFrame
123 {
124 float matrix[3][4];
125 } PACK_STRUCT;
127 // ---------------------------------------------------------------------------
128 /** \brief Stores the name / parent index / flag of a node
129 */
130 // ---------------------------------------------------------------------------
131 struct BoneName
132 {
133 char name[32] ;
134 int parent ;
135 int flags ;
136 } PACK_STRUCT;
138 // ---------------------------------------------------------------------------
139 /** \brief Data structure for a surface in a MD4 file
140 */
141 // ---------------------------------------------------------------------------
142 struct 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;
162 // ---------------------------------------------------------------------------
163 /** \brief Data structure for a MD4 vertex' weight
164 */
165 // ---------------------------------------------------------------------------
166 struct Weight
167 {
168 int32_t boneIndex;
169 float boneWeight;
170 float offset[3];
171 } PACK_STRUCT;
173 // ---------------------------------------------------------------------------
174 /** \brief Data structure for a vertex in a MD4 file
175 */
176 // ---------------------------------------------------------------------------
177 struct 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;
186 // ---------------------------------------------------------------------------
187 /** \brief Data structure for a triangle in a MD4 file
188 */
189 // ---------------------------------------------------------------------------
190 struct Triangle
191 {
192 int32_t indexes[3];
193 } PACK_STRUCT;
195 // ---------------------------------------------------------------------------
196 /** \brief Data structure for a MD4 frame
197 */
198 // ---------------------------------------------------------------------------
199 struct Frame
200 {
201 float bounds[3][2];
202 float localOrigin[3];
203 float radius;
204 BoneFrame bones[1];
205 } PACK_STRUCT;
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
215 };
216 };
218 #endif // !! AI_MD4FILEHELPER_H_INC