TDME2  1.9.200
AnimationSetup.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 
5 #include <tdme/tdme.h>
7 
8 using std::string;
9 
11 
12 /**
13  * Animation setup
14  * @author Andreas Drewke
15  */
17 {
18  friend class Model;
19 
20 private:
21  Model* model { nullptr };
22  string id;
23  int32_t startFrame;
24  int32_t endFrame;
25  int32_t frames;
26  bool loop;
28  float speed;
29 
30 public:
31  // forbid class copy
33 
34  /**
35  * Public constructor
36  * @param model model
37  * @param id id
38  * @param startFrame start frame
39  * @param endFrame end frame
40  * @param loop loop
41  * @param overlayFromNodeId overlay from node id
42  * @param speed speed whereas 1.0 is default speed
43  */
44  AnimationSetup(Model* model, const string& id, int32_t startFrame, int32_t endFrame, bool loop, const string& overlayFromNodeId, float speed = 1.0);
45 
46  /**
47  * @return model this animation belongs to
48  */
49  inline Model* getModel() {
50  return model;
51  }
52 
53  /**
54  * @return id
55  */
56  inline const string& getId() {
57  return id;
58  }
59 
60  /**
61  * @return if animation set up is a overlay animation setup
62  */
63  inline bool isOverlayAnimationSetup() {
64  return overlayFromNodeId.empty() == false;
65  }
66 
67  /**
68  * @return start frame
69  */
70  inline int32_t getStartFrame() {
71  return startFrame;
72  }
73 
74  /**
75  * Set start frame
76  * @param startFrame start frame
77  */
78  void setStartFrame(int32_t startFrame);
79 
80  /**
81  * @return end frame
82  */
83  inline int32_t getEndFrame() {
84  return endFrame;
85  }
86 
87  /**
88  * Set end frame
89  * @param endFrame end frame
90  */
91  void setEndFrame(int32_t endFrame);
92 
93  /**
94  * @return frames
95  */
96  inline int32_t getFrames() {
97  return frames;
98  }
99 
100  /**
101  * @return looping enabled
102  */
103  inline bool isLoop() {
104  return loop;
105  }
106 
107  /**
108  * Set loop
109  * @param loop loop
110  */
111  inline void setLoop(bool loop) {
112  this->loop = loop;
113  }
114 
115  /**
116  * If this is a overlay animation this returns a node id from which node the animation will start in the hierarchy
117  * @return node id from which the animation will start in the hierarchy
118  */
119  inline const string& getOverlayFromNodeId() {
120  return overlayFromNodeId;
121  }
122 
123  /**
124  * Set overlay from node id
125  * @param overlayFromNodeId overlay from node id
126  */
127  inline void setOverlayFromNodeId(const string& overlayFromNodeId) {
128  this->overlayFromNodeId = overlayFromNodeId;
129  }
130 
131  /**
132  * @return animation duration in milliseconds
133  */
134  int64_t computeDuration();
135 
136  /**
137  * Compute animation duration
138  * @param startFrame start frame
139  * @param endFrame end frame
140  * @return animation duration in milliseconds
141  */
142  int64_t computeDuration(int32_t startFrame, int32_t endFrame);
143 
144  /**
145  * @return speed whereas 1.0 is default speed
146  */
147  inline float getSpeed() {
148  return speed;
149  }
150 
151  /**
152  * Set up animation speed
153  * @param speed speed whereas 1.0 is default speed
154  */
155  inline void setSpeed(float speed) {
156  this->speed = speed;
157  }
158 
159 private:
160 
161  /**
162  * Set id
163  * @param id id
164  */
165  inline void setId(const string& id) {
166  this->id = id;
167  }
168 
169 };
AnimationSetup(Model *model, const string &id, int32_t startFrame, int32_t endFrame, bool loop, const string &overlayFromNodeId, float speed=1.0)
Public constructor.
void setEndFrame(int32_t endFrame)
Set end frame.
void setSpeed(float speed)
Set up animation speed.
const string & getOverlayFromNodeId()
If this is a overlay animation this returns a node id from which node the animation will start in the...
void setId(const string &id)
Set id.
void setStartFrame(int32_t startFrame)
Set start frame.
void setLoop(bool loop)
Set loop.
void setOverlayFromNodeId(const string &overlayFromNodeId)
Set overlay from node id.
Representation of a 3D model.
Definition: Model.h:35
#define FORBID_CLASS_COPY(CLASS)
Definition: tdme.h:6