GraphicsAPI_2020C
anim.h
Go to the documentation of this file.
1 /*
2 ---------------------------------------------------------------------------
3 Open Asset Import Library (assimp)
4 ---------------------------------------------------------------------------
5 
6 Copyright (c) 2006-2017, assimp team
7 
8 
9 All rights reserved.
10 
11 Redistribution and use of this software in source and binary forms,
12 with or without modification, are permitted provided that the following
13 conditions are met:
14 
15 * Redistributions of source code must retain the above
16  copyright notice, this list of conditions and the
17  following disclaimer.
18 
19 * Redistributions in binary form must reproduce the above
20  copyright notice, this list of conditions and the
21  following disclaimer in the documentation and/or other
22  materials provided with the distribution.
23 
24 * Neither the name of the assimp team, nor the names of its
25  contributors may be used to endorse or promote products
26  derived from this software without specific prior
27  written permission of the assimp team.
28 
29 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
30 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
31 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
33 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
34 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
37 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 ---------------------------------------------------------------------------
41 */
42 
48 #pragma once
49 #ifndef AI_ANIM_H_INC
50 #define AI_ANIM_H_INC
51 
52 #include <assimp/types.h>
53 #include <assimp/quaternion.h>
54 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
59 // ---------------------------------------------------------------------------
62 {
64  double mTime;
65 
67  C_STRUCT aiVector3D mValue;
68 
69 #ifdef __cplusplus
70 
72  aiVectorKey()
73  : mTime( 0.0 )
74  , mValue() {
75  // empty
76  }
77 
79 
80  aiVectorKey(double time, const aiVector3D& value)
81  : mTime (time)
82  , mValue (value)
83  {}
84 
85  typedef aiVector3D elem_type;
86 
87  // Comparison operators. For use with std::find();
88  bool operator == (const aiVectorKey& o) const {
89  return o.mValue == this->mValue;
90  }
91  bool operator != (const aiVectorKey& o) const {
92  return o.mValue != this->mValue;
93  }
94 
95  // Relational operators. For use with std::sort();
96  bool operator < (const aiVectorKey& o) const {
97  return mTime < o.mTime;
98  }
99  bool operator > (const aiVectorKey& o) const {
100  return mTime > o.mTime;
101  }
102 #endif // __cplusplus
103 };
104 
105 // ---------------------------------------------------------------------------
108 struct aiQuatKey
109 {
111  double mTime;
112 
115 
116 #ifdef __cplusplus
117  aiQuatKey()
118  : mTime( 0.0 )
119  , mValue() {
120  // empty
121  }
122 
124  aiQuatKey(double time, const aiQuaternion& value)
125  : mTime (time)
126  , mValue (value)
127  {}
128 
129  typedef aiQuaternion elem_type;
130 
131  // Comparison operators. For use with std::find();
132  bool operator == (const aiQuatKey& o) const {
133  return o.mValue == this->mValue;
134  }
135  bool operator != (const aiQuatKey& o) const {
136  return o.mValue != this->mValue;
137  }
138 
139  // Relational operators. For use with std::sort();
140  bool operator < (const aiQuatKey& o) const {
141  return mTime < o.mTime;
142  }
143  bool operator > (const aiQuatKey& o) const {
144  return mTime > o.mTime;
145  }
146 #endif
147 };
148 
149 // ---------------------------------------------------------------------------
151 struct aiMeshKey
152 {
154  double mTime;
155 
160  unsigned int mValue;
161 
162 #ifdef __cplusplus
163 
164  aiMeshKey() {
165  }
166 
168  aiMeshKey(double time, const unsigned int value)
169  : mTime (time)
170  , mValue (value)
171  {}
172 
173  typedef unsigned int elem_type;
174 
175  // Comparison operators. For use with std::find();
176  bool operator == (const aiMeshKey& o) const {
177  return o.mValue == this->mValue;
178  }
179  bool operator != (const aiMeshKey& o) const {
180  return o.mValue != this->mValue;
181  }
182 
183  // Relational operators. For use with std::sort();
184  bool operator < (const aiMeshKey& o) const {
185  return mTime < o.mTime;
186  }
187  bool operator > (const aiMeshKey& o) const {
188  return mTime > o.mTime;
189  }
190 
191 #endif
192 };
193 
194 // ---------------------------------------------------------------------------
197 {
199  double mTime;
200 
202  unsigned int *mValues;
203  double *mWeights;
204 
206  unsigned int mNumValuesAndWeights;
207 #ifdef __cplusplus
209  : mTime(0.0)
210  , mValues(NULL)
211  , mWeights(NULL)
212  , mNumValuesAndWeights(0)
213  {
214 
215  }
216 
217  ~aiMeshMorphKey()
218  {
219  if (mNumValuesAndWeights && mValues && mWeights) {
220  delete [] mValues;
221  delete [] mWeights;
222  }
223  }
224 #endif
225 };
226 
227 // ---------------------------------------------------------------------------
232 {
235 
238 
242 
248 
251 #ifndef SWIG
253 #endif
254 };
255 
256 // ---------------------------------------------------------------------------
271 struct aiNodeAnim {
274  C_STRUCT aiString mNodeName;
275 
277  unsigned int mNumPositionKeys;
278 
284  C_STRUCT aiVectorKey* mPositionKeys;
285 
287  unsigned int mNumRotationKeys;
288 
295  C_STRUCT aiQuatKey* mRotationKeys;
296 
298  unsigned int mNumScalingKeys;
299 
305  C_STRUCT aiVectorKey* mScalingKeys;
306 
312  C_ENUM aiAnimBehaviour mPreState;
313 
319  C_ENUM aiAnimBehaviour mPostState;
320 
321 #ifdef __cplusplus
322  aiNodeAnim()
323  : mNumPositionKeys( 0 )
324  , mPositionKeys( NULL )
325  , mNumRotationKeys( 0 )
326  , mRotationKeys( NULL )
327  , mNumScalingKeys( 0 )
328  , mScalingKeys( NULL )
329  , mPreState( aiAnimBehaviour_DEFAULT )
330  , mPostState( aiAnimBehaviour_DEFAULT ) {
331  // empty
332  }
333 
334  ~aiNodeAnim() {
335  delete [] mPositionKeys;
336  delete [] mRotationKeys;
337  delete [] mScalingKeys;
338  }
339 #endif // __cplusplus
340 };
341 
342 // ---------------------------------------------------------------------------
349 {
354  C_STRUCT aiString mName;
355 
357  unsigned int mNumKeys;
358 
360  C_STRUCT aiMeshKey* mKeys;
361 
362 #ifdef __cplusplus
363 
364  aiMeshAnim()
365  : mNumKeys()
366  , mKeys()
367  {}
368 
369  ~aiMeshAnim()
370  {
371  delete[] mKeys;
372  }
373 
374 #endif
375 };
376 
377 // ---------------------------------------------------------------------------
380 {
385  C_STRUCT aiString mName;
386 
388  unsigned int mNumKeys;
389 
391  C_STRUCT aiMeshMorphKey* mKeys;
392 
393 #ifdef __cplusplus
394 
396  : mNumKeys()
397  , mKeys()
398  {}
399 
400  ~aiMeshMorphAnim()
401  {
402  delete[] mKeys;
403  }
404 
405 #endif
406 };
407 
408 // ---------------------------------------------------------------------------
411 struct aiAnimation {
415  C_STRUCT aiString mName;
416 
418  double mDuration;
419 
422 
425  unsigned int mNumChannels;
426 
429  C_STRUCT aiNodeAnim** mChannels;
430 
431 
434  unsigned int mNumMeshChannels;
435 
438  C_STRUCT aiMeshAnim** mMeshChannels;
439 
442  unsigned int mNumMorphMeshChannels;
443 
446  C_STRUCT aiMeshMorphAnim **mMorphMeshChannels;
447 
448 #ifdef __cplusplus
449  aiAnimation()
450  : mDuration(-1.)
451  , mTicksPerSecond(0.)
452  , mNumChannels(0)
453  , mChannels(NULL)
454  , mNumMeshChannels(0)
455  , mMeshChannels(NULL)
456  , mNumMorphMeshChannels(0)
457  , mMorphMeshChannels(NULL) {
458  // empty
459  }
460 
461  ~aiAnimation() {
462  // DO NOT REMOVE THIS ADDITIONAL CHECK
463  if ( mNumChannels && mChannels ) {
464  for( unsigned int a = 0; a < mNumChannels; a++) {
465  delete mChannels[ a ];
466  }
467 
468  delete [] mChannels;
469  }
470  if (mNumMeshChannels && mMeshChannels) {
471  for( unsigned int a = 0; a < mNumMeshChannels; a++) {
472  delete mMeshChannels[a];
473  }
474 
475  delete [] mMeshChannels;
476  }
477  if (mNumMorphMeshChannels && mMorphMeshChannels) {
478  for( unsigned int a = 0; a < mNumMorphMeshChannels; a++) {
479  delete mMorphMeshChannels[a];
480  }
481 
482  delete [] mMorphMeshChannels;
483  }
484  }
485 #endif // __cplusplus
486 };
487 
488 #ifdef __cplusplus
489 
490 }
491 
493 namespace Assimp {
494 
495 // ---------------------------------------------------------------------------
502 template <typename T>
503 struct Interpolator
504 {
505  // ------------------------------------------------------------------
511  void operator () (T& out,const T& a, const T& b, ai_real d) const {
512  out = a + (b-a)*d;
513  }
514 }; // ! Interpolator <T>
515 
517 
518 template <>
519 struct Interpolator <aiQuaternion> {
520  void operator () (aiQuaternion& out,const aiQuaternion& a,
521  const aiQuaternion& b, ai_real d) const
522  {
523  aiQuaternion::Interpolate(out,a,b,d);
524  }
525 }; // ! Interpolator <aiQuaternion>
526 
527 template <>
528 struct Interpolator <unsigned int> {
529  void operator () (unsigned int& out,unsigned int a,
530  unsigned int b, ai_real d) const
531  {
532  out = d>0.5f ? b : a;
533  }
534 }; // ! Interpolator <aiQuaternion>
535 
536 template <>
537 struct Interpolator<aiVectorKey> {
538  void operator () (aiVector3D& out,const aiVectorKey& a,
539  const aiVectorKey& b, ai_real d) const
540  {
541  Interpolator<aiVector3D> ipl;
542  ipl(out,a.mValue,b.mValue,d);
543  }
544 }; // ! Interpolator <aiVectorKey>
545 
546 template <>
547 struct Interpolator<aiQuatKey> {
548  void operator () (aiQuaternion& out, const aiQuatKey& a,
549  const aiQuatKey& b, ai_real d) const
550  {
551  Interpolator<aiQuaternion> ipl;
552  ipl(out,a.mValue,b.mValue,d);
553  }
554 }; // ! Interpolator <aiQuatKey>
555 
556 template <>
557 struct Interpolator<aiMeshKey> {
558  void operator () (unsigned int& out, const aiMeshKey& a,
559  const aiMeshKey& b, ai_real d) const
560  {
561  Interpolator<unsigned int> ipl;
562  ipl(out,a.mValue,b.mValue,d);
563  }
564 }; // ! Interpolator <aiQuatKey>
565 
567 
568 } // ! end namespace Assimp
569 
570 #endif // __cplusplus
571 
572 #endif // AI_ANIM_H_INC
The value from the default node transformation is taken.
Definition: anim.h:234
The nearest key value is used without interpolation.
Definition: anim.h:237
An animation consists of key-frame data for a number of nodes.
Definition: anim.h:411
Basic data types and primitives, such as vectors or colors.
Describes vertex-based animations for a single mesh or a group of meshes.
Definition: anim.h:348
Assimp&#39;s CPP-API and all internal APIs.
Definition: DefaultIOStream.h:51
Binds a morph anim mesh to a specific point in time.
Definition: anim.h:196
unsigned int mNumPositionKeys
The number of position keys.
Definition: anim.h:277
unsigned int mNumMorphMeshChannels
The number of mesh animation channels.
Definition: anim.h:442
double mTime
The time of this key.
Definition: anim.h:154
Binds a anim mesh to a specific point in time.
Definition: anim.h:151
Definition: quaternion.h:123
unsigned int mNumKeys
Size of the mKeys array.
Definition: anim.h:357
The animation is repeated.
Definition: anim.h:247
unsigned int mNumRotationKeys
The number of rotation keys.
Definition: anim.h:287
Describes a morphing animation of a given mesh.
Definition: anim.h:379
The value of the nearest two keys is linearly extrapolated for the current time value.
Definition: anim.h:241
unsigned int mValue
Index into the aiMesh::mAnimMeshes array of the mesh corresponding to the aiMeshAnim hosting this key...
Definition: anim.h:160
aiAnimBehaviour
Defines how an animation channel behaves outside the defined time range.
Definition: anim.h:231
unsigned int mNumScalingKeys
The number of scaling keys.
Definition: anim.h:298
Represents an UTF-8 string, zero byte terminated.
Definition: types.h:252
double mTime
The time of this key.
Definition: anim.h:199
A time-value pair specifying a certain 3D vector for the given time.
Definition: anim.h:61
double mTime
The time of this key.
Definition: anim.h:64
Describes the animation of a single node.
Definition: anim.h:271
Definition: vector3.h:135
double mTicksPerSecond
Ticks per second.
Definition: anim.h:421
Quaternion structure, including operators when compiling in C++.
C_STRUCT aiQuaternion mValue
The value of this key.
Definition: anim.h:114
This value is not used, it is just here to force the the compiler to map this enum to a 32 Bit intege...
Definition: anim.h:252
unsigned int * mValues
The values and weights at the time of this key.
Definition: anim.h:202
double mDuration
Duration of the animation in ticks.
Definition: anim.h:418
unsigned int mNumMeshChannels
The number of mesh animation channels.
Definition: anim.h:434
C_STRUCT aiVector3D mValue
The value of this key.
Definition: anim.h:67
A time-value pair specifying a rotation for the given time.
Definition: anim.h:108
unsigned int mNumValuesAndWeights
The number of values and weights.
Definition: anim.h:206
unsigned int mNumKeys
Size of the mKeys array.
Definition: anim.h:388
double mTime
The time of this key.
Definition: anim.h:111
unsigned int mNumChannels
The number of bone animation channels.
Definition: anim.h:425