AnimEngine
SkeletonAnimator.hpp
1 #pragma once
2 #ifndef KJY_ANIM_ENGINE_COMPONENTS_SKELETON_ANIMATOR_HPP_
3 #define KJY_ANIM_ENGINE_COMPONENTS_SKELETON_ANIMATOR_HPP_
4 #include "KeyframeAnimation.hpp"
5 #include <vector>
6 
9  SkeletonAnimationSequence(const std::string& name, size_t bone_count) : name(name), bone_subanimations(bone_count) {}
10 
11  virtual Pose sample(size_t index, key_time_t time) const override;
12  virtual void sampleInPlace(size_t index, key_time_t time, Pose& target_prop) const override;
13  virtual key_time_t getLength() const override;
14  /* Name of the animation */
15  std::string name;
16 
17  /* One element for each bone */
18  std::vector<PoseKeyframeSequence> bone_subanimations;
19 
20  /* Get the length of this animation in milliseconds. Don't call this too
21  * often, it requires an O(n) search of the skeleton. */
22 };
23 
25  public:
28  SkinKeyframeAnimator(const std::string& name, size_t bone_count) : _animation_name(name), sequence(name, bone_count) {}
29 
30  virtual key_time_t getCurrentTime() const override;
31  virtual void setCurrentTime(key_time_t time) override;
32  virtual std::string getAnimatorName() const override;
33  virtual void setAnimatorName(const std::string& name) override;
34 
35  virtual bool isEnabled() const override {return(_enabled);}
36  virtual void enable() override {_enabled = true;}
37  virtual void disable() override {_enabled = false;}
38 
39  virtual key_time_t getLength() const override;
40 
41  virtual bool willLoop() const override {return(_loops);}
42  virtual void enableLoop() override {_loops = true;};
43  virtual void disableLoop() override {_loops = false;}
44  /* Override the time index at which the animation loops. A time value of 0 resets to the default */
45  virtual void overrideLoopTime(key_time_t time) override {_loop_time = time;}
46  /* Reset loop time to the default (The length of the animation) */
47  virtual void resetLoopTime() override {_loop_time = 0;}
48 
49  virtual Pose sample(size_t bone_index) const;
50 
51  protected:
52  key_time_t _current_time;
53  std::string _animation_name;
54 
55  bool _enabled = true;
56  bool _loops = true;
57  key_time_t _loop_time = 0;
58 };
59 
60 
61 #endif
Definition: SkeletonAnimator.hpp:7
Definition: KeyframeAnimation.hpp:102
Definition: Pose.hpp:11
Definition: SkeletonAnimator.hpp:24
Definition: KeyframeAnimation.hpp:130