GteKeyframeController.h
Go to the documentation of this file.
1 // David Eberly, Geometric Tools, Redmond WA 98052
2 // Copyright (c) 1998-2017
3 // Distributed under the Boost Software License, Version 1.0.
4 // http://www.boost.org/LICENSE_1_0.txt
5 // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
6 // File Version: 3.0.0 (2016/06/19)
7 
8 #pragma once
9 
12 
13 namespace gte
14 {
15 
17 {
18 public:
19  // Construction and destruction. If the translations, rotations, and
20  // scales all share the same keyframe times, then numCommonTimes is
21  // set to a positive number. Each remaining number is numCommonTimes
22  // when the channel exists or zero when it does not. If the keyframe
23  // times are not shared, then numCommonTimes must be set to zero and
24  // the remaining numbers set to the appropriate values--positive when
25  // the channel exists or zero otherwise.
26  //
27  // The Transform input initializes the controlled object's local
28  // transform. The previous behavior of this class was to fill in only
29  // those transformation channels represented by the key frames, which
30  // relied implicitly on the Spatial mObject to have its other channels
31  // set appropriately by the application. Now KeyframeController sets
32  // *all* the channels.
33  virtual ~KeyframeController();
34  KeyframeController(int numCommonTimes, int numTranslations,
35  int numRotations, int numScales, Transform const& localTransform);
36 
37  // Member access. After calling the constructor, you must set the data
38  // using these functions.
39  inline int GetNumCommonTimes() const;
40  inline float* GetCommonTimes();
41 
42  inline int GetNumTranslations() const;
43  inline float* GetTranslationTimes();
44  inline Vector4<float>* GetTranslations();
45 
46  inline int GetNumRotations() const;
47  inline float* GetRotationTimes();
48  inline Quaternion<float>* GetRotations();
49 
50  inline int GetNumScales() const;
51  inline float* GetScaleTimes();
52  inline float* GetScales();
53 
54  // The animation update. The application time is in milliseconds.
55  virtual bool Update(double applicationTime);
56 
57 protected:
58  // Support for looking up keyframes given the specified time.
59  static void GetKeyInfo(float ctrlTime, int numTimes, float* times,
60  int& lastIndex, float& normTime, int& i0, int& i1);
61 
62  Vector4<float> GetTranslate(float normTime, int i0, int i1);
63  Matrix4x4<float> GetRotate(float normTime, int i0, int i1);
64  float GetScale(float normTime, int i0, int i1);
65 
66  // This array is used only when times are shared by translations,
67  // rotations, and scales.
69  std::vector<float> mCommonTimes;
70 
72  std::vector<float> mTranslationTimes;
73  std::vector<Vector4<float>> mTranslations;
74 
76  std::vector<float> mRotationTimes;
77  std::vector<Quaternion<float>> mRotations;
78 
80  std::vector<float> mScaleTimes;
81  std::vector<float> mScales;
82 
83  // Cached indices for the last found pair of keys used for interpolation.
84  // For a sequence of times, this guarantees an O(1) lookup.
85  int mTLastIndex, mRLastIndex, mSLastIndex, mCLastIndex;
86 };
87 
88 
90 {
91  return mNumCommonTimes;
92 }
93 
95 {
96  return mCommonTimes.data();
97 }
98 
100 {
101  return mNumTranslations;
102 }
103 
105 {
106  return mTranslationTimes.data();
107 }
108 
110 {
111  return mTranslations.data();
112 }
113 
115 {
116  return mNumRotations;
117 }
118 
120 {
121  return mRotationTimes.data();
122 }
123 
125 {
126  return mRotations.data();
127 }
128 
130 {
131  return mNumScales;
132 }
133 
135 {
136  return mScaleTimes.data();
137 }
138 
140 {
141  return mScales.data();
142 }
143 
144 }
std::vector< float > mTranslationTimes
Vector4< float > * GetTranslations()
Quaternion< float > * GetRotations()
std::vector< float > mCommonTimes
std::vector< float > mScales
std::vector< Vector4< float > > mTranslations
std::vector< float > mScaleTimes
std::vector< Quaternion< float > > mRotations
std::vector< float > mRotationTimes
#define GTE_IMPEXP
Definition: GTEngineDEF.h:63


geometric_tools_engine
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 04:00:00