BRE12
anim.h
Go to the documentation of this file.
1 /*
2 ---------------------------------------------------------------------------
3 Open Asset Import Library (assimp)
4 ---------------------------------------------------------------------------
5 
6 Copyright (c) 2006-2012, assimp team
7 
8 All rights reserved.
9 
10 Redistribution and use of this software in source and binary forms,
11 with or without modification, are permitted provided that the following
12 conditions are met:
13 
14 * Redistributions of source code must retain the above
15  copyright notice, this list of conditions and the
16  following disclaimer.
17 
18 * Redistributions in binary form must reproduce the above
19  copyright notice, this list of conditions and the
20  following disclaimer in the documentation and/or other
21  materials provided with the distribution.
22 
23 * Neither the name of the assimp team, nor the names of its
24  contributors may be used to endorse or promote products
25  derived from this software without specific prior
26  written permission of the assimp team.
27 
28 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 ---------------------------------------------------------------------------
40 */
41 
46 #ifndef AI_ANIM_H_INC
47 #define AI_ANIM_H_INC
48 
49 #include "types.h"
50 #include "quaternion.h"
51 
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 
56 // ---------------------------------------------------------------------------
58 struct aiVectorKey
59 {
61  double mTime;
62 
64  C_STRUCT aiVector3D mValue;
65 
66 #ifdef __cplusplus
67 
69  aiVectorKey(){}
70 
72  aiVectorKey(double time, const aiVector3D& value)
73  : mTime (time)
74  , mValue (value)
75  {}
76 
77 
78  typedef aiVector3D elem_type;
79 
80  // Comparison operators. For use with std::find();
81  bool operator == (const aiVectorKey& o) const {
82  return o.mValue == this->mValue;
83  }
84  bool operator != (const aiVectorKey& o) const {
85  return o.mValue != this->mValue;
86  }
87 
88  // Relational operators. For use with std::sort();
89  bool operator < (const aiVectorKey& o) const {
90  return mTime < o.mTime;
91  }
92  bool operator > (const aiVectorKey& o) const {
93  return mTime > o.mTime;
94  }
95 #endif
96 };
97 
98 // ---------------------------------------------------------------------------
101 struct aiQuatKey
102 {
104  double mTime;
105 
107  C_STRUCT aiQuaternion mValue;
108 
109 #ifdef __cplusplus
110  aiQuatKey(){
111  }
112 
114  aiQuatKey(double time, const aiQuaternion& value)
115  : mTime (time)
116  , mValue (value)
117  {}
118 
119  typedef aiQuaternion elem_type;
120 
121  // Comparison operators. For use with std::find();
122  bool operator == (const aiQuatKey& o) const {
123  return o.mValue == this->mValue;
124  }
125  bool operator != (const aiQuatKey& o) const {
126  return o.mValue != this->mValue;
127  }
128 
129  // Relational operators. For use with std::sort();
130  bool operator < (const aiQuatKey& o) const {
131  return mTime < o.mTime;
132  }
133  bool operator > (const aiQuatKey& o) const {
134  return mTime > o.mTime;
135  }
136 #endif
137 };
138 
139 // ---------------------------------------------------------------------------
141 struct aiMeshKey
142 {
144  double mTime;
145 
150  unsigned int mValue;
151 
152 #ifdef __cplusplus
153 
154  aiMeshKey() {
155  }
156 
158  aiMeshKey(double time, const unsigned int value)
159  : mTime (time)
160  , mValue (value)
161  {}
162 
163  typedef unsigned int elem_type;
164 
165  // Comparison operators. For use with std::find();
166  bool operator == (const aiMeshKey& o) const {
167  return o.mValue == this->mValue;
168  }
169  bool operator != (const aiMeshKey& o) const {
170  return o.mValue != this->mValue;
171  }
172 
173  // Relational operators. For use with std::sort();
174  bool operator < (const aiMeshKey& o) const {
175  return mTime < o.mTime;
176  }
177  bool operator > (const aiMeshKey& o) const {
178  return mTime > o.mTime;
179  }
180 
181 #endif
182 };
183 
184 // ---------------------------------------------------------------------------
188 enum aiAnimBehaviour
189 {
191  aiAnimBehaviour_DEFAULT = 0x0,
192 
194  aiAnimBehaviour_CONSTANT = 0x1,
195 
198  aiAnimBehaviour_LINEAR = 0x2,
199 
204  aiAnimBehaviour_REPEAT = 0x3,
205 
206 
207 
210 #ifndef SWIG
211  _aiAnimBehaviour_Force32Bit = INT_MAX
212 #endif
213 };
214 
215 // ---------------------------------------------------------------------------
230 struct aiNodeAnim
231 {
234  C_STRUCT aiString mNodeName;
235 
237  unsigned int mNumPositionKeys;
238 
244  C_STRUCT aiVectorKey* mPositionKeys;
245 
247  unsigned int mNumRotationKeys;
248 
255  C_STRUCT aiQuatKey* mRotationKeys;
256 
257 
259  unsigned int mNumScalingKeys;
260 
266  C_STRUCT aiVectorKey* mScalingKeys;
267 
268 
274  C_ENUM aiAnimBehaviour mPreState;
275 
281  C_ENUM aiAnimBehaviour mPostState;
282 
283 #ifdef __cplusplus
284  aiNodeAnim()
285  {
286  mNumPositionKeys = 0; mPositionKeys = NULL;
287  mNumRotationKeys = 0; mRotationKeys = NULL;
288  mNumScalingKeys = 0; mScalingKeys = NULL;
289 
290  mPreState = mPostState = aiAnimBehaviour_DEFAULT;
291  }
292 
293  ~aiNodeAnim()
294  {
295  delete [] mPositionKeys;
296  delete [] mRotationKeys;
297  delete [] mScalingKeys;
298  }
299 #endif // __cplusplus
300 };
301 
302 // ---------------------------------------------------------------------------
308 struct aiMeshAnim
309 {
314  C_STRUCT aiString mName;
315 
317  unsigned int mNumKeys;
318 
320  C_STRUCT aiMeshKey* mKeys;
321 
322 #ifdef __cplusplus
323 
324  aiMeshAnim()
325  : mNumKeys()
326  , mKeys()
327  {}
328 
329  ~aiMeshAnim()
330  {
331  delete[] mKeys;
332  }
333 
334 #endif
335 };
336 
337 // ---------------------------------------------------------------------------
340 struct aiAnimation
341 {
345  C_STRUCT aiString mName;
346 
348  double mDuration;
349 
351  double mTicksPerSecond;
352 
355  unsigned int mNumChannels;
356 
359  C_STRUCT aiNodeAnim** mChannels;
360 
361 
364  unsigned int mNumMeshChannels;
365 
368  C_STRUCT aiMeshAnim** mMeshChannels;
369 
370 #ifdef __cplusplus
371  aiAnimation()
372  : mDuration(-1.)
373  , mTicksPerSecond()
374  , mNumChannels()
375  , mChannels()
376  , mNumMeshChannels()
377  , mMeshChannels()
378  {
379  }
380 
381  ~aiAnimation()
382  {
383  // DO NOT REMOVE THIS ADDITIONAL CHECK
384  if (mNumChannels && mChannels) {
385  for( unsigned int a = 0; a < mNumChannels; a++) {
386  delete mChannels[a];
387  }
388 
389  delete [] mChannels;
390  }
391  if (mNumMeshChannels && mMeshChannels) {
392  for( unsigned int a = 0; a < mNumMeshChannels; a++) {
393  delete mMeshChannels[a];
394  }
395 
396  delete [] mMeshChannels;
397  }
398  }
399 #endif // __cplusplus
400 };
401 
402 #ifdef __cplusplus
403 }
404 
405 
406 // some C++ utilities for inter- and extrapolation
407 namespace Assimp {
408 
409 // ---------------------------------------------------------------------------
414 template <typename T>
415 struct Interpolator
416 {
417  // ------------------------------------------------------------------
423  void operator () (T& out,const T& a, const T& b, float d) const {
424  out = a + (b-a)*d;
425  }
426 }; // ! Interpolator <T>
427 
429 
430 template <>
431 struct Interpolator <aiQuaternion> {
432  void operator () (aiQuaternion& out,const aiQuaternion& a,
433  const aiQuaternion& b, float d) const
434  {
435  aiQuaternion::Interpolate(out,a,b,d);
436  }
437 }; // ! Interpolator <aiQuaternion>
438 
439 template <>
440 struct Interpolator <unsigned int> {
441  void operator () (unsigned int& out,unsigned int a,
442  unsigned int b, float d) const
443  {
444  out = d>0.5f ? b : a;
445  }
446 }; // ! Interpolator <aiQuaternion>
447 
448 template <>
449 struct Interpolator <aiVectorKey> {
450  void operator () (aiVector3D& out,const aiVectorKey& a,
451  const aiVectorKey& b, float d) const
452  {
453  Interpolator<aiVector3D> ipl;
454  ipl(out,a.mValue,b.mValue,d);
455  }
456 }; // ! Interpolator <aiVectorKey>
457 
458 template <>
459 struct Interpolator <aiQuatKey> {
460  void operator () (aiQuaternion& out, const aiQuatKey& a,
461  const aiQuatKey& b, float d) const
462  {
463  Interpolator<aiQuaternion> ipl;
464  ipl(out,a.mValue,b.mValue,d);
465  }
466 }; // ! Interpolator <aiQuatKey>
467 
468 template <>
469 struct Interpolator <aiMeshKey> {
470  void operator () (unsigned int& out, const aiMeshKey& a,
471  const aiMeshKey& b, float d) const
472  {
473  Interpolator<unsigned int> ipl;
474  ipl(out,a.mValue,b.mValue,d);
475  }
476 }; // ! Interpolator <aiQuatKey>
477 
479 } // ! end namespace Assimp
480 
481 
482 
483 #endif // __cplusplus
484 #endif // AI_ANIM_H_INC
Basic data types and primitives, such as vectors or colors.
Assimp&#39;s CPP-API and all internal APIs.
Definition: DefaultLogger.hpp:51
Definition: quaternion.h:119
Represents an UTF-8 string, zero byte terminated.
Definition: types.h:251
Definition: vector3.h:134
Quaternion structure, including operators when compiling in C++.