rev |
line source |
nuclear@0
|
1 /*
|
nuclear@0
|
2 ---------------------------------------------------------------------------
|
nuclear@0
|
3 Open Asset Import Library (assimp)
|
nuclear@0
|
4 ---------------------------------------------------------------------------
|
nuclear@0
|
5
|
nuclear@0
|
6 Copyright (c) 2006-2018, assimp team
|
nuclear@0
|
7
|
nuclear@0
|
8
|
nuclear@0
|
9
|
nuclear@0
|
10 All rights reserved.
|
nuclear@0
|
11
|
nuclear@0
|
12 Redistribution and use of this software in source and binary forms,
|
nuclear@0
|
13 with or without modification, are permitted provided that the following
|
nuclear@0
|
14 conditions are met:
|
nuclear@0
|
15
|
nuclear@0
|
16 * Redistributions of source code must retain the above
|
nuclear@0
|
17 copyright notice, this list of conditions and the
|
nuclear@0
|
18 following disclaimer.
|
nuclear@0
|
19
|
nuclear@0
|
20 * Redistributions in binary form must reproduce the above
|
nuclear@0
|
21 copyright notice, this list of conditions and the
|
nuclear@0
|
22 following disclaimer in the documentation and/or other
|
nuclear@0
|
23 materials provided with the distribution.
|
nuclear@0
|
24
|
nuclear@0
|
25 * Neither the name of the assimp team, nor the names of its
|
nuclear@0
|
26 contributors may be used to endorse or promote products
|
nuclear@0
|
27 derived from this software without specific prior
|
nuclear@0
|
28 written permission of the assimp team.
|
nuclear@0
|
29
|
nuclear@0
|
30 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
nuclear@0
|
31 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
nuclear@0
|
32 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
nuclear@0
|
33 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
nuclear@0
|
34 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
nuclear@0
|
35 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
nuclear@0
|
36 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
nuclear@0
|
37 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
nuclear@0
|
38 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
nuclear@0
|
39 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
nuclear@0
|
40 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
nuclear@0
|
41 ---------------------------------------------------------------------------
|
nuclear@0
|
42 */
|
nuclear@0
|
43
|
nuclear@0
|
44 /**
|
nuclear@0
|
45 * @file anim.h
|
nuclear@0
|
46 * @brief Defines the data structures in which the imported animations
|
nuclear@0
|
47 * are returned.
|
nuclear@0
|
48 */
|
nuclear@0
|
49 #pragma once
|
nuclear@0
|
50 #ifndef AI_ANIM_H_INC
|
nuclear@0
|
51 #define AI_ANIM_H_INC
|
nuclear@0
|
52
|
nuclear@0
|
53 #include <miniassimp/types.h>
|
nuclear@0
|
54 #include <miniassimp/quaternion.h>
|
nuclear@0
|
55
|
nuclear@0
|
56 #ifdef __cplusplus
|
nuclear@0
|
57 extern "C" {
|
nuclear@0
|
58 #endif
|
nuclear@0
|
59
|
nuclear@0
|
60 // ---------------------------------------------------------------------------
|
nuclear@0
|
61 /** A time-value pair specifying a certain 3D vector for the given time. */
|
nuclear@0
|
62 struct aiVectorKey
|
nuclear@0
|
63 {
|
nuclear@0
|
64 /** The time of this key */
|
nuclear@0
|
65 double mTime;
|
nuclear@0
|
66
|
nuclear@0
|
67 /** The value of this key */
|
nuclear@0
|
68 C_STRUCT aiVector3D mValue;
|
nuclear@0
|
69
|
nuclear@0
|
70 #ifdef __cplusplus
|
nuclear@0
|
71
|
nuclear@0
|
72 /// @brief The default constructor.
|
nuclear@0
|
73 aiVectorKey() AI_NO_EXCEPT
|
nuclear@0
|
74 : mTime( 0.0 )
|
nuclear@0
|
75 , mValue() {
|
nuclear@0
|
76 // empty
|
nuclear@0
|
77 }
|
nuclear@0
|
78
|
nuclear@0
|
79 /// @brief Construction from a given time and key value.
|
nuclear@0
|
80
|
nuclear@0
|
81 aiVectorKey(double time, const aiVector3D& value)
|
nuclear@0
|
82 : mTime( time )
|
nuclear@0
|
83 , mValue( value ) {
|
nuclear@0
|
84 // empty
|
nuclear@0
|
85 }
|
nuclear@0
|
86
|
nuclear@0
|
87 typedef aiVector3D elem_type;
|
nuclear@0
|
88
|
nuclear@0
|
89 // Comparison operators. For use with std::find();
|
nuclear@0
|
90 bool operator == (const aiVectorKey& rhs) const {
|
nuclear@0
|
91 return rhs.mValue == this->mValue;
|
nuclear@0
|
92 }
|
nuclear@0
|
93 bool operator != (const aiVectorKey& rhs ) const {
|
nuclear@0
|
94 return rhs.mValue != this->mValue;
|
nuclear@0
|
95 }
|
nuclear@0
|
96
|
nuclear@0
|
97 // Relational operators. For use with std::sort();
|
nuclear@0
|
98 bool operator < (const aiVectorKey& rhs ) const {
|
nuclear@0
|
99 return mTime < rhs.mTime;
|
nuclear@0
|
100 }
|
nuclear@0
|
101 bool operator > (const aiVectorKey& rhs ) const {
|
nuclear@0
|
102 return mTime > rhs.mTime;
|
nuclear@0
|
103 }
|
nuclear@0
|
104 #endif // __cplusplus
|
nuclear@0
|
105 };
|
nuclear@0
|
106
|
nuclear@0
|
107 // ---------------------------------------------------------------------------
|
nuclear@0
|
108 /** A time-value pair specifying a rotation for the given time.
|
nuclear@0
|
109 * Rotations are expressed with quaternions. */
|
nuclear@0
|
110 struct aiQuatKey
|
nuclear@0
|
111 {
|
nuclear@0
|
112 /** The time of this key */
|
nuclear@0
|
113 double mTime;
|
nuclear@0
|
114
|
nuclear@0
|
115 /** The value of this key */
|
nuclear@0
|
116 C_STRUCT aiQuaternion mValue;
|
nuclear@0
|
117
|
nuclear@0
|
118 #ifdef __cplusplus
|
nuclear@0
|
119 aiQuatKey() AI_NO_EXCEPT
|
nuclear@0
|
120 : mTime( 0.0 )
|
nuclear@0
|
121 , mValue() {
|
nuclear@0
|
122 // empty
|
nuclear@0
|
123 }
|
nuclear@0
|
124
|
nuclear@0
|
125 /** Construction from a given time and key value */
|
nuclear@0
|
126 aiQuatKey(double time, const aiQuaternion& value)
|
nuclear@0
|
127 : mTime (time)
|
nuclear@0
|
128 , mValue (value)
|
nuclear@0
|
129 {}
|
nuclear@0
|
130
|
nuclear@0
|
131 typedef aiQuaternion elem_type;
|
nuclear@0
|
132
|
nuclear@0
|
133 // Comparison operators. For use with std::find();
|
nuclear@0
|
134 bool operator == (const aiQuatKey& rhs ) const {
|
nuclear@0
|
135 return rhs.mValue == this->mValue;
|
nuclear@0
|
136 }
|
nuclear@0
|
137 bool operator != (const aiQuatKey& rhs ) const {
|
nuclear@0
|
138 return rhs.mValue != this->mValue;
|
nuclear@0
|
139 }
|
nuclear@0
|
140
|
nuclear@0
|
141 // Relational operators. For use with std::sort();
|
nuclear@0
|
142 bool operator < (const aiQuatKey& rhs ) const {
|
nuclear@0
|
143 return mTime < rhs.mTime;
|
nuclear@0
|
144 }
|
nuclear@0
|
145 bool operator > (const aiQuatKey& rhs ) const {
|
nuclear@0
|
146 return mTime > rhs.mTime;
|
nuclear@0
|
147 }
|
nuclear@0
|
148 #endif
|
nuclear@0
|
149 };
|
nuclear@0
|
150
|
nuclear@0
|
151 // ---------------------------------------------------------------------------
|
nuclear@0
|
152 /** Binds a anim-mesh to a specific point in time. */
|
nuclear@0
|
153 struct aiMeshKey
|
nuclear@0
|
154 {
|
nuclear@0
|
155 /** The time of this key */
|
nuclear@0
|
156 double mTime;
|
nuclear@0
|
157
|
nuclear@0
|
158 /** Index into the aiMesh::mAnimMeshes array of the
|
nuclear@0
|
159 * mesh corresponding to the #aiMeshAnim hosting this
|
nuclear@0
|
160 * key frame. The referenced anim mesh is evaluated
|
nuclear@0
|
161 * according to the rules defined in the docs for #aiAnimMesh.*/
|
nuclear@0
|
162 unsigned int mValue;
|
nuclear@0
|
163
|
nuclear@0
|
164 #ifdef __cplusplus
|
nuclear@0
|
165
|
nuclear@0
|
166 aiMeshKey() AI_NO_EXCEPT
|
nuclear@0
|
167 : mTime(0.0)
|
nuclear@0
|
168 , mValue(0)
|
nuclear@0
|
169 {
|
nuclear@0
|
170 }
|
nuclear@0
|
171
|
nuclear@0
|
172 /** Construction from a given time and key value */
|
nuclear@0
|
173 aiMeshKey(double time, const unsigned int value)
|
nuclear@0
|
174 : mTime (time)
|
nuclear@0
|
175 , mValue (value)
|
nuclear@0
|
176 {}
|
nuclear@0
|
177
|
nuclear@0
|
178 typedef unsigned int elem_type;
|
nuclear@0
|
179
|
nuclear@0
|
180 // Comparison operators. For use with std::find();
|
nuclear@0
|
181 bool operator == (const aiMeshKey& o) const {
|
nuclear@0
|
182 return o.mValue == this->mValue;
|
nuclear@0
|
183 }
|
nuclear@0
|
184 bool operator != (const aiMeshKey& o) const {
|
nuclear@0
|
185 return o.mValue != this->mValue;
|
nuclear@0
|
186 }
|
nuclear@0
|
187
|
nuclear@0
|
188 // Relational operators. For use with std::sort();
|
nuclear@0
|
189 bool operator < (const aiMeshKey& o) const {
|
nuclear@0
|
190 return mTime < o.mTime;
|
nuclear@0
|
191 }
|
nuclear@0
|
192 bool operator > (const aiMeshKey& o) const {
|
nuclear@0
|
193 return mTime > o.mTime;
|
nuclear@0
|
194 }
|
nuclear@0
|
195
|
nuclear@0
|
196 #endif
|
nuclear@0
|
197 };
|
nuclear@0
|
198
|
nuclear@0
|
199 // ---------------------------------------------------------------------------
|
nuclear@0
|
200 /** Binds a morph anim mesh to a specific point in time. */
|
nuclear@0
|
201 struct aiMeshMorphKey
|
nuclear@0
|
202 {
|
nuclear@0
|
203 /** The time of this key */
|
nuclear@0
|
204 double mTime;
|
nuclear@0
|
205
|
nuclear@0
|
206 /** The values and weights at the time of this key */
|
nuclear@0
|
207 unsigned int *mValues;
|
nuclear@0
|
208 double *mWeights;
|
nuclear@0
|
209
|
nuclear@0
|
210 /** The number of values and weights */
|
nuclear@0
|
211 unsigned int mNumValuesAndWeights;
|
nuclear@0
|
212 #ifdef __cplusplus
|
nuclear@0
|
213 aiMeshMorphKey() AI_NO_EXCEPT
|
nuclear@0
|
214 : mTime(0.0)
|
nuclear@0
|
215 , mValues(0)
|
nuclear@0
|
216 , mWeights(0)
|
nuclear@0
|
217 , mNumValuesAndWeights(0)
|
nuclear@0
|
218 {
|
nuclear@0
|
219
|
nuclear@0
|
220 }
|
nuclear@0
|
221
|
nuclear@0
|
222 ~aiMeshMorphKey()
|
nuclear@0
|
223 {
|
nuclear@0
|
224 if (mNumValuesAndWeights && mValues && mWeights) {
|
nuclear@0
|
225 delete [] mValues;
|
nuclear@0
|
226 delete [] mWeights;
|
nuclear@0
|
227 }
|
nuclear@0
|
228 }
|
nuclear@0
|
229 #endif
|
nuclear@0
|
230 };
|
nuclear@0
|
231
|
nuclear@0
|
232 // ---------------------------------------------------------------------------
|
nuclear@0
|
233 /** Defines how an animation channel behaves outside the defined time
|
nuclear@0
|
234 * range. This corresponds to aiNodeAnim::mPreState and
|
nuclear@0
|
235 * aiNodeAnim::mPostState.*/
|
nuclear@0
|
236 enum aiAnimBehaviour
|
nuclear@0
|
237 {
|
nuclear@0
|
238 /** The value from the default node transformation is taken*/
|
nuclear@0
|
239 aiAnimBehaviour_DEFAULT = 0x0,
|
nuclear@0
|
240
|
nuclear@0
|
241 /** The nearest key value is used without interpolation */
|
nuclear@0
|
242 aiAnimBehaviour_CONSTANT = 0x1,
|
nuclear@0
|
243
|
nuclear@0
|
244 /** The value of the nearest two keys is linearly
|
nuclear@0
|
245 * extrapolated for the current time value.*/
|
nuclear@0
|
246 aiAnimBehaviour_LINEAR = 0x2,
|
nuclear@0
|
247
|
nuclear@0
|
248 /** The animation is repeated.
|
nuclear@0
|
249 *
|
nuclear@0
|
250 * If the animation key go from n to m and the current
|
nuclear@0
|
251 * time is t, use the value at (t-n) % (|m-n|).*/
|
nuclear@0
|
252 aiAnimBehaviour_REPEAT = 0x3,
|
nuclear@0
|
253
|
nuclear@0
|
254 /** This value is not used, it is just here to force the
|
nuclear@0
|
255 * the compiler to map this enum to a 32 Bit integer */
|
nuclear@0
|
256 #ifndef SWIG
|
nuclear@0
|
257 _aiAnimBehaviour_Force32Bit = INT_MAX
|
nuclear@0
|
258 #endif
|
nuclear@0
|
259 };
|
nuclear@0
|
260
|
nuclear@0
|
261 // ---------------------------------------------------------------------------
|
nuclear@0
|
262 /** Describes the animation of a single node. The name specifies the
|
nuclear@0
|
263 * bone/node which is affected by this animation channel. The keyframes
|
nuclear@0
|
264 * are given in three separate series of values, one each for position,
|
nuclear@0
|
265 * rotation and scaling. The transformation matrix computed from these
|
nuclear@0
|
266 * values replaces the node's original transformation matrix at a
|
nuclear@0
|
267 * specific time.
|
nuclear@0
|
268 * This means all keys are absolute and not relative to the bone default pose.
|
nuclear@0
|
269 * The order in which the transformations are applied is
|
nuclear@0
|
270 * - as usual - scaling, rotation, translation.
|
nuclear@0
|
271 *
|
nuclear@0
|
272 * @note All keys are returned in their correct, chronological order.
|
nuclear@0
|
273 * Duplicate keys don't pass the validation step. Most likely there
|
nuclear@0
|
274 * will be no negative time values, but they are not forbidden also ( so
|
nuclear@0
|
275 * implementations need to cope with them! ) */
|
nuclear@0
|
276 struct aiNodeAnim {
|
nuclear@0
|
277 /** The name of the node affected by this animation. The node
|
nuclear@0
|
278 * must exist and it must be unique.*/
|
nuclear@0
|
279 C_STRUCT aiString mNodeName;
|
nuclear@0
|
280
|
nuclear@0
|
281 /** The number of position keys */
|
nuclear@0
|
282 unsigned int mNumPositionKeys;
|
nuclear@0
|
283
|
nuclear@0
|
284 /** The position keys of this animation channel. Positions are
|
nuclear@0
|
285 * specified as 3D vector. The array is mNumPositionKeys in size.
|
nuclear@0
|
286 *
|
nuclear@0
|
287 * If there are position keys, there will also be at least one
|
nuclear@0
|
288 * scaling and one rotation key.*/
|
nuclear@0
|
289 C_STRUCT aiVectorKey* mPositionKeys;
|
nuclear@0
|
290
|
nuclear@0
|
291 /** The number of rotation keys */
|
nuclear@0
|
292 unsigned int mNumRotationKeys;
|
nuclear@0
|
293
|
nuclear@0
|
294 /** The rotation keys of this animation channel. Rotations are
|
nuclear@0
|
295 * given as quaternions, which are 4D vectors. The array is
|
nuclear@0
|
296 * mNumRotationKeys in size.
|
nuclear@0
|
297 *
|
nuclear@0
|
298 * If there are rotation keys, there will also be at least one
|
nuclear@0
|
299 * scaling and one position key. */
|
nuclear@0
|
300 C_STRUCT aiQuatKey* mRotationKeys;
|
nuclear@0
|
301
|
nuclear@0
|
302 /** The number of scaling keys */
|
nuclear@0
|
303 unsigned int mNumScalingKeys;
|
nuclear@0
|
304
|
nuclear@0
|
305 /** The scaling keys of this animation channel. Scalings are
|
nuclear@0
|
306 * specified as 3D vector. The array is mNumScalingKeys in size.
|
nuclear@0
|
307 *
|
nuclear@0
|
308 * If there are scaling keys, there will also be at least one
|
nuclear@0
|
309 * position and one rotation key.*/
|
nuclear@0
|
310 C_STRUCT aiVectorKey* mScalingKeys;
|
nuclear@0
|
311
|
nuclear@0
|
312 /** Defines how the animation behaves before the first
|
nuclear@0
|
313 * key is encountered.
|
nuclear@0
|
314 *
|
nuclear@0
|
315 * The default value is aiAnimBehaviour_DEFAULT (the original
|
nuclear@0
|
316 * transformation matrix of the affected node is used).*/
|
nuclear@0
|
317 C_ENUM aiAnimBehaviour mPreState;
|
nuclear@0
|
318
|
nuclear@0
|
319 /** Defines how the animation behaves after the last
|
nuclear@0
|
320 * key was processed.
|
nuclear@0
|
321 *
|
nuclear@0
|
322 * The default value is aiAnimBehaviour_DEFAULT (the original
|
nuclear@0
|
323 * transformation matrix of the affected node is taken).*/
|
nuclear@0
|
324 C_ENUM aiAnimBehaviour mPostState;
|
nuclear@0
|
325
|
nuclear@0
|
326 #ifdef __cplusplus
|
nuclear@0
|
327 aiNodeAnim() AI_NO_EXCEPT
|
nuclear@0
|
328 : mNumPositionKeys( 0 )
|
nuclear@0
|
329 , mPositionKeys( 0 )
|
nuclear@0
|
330 , mNumRotationKeys( 0 )
|
nuclear@0
|
331 , mRotationKeys( 0 )
|
nuclear@0
|
332 , mNumScalingKeys( 0 )
|
nuclear@0
|
333 , mScalingKeys( 0 )
|
nuclear@0
|
334 , mPreState( aiAnimBehaviour_DEFAULT )
|
nuclear@0
|
335 , mPostState( aiAnimBehaviour_DEFAULT ) {
|
nuclear@0
|
336 // empty
|
nuclear@0
|
337 }
|
nuclear@0
|
338
|
nuclear@0
|
339 ~aiNodeAnim() {
|
nuclear@0
|
340 delete [] mPositionKeys;
|
nuclear@0
|
341 delete [] mRotationKeys;
|
nuclear@0
|
342 delete [] mScalingKeys;
|
nuclear@0
|
343 }
|
nuclear@0
|
344 #endif // __cplusplus
|
nuclear@0
|
345 };
|
nuclear@0
|
346
|
nuclear@0
|
347 // ---------------------------------------------------------------------------
|
nuclear@0
|
348 /** Describes vertex-based animations for a single mesh or a group of
|
nuclear@0
|
349 * meshes. Meshes carry the animation data for each frame in their
|
nuclear@0
|
350 * aiMesh::mAnimMeshes array. The purpose of aiMeshAnim is to
|
nuclear@0
|
351 * define keyframes linking each mesh attachment to a particular
|
nuclear@0
|
352 * point in time. */
|
nuclear@0
|
353 struct aiMeshAnim
|
nuclear@0
|
354 {
|
nuclear@0
|
355 /** Name of the mesh to be animated. An empty string is not allowed,
|
nuclear@0
|
356 * animated meshes need to be named (not necessarily uniquely,
|
nuclear@0
|
357 * the name can basically serve as wild-card to select a group
|
nuclear@0
|
358 * of meshes with similar animation setup)*/
|
nuclear@0
|
359 C_STRUCT aiString mName;
|
nuclear@0
|
360
|
nuclear@0
|
361 /** Size of the #mKeys array. Must be 1, at least. */
|
nuclear@0
|
362 unsigned int mNumKeys;
|
nuclear@0
|
363
|
nuclear@0
|
364 /** Key frames of the animation. May not be NULL. */
|
nuclear@0
|
365 C_STRUCT aiMeshKey* mKeys;
|
nuclear@0
|
366
|
nuclear@0
|
367 #ifdef __cplusplus
|
nuclear@0
|
368
|
nuclear@0
|
369 aiMeshAnim() AI_NO_EXCEPT
|
nuclear@0
|
370 : mNumKeys()
|
nuclear@0
|
371 , mKeys()
|
nuclear@0
|
372 {}
|
nuclear@0
|
373
|
nuclear@0
|
374 ~aiMeshAnim()
|
nuclear@0
|
375 {
|
nuclear@0
|
376 delete[] mKeys;
|
nuclear@0
|
377 }
|
nuclear@0
|
378
|
nuclear@0
|
379 #endif
|
nuclear@0
|
380 };
|
nuclear@0
|
381
|
nuclear@0
|
382 // ---------------------------------------------------------------------------
|
nuclear@0
|
383 /** Describes a morphing animation of a given mesh. */
|
nuclear@0
|
384 struct aiMeshMorphAnim
|
nuclear@0
|
385 {
|
nuclear@0
|
386 /** Name of the mesh to be animated. An empty string is not allowed,
|
nuclear@0
|
387 * animated meshes need to be named (not necessarily uniquely,
|
nuclear@0
|
388 * the name can basically serve as wildcard to select a group
|
nuclear@0
|
389 * of meshes with similar animation setup)*/
|
nuclear@0
|
390 C_STRUCT aiString mName;
|
nuclear@0
|
391
|
nuclear@0
|
392 /** Size of the #mKeys array. Must be 1, at least. */
|
nuclear@0
|
393 unsigned int mNumKeys;
|
nuclear@0
|
394
|
nuclear@0
|
395 /** Key frames of the animation. May not be NULL. */
|
nuclear@0
|
396 C_STRUCT aiMeshMorphKey* mKeys;
|
nuclear@0
|
397
|
nuclear@0
|
398 #ifdef __cplusplus
|
nuclear@0
|
399
|
nuclear@0
|
400 aiMeshMorphAnim() AI_NO_EXCEPT
|
nuclear@0
|
401 : mNumKeys()
|
nuclear@0
|
402 , mKeys()
|
nuclear@0
|
403 {}
|
nuclear@0
|
404
|
nuclear@0
|
405 ~aiMeshMorphAnim()
|
nuclear@0
|
406 {
|
nuclear@0
|
407 delete[] mKeys;
|
nuclear@0
|
408 }
|
nuclear@0
|
409
|
nuclear@0
|
410 #endif
|
nuclear@0
|
411 };
|
nuclear@0
|
412
|
nuclear@0
|
413 // ---------------------------------------------------------------------------
|
nuclear@0
|
414 /** An animation consists of key-frame data for a number of nodes. For
|
nuclear@0
|
415 * each node affected by the animation a separate series of data is given.*/
|
nuclear@0
|
416 struct aiAnimation {
|
nuclear@0
|
417 /** The name of the animation. If the modeling package this data was
|
nuclear@0
|
418 * exported from does support only a single animation channel, this
|
nuclear@0
|
419 * name is usually empty (length is zero). */
|
nuclear@0
|
420 C_STRUCT aiString mName;
|
nuclear@0
|
421
|
nuclear@0
|
422 /** Duration of the animation in ticks. */
|
nuclear@0
|
423 double mDuration;
|
nuclear@0
|
424
|
nuclear@0
|
425 /** Ticks per second. 0 if not specified in the imported file */
|
nuclear@0
|
426 double mTicksPerSecond;
|
nuclear@0
|
427
|
nuclear@0
|
428 /** The number of bone animation channels. Each channel affects
|
nuclear@0
|
429 * a single node. */
|
nuclear@0
|
430 unsigned int mNumChannels;
|
nuclear@0
|
431
|
nuclear@0
|
432 /** The node animation channels. Each channel affects a single node.
|
nuclear@0
|
433 * The array is mNumChannels in size. */
|
nuclear@0
|
434 C_STRUCT aiNodeAnim** mChannels;
|
nuclear@0
|
435
|
nuclear@0
|
436
|
nuclear@0
|
437 /** The number of mesh animation channels. Each channel affects
|
nuclear@0
|
438 * a single mesh and defines vertex-based animation. */
|
nuclear@0
|
439 unsigned int mNumMeshChannels;
|
nuclear@0
|
440
|
nuclear@0
|
441 /** The mesh animation channels. Each channel affects a single mesh.
|
nuclear@0
|
442 * The array is mNumMeshChannels in size. */
|
nuclear@0
|
443 C_STRUCT aiMeshAnim** mMeshChannels;
|
nuclear@0
|
444
|
nuclear@0
|
445 /** The number of mesh animation channels. Each channel affects
|
nuclear@0
|
446 * a single mesh and defines morphing animation. */
|
nuclear@0
|
447 unsigned int mNumMorphMeshChannels;
|
nuclear@0
|
448
|
nuclear@0
|
449 /** The morph mesh animation channels. Each channel affects a single mesh.
|
nuclear@0
|
450 * The array is mNumMorphMeshChannels in size. */
|
nuclear@0
|
451 C_STRUCT aiMeshMorphAnim **mMorphMeshChannels;
|
nuclear@0
|
452
|
nuclear@0
|
453 #ifdef __cplusplus
|
nuclear@0
|
454 aiAnimation() AI_NO_EXCEPT
|
nuclear@0
|
455 : mDuration(-1.)
|
nuclear@0
|
456 , mTicksPerSecond(0.)
|
nuclear@0
|
457 , mNumChannels(0)
|
nuclear@0
|
458 , mChannels(0)
|
nuclear@0
|
459 , mNumMeshChannels(0)
|
nuclear@0
|
460 , mMeshChannels(0)
|
nuclear@0
|
461 , mNumMorphMeshChannels(0)
|
nuclear@0
|
462 , mMorphMeshChannels(0) {
|
nuclear@0
|
463 // empty
|
nuclear@0
|
464 }
|
nuclear@0
|
465
|
nuclear@0
|
466 ~aiAnimation() {
|
nuclear@0
|
467 // DO NOT REMOVE THIS ADDITIONAL CHECK
|
nuclear@0
|
468 if ( mNumChannels && mChannels ) {
|
nuclear@0
|
469 for( unsigned int a = 0; a < mNumChannels; a++) {
|
nuclear@0
|
470 delete mChannels[ a ];
|
nuclear@0
|
471 }
|
nuclear@0
|
472
|
nuclear@0
|
473 delete [] mChannels;
|
nuclear@0
|
474 }
|
nuclear@0
|
475 if (mNumMeshChannels && mMeshChannels) {
|
nuclear@0
|
476 for( unsigned int a = 0; a < mNumMeshChannels; a++) {
|
nuclear@0
|
477 delete mMeshChannels[a];
|
nuclear@0
|
478 }
|
nuclear@0
|
479
|
nuclear@0
|
480 delete [] mMeshChannels;
|
nuclear@0
|
481 }
|
nuclear@0
|
482 if (mNumMorphMeshChannels && mMorphMeshChannels) {
|
nuclear@0
|
483 for( unsigned int a = 0; a < mNumMorphMeshChannels; a++) {
|
nuclear@0
|
484 delete mMorphMeshChannels[a];
|
nuclear@0
|
485 }
|
nuclear@0
|
486
|
nuclear@0
|
487 delete [] mMorphMeshChannels;
|
nuclear@0
|
488 }
|
nuclear@0
|
489 }
|
nuclear@0
|
490 #endif // __cplusplus
|
nuclear@0
|
491 };
|
nuclear@0
|
492
|
nuclear@0
|
493 #ifdef __cplusplus
|
nuclear@0
|
494
|
nuclear@0
|
495 }
|
nuclear@0
|
496
|
nuclear@0
|
497 /// @brief Some C++ utilities for inter- and extrapolation
|
nuclear@0
|
498 namespace Assimp {
|
nuclear@0
|
499
|
nuclear@0
|
500 // ---------------------------------------------------------------------------
|
nuclear@0
|
501 /**
|
nuclear@0
|
502 * @brief CPP-API: Utility class to simplify interpolations of various data types.
|
nuclear@0
|
503 *
|
nuclear@0
|
504 * The type of interpolation is chosen automatically depending on the
|
nuclear@0
|
505 * types of the arguments.
|
nuclear@0
|
506 */
|
nuclear@0
|
507 template <typename T>
|
nuclear@0
|
508 struct Interpolator
|
nuclear@0
|
509 {
|
nuclear@0
|
510 // ------------------------------------------------------------------
|
nuclear@0
|
511 /** @brief Get the result of the interpolation between a,b.
|
nuclear@0
|
512 *
|
nuclear@0
|
513 * The interpolation algorithm depends on the type of the operands.
|
nuclear@0
|
514 * aiQuaternion's and aiQuatKey's SLERP, the rest does a simple
|
nuclear@0
|
515 * linear interpolation. */
|
nuclear@0
|
516 void operator () (T& out,const T& a, const T& b, ai_real d) const {
|
nuclear@0
|
517 out = a + (b-a)*d;
|
nuclear@0
|
518 }
|
nuclear@0
|
519 }; // ! Interpolator <T>
|
nuclear@0
|
520
|
nuclear@0
|
521 //! @cond Never
|
nuclear@0
|
522
|
nuclear@0
|
523 template <>
|
nuclear@0
|
524 struct Interpolator <aiQuaternion> {
|
nuclear@0
|
525 void operator () (aiQuaternion& out,const aiQuaternion& a,
|
nuclear@0
|
526 const aiQuaternion& b, ai_real d) const
|
nuclear@0
|
527 {
|
nuclear@0
|
528 aiQuaternion::Interpolate(out,a,b,d);
|
nuclear@0
|
529 }
|
nuclear@0
|
530 }; // ! Interpolator <aiQuaternion>
|
nuclear@0
|
531
|
nuclear@0
|
532 template <>
|
nuclear@0
|
533 struct Interpolator <unsigned int> {
|
nuclear@0
|
534 void operator () (unsigned int& out,unsigned int a,
|
nuclear@0
|
535 unsigned int b, ai_real d) const
|
nuclear@0
|
536 {
|
nuclear@0
|
537 out = d>0.5f ? b : a;
|
nuclear@0
|
538 }
|
nuclear@0
|
539 }; // ! Interpolator <aiQuaternion>
|
nuclear@0
|
540
|
nuclear@0
|
541 template <>
|
nuclear@0
|
542 struct Interpolator<aiVectorKey> {
|
nuclear@0
|
543 void operator () (aiVector3D& out,const aiVectorKey& a,
|
nuclear@0
|
544 const aiVectorKey& b, ai_real d) const
|
nuclear@0
|
545 {
|
nuclear@0
|
546 Interpolator<aiVector3D> ipl;
|
nuclear@0
|
547 ipl(out,a.mValue,b.mValue,d);
|
nuclear@0
|
548 }
|
nuclear@0
|
549 }; // ! Interpolator <aiVectorKey>
|
nuclear@0
|
550
|
nuclear@0
|
551 template <>
|
nuclear@0
|
552 struct Interpolator<aiQuatKey> {
|
nuclear@0
|
553 void operator () (aiQuaternion& out, const aiQuatKey& a,
|
nuclear@0
|
554 const aiQuatKey& b, ai_real d) const
|
nuclear@0
|
555 {
|
nuclear@0
|
556 Interpolator<aiQuaternion> ipl;
|
nuclear@0
|
557 ipl(out,a.mValue,b.mValue,d);
|
nuclear@0
|
558 }
|
nuclear@0
|
559 }; // ! Interpolator <aiQuatKey>
|
nuclear@0
|
560
|
nuclear@0
|
561 template <>
|
nuclear@0
|
562 struct Interpolator<aiMeshKey> {
|
nuclear@0
|
563 void operator () (unsigned int& out, const aiMeshKey& a,
|
nuclear@0
|
564 const aiMeshKey& b, ai_real d) const
|
nuclear@0
|
565 {
|
nuclear@0
|
566 Interpolator<unsigned int> ipl;
|
nuclear@0
|
567 ipl(out,a.mValue,b.mValue,d);
|
nuclear@0
|
568 }
|
nuclear@0
|
569 }; // ! Interpolator <aiQuatKey>
|
nuclear@0
|
570
|
nuclear@0
|
571 //! @endcond
|
nuclear@0
|
572
|
nuclear@0
|
573 } // ! end namespace Assimp
|
nuclear@0
|
574
|
nuclear@0
|
575 #endif // __cplusplus
|
nuclear@0
|
576
|
nuclear@0
|
577 #endif // AI_ANIM_H_INC
|