Ignition Common

API Reference

3.0.0
Animation.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef IGNITION_COMMON_ANIMATION_HH_
18 #define IGNITION_COMMON_ANIMATION_HH_
19 
20 #include <string>
21 #include <vector>
22 
23 #include <ignition/math/Spline.hh>
25 
26 #include <ignition/common/graphics/Export.hh>
27 
28 namespace ignition
29 {
30  namespace common
31  {
32  class KeyFrame;
33  class PoseKeyFrame;
34  class NumericKeyFrame;
35 
39  class IGNITION_COMMON_GRAPHICS_VISIBLE Animation
40  {
45  public: Animation(const std::string &_name,
46  const double _length, const bool _loop);
47 
49  public: virtual ~Animation();
50 
53  public: double Length() const;
54 
57  public: void Length(const double _len);
58 
61  public: void Time(const double _time);
62 
65  public: void AddTime(const double _time);
66 
69  public: double Time() const;
70 
73  public: unsigned int KeyFrameCount() const;
74 
78  public: common::KeyFrame *KeyFrame(const unsigned int _index) const;
79 
86  protected: double KeyFramesAtTime(
87  double _time, common::KeyFrame **_kf1,
88  common::KeyFrame **_kf2,
89  unsigned int &_firstKeyIndex) const;
90 
91 #ifdef _WIN32
92 // Disable warning C4251 which is triggered by
93 // std::unique_ptr
94 #pragma warning(push)
95 #pragma warning(disable: 4251)
96 #endif
97 
99  protected: std::string name;
100 
102  protected: double length;
103 
105  protected: double timePos;
106 
108  protected: mutable bool build;
109 
111  protected: bool loop;
112 
115 
117  protected: KeyFrame_V keyFrames;
118 #ifdef _WIN32
119 #pragma warning(pop)
120 #endif
121  };
122 
124  class IGNITION_COMMON_GRAPHICS_VISIBLE PoseAnimation : public Animation
125  {
130  public: PoseAnimation(const std::string &_name,
131  const double _length, const bool _loop);
132 
134  public: virtual ~PoseAnimation();
135 
139  public: PoseKeyFrame *CreateKeyFrame(const double _time);
140 
143  public: void InterpolatedKeyFrame(PoseKeyFrame &_kf) const;
144 
148  protected: void InterpolatedKeyFrame(const double _time,
149  PoseKeyFrame &_kf) const;
150 
152  protected: void BuildInterpolationSplines() const;
153 
155  private: mutable math::Spline *positionSpline;
156 
158  private: mutable math::RotationSpline *rotationSpline;
159  };
160 
162  class IGNITION_COMMON_GRAPHICS_VISIBLE NumericAnimation : public Animation
163  {
168  public: NumericAnimation(const std::string &_name,
169  const double _length, const bool _loop);
170 
172  public: virtual ~NumericAnimation();
173 
177  public: NumericKeyFrame *CreateKeyFrame(const double _time);
178 
182  public: void InterpolatedKeyFrame(NumericKeyFrame &_kf) const;
183  };
184  }
185 }
186 #endif
double length
animation duration
Definition: Animation.hh:102
bool build
determines if the interpolation splines need building
Definition: Animation.hh:108
Manages an animation, which is a collection of keyframes and the ability to interpolate between the k...
Definition: Animation.hh:39
std::vector< common::KeyFrame * > KeyFrame_V
array of keyframe type alias
Definition: Animation.hh:114
A numeric animation.
Definition: Animation.hh:162
std::string name
animation name
Definition: Animation.hh:99
A Time class, can be used to hold wall- or sim-time. stored as sec and nano-sec.
Definition: Time.hh:33
bool loop
true if animation repeats
Definition: Animation.hh:111
STL class.
A pose animation.
Definition: Animation.hh:124
A key frame in an animation.
Definition: KeyFrame.hh:30
A keyframe for a NumericAnimation.
Definition: KeyFrame.hh:90
KeyFrame_V keyFrames
array of key frames
Definition: Animation.hh:117
Forward declarations for the common classes.
double timePos
current time position
Definition: Animation.hh:105
A keyframe for a PoseAnimation.
Definition: KeyFrame.hh:48