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