Radium Engine  1.5.0
AnimationData.hpp
1 #pragma once
2 
3 #include <Core/Animation/KeyFramedValue.hpp>
4 #include <Core/Asset/AnimationTime.hpp>
5 #include <Core/Asset/AssetData.hpp>
6 #include <Core/RaCore.hpp>
7 #include <Core/Utils/Log.hpp>
8 
9 #include <string>
10 #include <vector>
11 
12 namespace Ra {
13 namespace Core {
14 namespace Asset {
15 
19 struct RA_CORE_API HandleAnimation {
20  explicit HandleAnimation( const std::string& name = "" );
21 
23  std::string m_name;
24 
27 
30 };
31 
37 class RA_CORE_API AnimationData : public AssetData
38 {
39  public:
40  explicit AnimationData( const std::string& name = "" );
41 
42  ~AnimationData();
43 
47  inline void setName( const std::string& name ) { m_name = name; }
48 
51 
55  inline const AnimationTime& getTime() const { return m_time; }
56 
60  inline void setTime( const AnimationTime& time ) { m_time = time; }
64  inline AnimationTime::Time getTimeStep() const { return m_dt; }
65 
69  inline void setTimeStep( const AnimationTime::Time& delta ) { m_dt = delta; }
70 
72 
75 
79  inline uint getFramesSize() const { return m_keyFrame.size(); }
80 
84  inline std::vector<HandleAnimation> getHandleData() const { return m_keyFrame; }
85 
89  inline void setHandleData( const std::vector<HandleAnimation>& frameList );
91 
95  inline void displayInfo() const;
96 
97  protected:
100 
103 
105  std::vector<HandleAnimation> m_keyFrame;
106 };
107 
108 inline void AnimationData::setHandleData( const std::vector<HandleAnimation>& frameList ) {
109  const uint size = frameList.size();
110  m_keyFrame.resize( size );
111 #pragma omp parallel for
112  for ( int i = 0; i < int( size ); ++i ) {
113  m_keyFrame[i] = frameList[i];
114  }
115 }
116 
117 inline void AnimationData::displayInfo() const {
118  using namespace Core::Utils; // log
119  LOG( logDEBUG ) << "======== ANIMATION INFO ========";
120  LOG( logDEBUG ) << " Name : " << m_name;
121  LOG( logDEBUG ) << " Start Time : " << m_time.getStart();
122  LOG( logDEBUG ) << " End Time : " << m_time.getEnd();
123  LOG( logDEBUG ) << " Time Step : " << m_dt;
124  LOG( logDEBUG ) << " Animated Object # : " << m_keyFrame.size();
125 }
126 
127 } // namespace Asset
128 } // namespace Core
129 } // namespace Ra
void setHandleData(const std::vector< HandleAnimation > &frameList)
std::vector< HandleAnimation > getHandleData() const
AnimationTime m_time
The AnimationTime for the object.
std::vector< HandleAnimation > m_keyFrame
The animation frames.
AnimationTime::Time getTimeStep() const
const AnimationTime & getTime() const
AnimationTime::Time m_dt
The animation timestep.
void setName(const std::string &name)
void setTimeStep(const AnimationTime::Time &delta)
void setTime(const AnimationTime &time)
Definition: Cage.cpp:3
std::string m_name
The Handle's name.
AnimationTime m_animationTime
The AnimationTime for the Handle.
Core::Animation::KeyFramedValue< Transform > m_anim
The list of KeyFramed transforms applied to the Handle.