Jet  v1.3.3
animation.h
Go to the documentation of this file.
1 // Copyright (c) 2018 Doyub Kim
2 //
3 // I am making my contributions/submissions to this project solely in my
4 // personal capacity and am not conveying any rights to any intellectual
5 // property of any third parties.
6 
7 #ifndef INCLUDE_JET_ANIMATION_H_
8 #define INCLUDE_JET_ANIMATION_H_
9 
10 #include <jet/macros.h>
11 #include <memory>
12 
13 namespace jet {
14 
21 struct Frame final {
23  int index = 0;
24 
26  double timeIntervalInSeconds = 1.0 / 60.0;
27 
29  Frame();
30 
32  Frame(int newIndex, double newTimeIntervalInSeconds);
33 
35  double timeInSeconds() const;
36 
38  void advance();
39 
42  void advance(int delta);
43 
46 
49 };
50 
59 class Animation {
60  public:
62 
63  virtual ~Animation();
64 
71  void update(const Frame& frame);
72 
73  protected:
82  virtual void onUpdate(const Frame& frame) = 0;
83 };
84 
86 typedef std::shared_ptr<Animation> AnimationPtr;
87 
88 } // namespace jet
89 
90 #endif // INCLUDE_JET_ANIMATION_H_
jet::Frame::timeInSeconds
double timeInSeconds() const
Returns the elapsed time in seconds.
jet::Frame::advance
void advance()
Advances single frame.
jet::AnimationPtr
std::shared_ptr< Animation > AnimationPtr
Shared pointer for the Animation type.
Definition: animation.h:86
macros.h
jet::Frame::advance
void advance(int delta)
jet::Animation::onUpdate
virtual void onUpdate(const Frame &frame)=0
The implementation of this function should update the animation state for given Frame instance frame.
jet
Definition: advection_solver2.h:18
jet::Animation::Animation
Animation()
jet::Animation
Abstract base class for animation-related class.
Definition: animation.h:59
jet::Animation::~Animation
virtual ~Animation()
jet::Frame::Frame
Frame()
Constructs Frame instance with 1/60 seconds time interval.
jet::Frame
Representation of an animation frame.
Definition: animation.h:21
jet::Frame::timeIntervalInSeconds
double timeIntervalInSeconds
Time interval in seconds between two adjacent frames.
Definition: animation.h:26
jet::Frame::operator++
Frame & operator++()
Advances single frame (prefix).
jet::Frame::Frame
Frame(int newIndex, double newTimeIntervalInSeconds)
Constructs Frame instance with given time interval.
jet::Frame::operator++
Frame operator++(int)
Advances single frame (postfix).
jet::Animation::update
void update(const Frame &frame)
Updates animation state for given frame.
jet::Frame::index
int index
Frame index.
Definition: animation.h:23