Gorgon Game Engine
TextureAnimation.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "Animations.h"
4 #include "Texture.h"
5 #include "Bitmap.h"
6 #include "../Containers/Collection.h"
7 
8 namespace Gorgon { namespace Graphics {
9 
10  template<class T_>
12  public:
14  };
15 
16 
17  template<class T_, template<class, class, class> class A_, class F_>
18  class basic_TextureAnimationProvider;
19 
20  template<class T_>
22  template<class T__, template<class, class, class> class A_, class F_>
24  public:
25  basic_AnimationFrame(T_ &image, unsigned duration = 42, unsigned start = 0) :
26  image(&image), duration(duration), start(start) { }
27 
29  unsigned GetDuration() const override {
30  return duration;
31  }
32 
34  unsigned GetStart() const override {
35  return start;
36  }
37 
39  unsigned GetEnd() const override {
40  return start + duration;
41  }
42 
44  bool IsIn(unsigned time) const override {
45  return time >= start && time < start + duration;
46  }
47 
49  T_ &GetImage() const {
50  return *image;
51  }
52 
53  private:
54  T_ *image;
55  unsigned duration, start;
56  };
57 
58  template<class T_, class P_, class F_>
59  class basic_TextureAnimation : public virtual Image, public virtual DiscreteAnimation {
60  public:
61  using ParentType = P_;
62  using FrameType = F_;
63 
66  Gorgon::Animation::Base(controller), parent(&parent) { }
67 
69  basic_TextureAnimation(const ParentType &parent, bool create) :
70  Gorgon::Animation::Base(create), parent(&parent) { }
71 
73  virtual void DeleteAnimation() const override {
74  delete this;
75  }
76 
77  virtual bool Progress(unsigned &leftover) override;
78 
79  int GetDuration() const override {
80  return parent->GetDuration();
81  }
82 
83  virtual GL::Texture GetID() const override {
84  if(current < (unsigned)parent->GetCount())
85  return (*parent)[current].GetID();
86  else if(parent->GetCount())
87  return (*parent)[0].GetID();
88 
89  Utils::ASSERT_FALSE("Animation contains no frames.");
90 
91  return 0;
92  }
93 
94  virtual Geometry::Size GetImageSize() const override {
95  if(current < (unsigned)parent->GetCount())
96  return (*parent)[current].GetImageSize();
97  else if(parent->GetCount())
98  return (*parent)[0].GetImageSize();
99 
100  Utils::ASSERT_FALSE("Animation contains no frames.");
101 
102  return {0, 0};
103  }
104 
105  virtual ColorMode GetMode() const override {
106  if(current < (unsigned)parent->GetCount())
107  return (*parent)[current].GetMode();
108  else if(parent->GetCount())
109  return (*parent)[0].GetMode();
110 
111  Utils::ASSERT_FALSE("Animation contains no frames.");
112 
113  return ColorMode::RGBA;
114  }
115 
116  virtual const Geometry::Pointf *GetCoordinates() const override {
117  if(current < (unsigned)parent->GetCount())
118  return (*parent)[current].GetCoordinates();
119  else if(parent->GetCount())
120  return (*parent)[0].GetCoordinates();
121 
122  Utils::ASSERT_FALSE("Animation contains no frames.");
123 
124  return nullptr;
125  }
126 
127  unsigned CurrentFrame() const override {
128  return current;
129  }
130 
131  private:
132  const ParentType *parent = nullptr;
133  unsigned current = NoFrame;
134  };
135 
136  template<class T_, template<class, class, class> class A_, class F_>
138  public:
139  using Iterator = typename std::vector<basic_AnimationFrame<T_>>::iterator;
140  using ConstIterator = typename std::vector<basic_AnimationFrame<T_>>::const_iterator;
142  using FrameType = F_;
143 
145 
147 
148  template<class C_>
150  swapout(other);
151  }
152 
153  //types are derived not to type the same code for every class
154  virtual auto MoveOutProvider() -> decltype(*this) override {
155  auto ret = new typename std::remove_reference<decltype(*this)>::type(std::move(*this));
156 
157  return *ret;
158  }
159 
161 
162  template<class C_>
164  frames.clear();
165  duration = 0;
166 
167  swapout(other);
168 
169  return *this;
170  }
171 
173  destroylist.Destroy();
174  }
175 
178  p.frames = frames;
179  p.duration = duration;
180 
181  return p;
182  }
183 
185  int GetWidth() const {
186  if(frames.size()>0)
187  return frames[0].GetImage().GetWidth();
188 
189  return 0;
190  }
191 
193  int GetHeight() const {
194  if(frames.size()>0)
195  return frames[0].GetImage().GetHeight();
196 
197  return 0;
198  }
199 
201  Geometry::Size GetSize() const override {
202  if(frames.size()>0)
203  return frames[0].GetImage().GetSize();
204 
205  return {0, 0};
206  }
207 
209  int GetCount() const override {
210  return (int)frames.size();
211  }
212 
214  virtual AnimationType &CreateAnimation(Gorgon::Animation::ControllerBase &controller) const override {
215  return *new AnimationType(*this, controller);
216  }
217 
219  virtual AnimationType &CreateAnimation(bool create=true) const override {
220  return *new AnimationType(*this, create);
221  }
222 
225  T_ &ImageAt(unsigned time) const {
226  ASSERT(frames.size() || duration==0, "Animation is empty");
227 
228  time=time%GetDuration();
229 
230  return frames[FrameAt(time)].GetImage();
231  }
232 
234  T_ &operator [](int frame) const {
235  ASSERT(frame>=0 && frame<(int)frames.size(), "Index out of bounds");
236 
237  return frames[frame].GetImage();
238  }
239 
242  unsigned FrameIndexAt(unsigned time) const {
243  ASSERT(frames.size(), "Animation is empty");
244 
245  int i = 0;
246  for(auto f : frames) {
247  if(f.GetEnd() >= time)
248  return i;
249 
250  i++;
251  }
252 
253  return i-1;
254  }
255 
257  const F_ &FrameAt(int index) const override {
258  ASSERT(index>=0 && index<(int)frames.size(), "Index out of bounds");
259 
260  return frames[index];
261  }
262 
264  unsigned StartOf(unsigned frame) const override {
265  return frames[frame].GetStart();
266  }
267 
269  unsigned GetDuration() const override {
270  return duration;
271  }
272 
274  unsigned GetDuration(unsigned frame) const override {
275  ASSERT(frame>=0 && frame<frames.size(), "Index out of bounds");
276 
277  return frames[frame].GetDuration();
278  }
279 
281  void Add(T_ &image, unsigned duration = 42, bool own = false) {
282  frames.push_back({image, duration, this->duration});
283  this->duration += duration;
284 
285  if(own)
286  destroylist.Push(image);
287  }
288 
291  void Add(T_ &&image, unsigned duration = 42) {
292  destroylist.Push(new T_(std::move(image)));
293  T_ &img = *destroylist.Last();
294  frames.push_back({img, duration, this->duration});
295  this->duration += duration;
296  }
297 
298  void Add(const F_ &frame) {
299  frames.push_back(frame);
300  frames.back().start = duration;
301  duration += frame.duration;
302  }
303 
304  void Add(const Gorgon::Animation::Frame &frame) override {
305  if(dynamic_cast<const F_*>(&frame) == nullptr)
306  throw std::runtime_error("Wrong frame type.");
307 
308  Add(dynamic_cast<const F_&>(frame));
309  }
310 
312  void Insert(T_ &image, int before, unsigned duration = 42) {
313  if(before < 0)
314  before += frames.size();
315 
316  if(before > frames.size()) before = frames.size();
317 
318  frames.insert(frames.begin()+before, {image, duration, frames[before].GetStart()});
319 
320  for(unsigned i=before+1; i<frames.size(); i++) {
321  frames[i].start=frames[i-1].GetEnd();
322  }
323 
324  this->duration += duration;
325  }
326 
328  void Insert(T_ &&img, int before, unsigned duration = 42) {
329  if(before < 0)
330  before += frames.size();
331 
332  if(before > frames.size()) before = frames.size();
333 
334  destroylist.Push(new T_(std::move(img)));
335  T_ &image = *destroylist.Last();
336 
337  frames.insert(frames.begin()+before, {image, duration, frames[before].GetStart()});
338 
339  for(unsigned i=before+1; i<frames.size(); i++) {
340  frames[i].start=frames[i-1].GetEnd();
341  }
342 
343  this->duration += duration;
344  }
345 
347  void Insert(const F_ &frm, int before) {
348  auto frame = frm;
349 
350  if(before < 0)
351  before += (int)frames.size();
352 
353  if((unsigned)before > frames.size()) before = (int)frames.size();
354 
355  if((unsigned)before == frames.size())
356  frame.start = duration;
357  else
358  frame.start = frames[before].start;
359 
360  frames.insert(frames.begin()+before, frame);
361 
362  for(unsigned i=before+1; i<frames.size(); i++) {
363  frames[i].start=frames[i-1].GetEnd();
364  }
365 
366  this->duration += duration;
367  }
368 
370  void Insert(const Gorgon::Animation::Frame &frame, int before) override {
371  if(dynamic_cast<const F_*>(&frame) == nullptr)
372  throw std::runtime_error("Wrong frame type.");
373 
374  Insert(dynamic_cast<const F_&>(frame), before);
375  }
376 
378  void MoveBefore(unsigned index, int before) override {
379  if(before < 0)
380  before += (int)frames.size();
381 
382  if((unsigned)before >= frames.size()) {
383  auto tmp = frames[index];
384  frames.erase(frames.begin()+index);
385  frames.push_back(tmp);
386  }
387  else if(index < (unsigned)before) {
388  std::rotate(frames.begin()+index, frames.begin()+index+1, frames.begin()+before);
389  }
390  else if((unsigned)before < index) {
391  std::rotate(frames.rbegin()+(frames.size()-1-index), frames.rbegin()+(frames.size()-1-index)+1, frames.rbegin()+(frames.size()-1-before));
392  }
393  }
394 
396  void Own(T_ &image) {
397  destroylist.Add(image);
398  }
399 
401  void Remove(unsigned frame) override {
402  ASSERT(frame>=0 && frame < frames.size(), "Index out of bounds");
403 
404  duration -= (frames.begin() + frame)->GetDuration();
405  frames.erase(frames.begin() + frame);
406  }
407 
409  void Clear() override {
410  frames.clear();
411  duration = 0;
412  }
413 
415  void ReleaseAll() {
416  destroylist.Clear();
417  }
418 
421  frames(it);
422  }
423 
426  return frames.begin();
427  }
428 
431  return frames.begin();
432  }
433 
436  return frames.end();
437  }
438 
440  ConstIterator end() const {
441  return frames.end();
442  }
443 
444  protected:
445  std::vector<basic_AnimationFrame<T_>> frames;
446  unsigned duration = 0;
448 
449  private:
450 
451  void swapout(basic_TextureAnimationProvider &other) {
452  using std::swap;
453 
454  swap(frames, other.frames);
455  swap(duration, other.duration);
456  swap(destroylist, other.destroylist);
457  }
458 
459  template<class N_, class R_ = T_>
460  typename std::enable_if<std::is_const<R_>::value, void>::type
461  swapout(basic_TextureAnimationProvider<typename std::remove_const<T_>::type, A_, N_> &other) {
462  duration = 0;
463 
464  for(auto &frame : other) {
465  Add(frame.GetImage(), frame.GetDuration());
466  Own(frame.GetImage());
467  }
468 
469  other.ReleaseAll();
470  other.Clear();
471  }
472 
473  };
474 
475  template<class T_, class P_, class F_>
477  if(!controller) return false;
478 
479  if(parent->GetCount()==0) return false;
480 
481 
482  unsigned progress=controller->GetProgress();
483 
484 
485  if(controller->IsControlled()) {
486  if(progress>parent->GetDuration()) {
487  current=parent->GetCount()-1;
488  leftover=progress-parent->GetDuration();
489 
490  return false;
491  }
492  else {
493  current=parent->FrameIndexAt(progress);
494 
495  return true;
496  }
497  }
498  else {
499  current = parent->FrameIndexAt(progress % parent->GetDuration());
500 
501  return true;
502  }
503  }
504 
505  template<>
507  public:
509 
510  void Prepare() {
511  auto &me = dynamic_cast<DiscreteAnimationProvider&>(*this);
512  int c = me.GetCount();
513  for(int i=0; i<c; i++) {
514  auto img = dynamic_cast<const basic_AnimationFrame<Bitmap>&>(me[i]);
515  img.GetImage().Prepare();
516  }
517  }
518  };
519 
521 
523 
525 
527 
529 
531 
533 
535 
536 } }
Gorgon::Graphics::basic_TextureAnimationProvider::CreateAnimation
virtual AnimationType & CreateAnimation(Gorgon::Animation::ControllerBase &controller) const override
Creates a new animation from this resource.
Definition: TextureAnimation.h:214
Gorgon::Graphics::basic_TextureAnimationProvider::GetHeight
int GetHeight() const
Returns the size of the first image.
Definition: TextureAnimation.h:193
Gorgon::Graphics::basic_TextureAnimationProvider::Iterator
typename std::vector< basic_AnimationFrame< T_ > >::iterator Iterator
Definition: TextureAnimation.h:139
Gorgon::swap
void swap(Event< Source_, Args_... > &l, Event< Source_, Args_... > &r)
Swaps two events.
Definition: Event.h:351
Gorgon::Graphics::basic_TextureAnimationProvider::MoveBefore
void MoveBefore(unsigned index, int before) override
Moves a frame that has the index before the given position.
Definition: TextureAnimation.h:378
Gorgon::Animation::Base::Base
Base(ControllerBase &controller)
Sets the controller for this animation to the given controller.
Definition: Animation.h:310
Gorgon::Graphics::basic_TextureAnimationProvider::Insert
void Insert(T_ &&img, int before, unsigned duration=42)
Inserts the given image before the given frame.
Definition: TextureAnimation.h:328
Gorgon::Graphics::basic_TextureAnimationProvider::basic_TextureAnimationProvider
basic_TextureAnimationProvider(const basic_TextureAnimationProvider &)=delete
Gorgon::Graphics::basic_TextureAnimation::basic_TextureAnimation
basic_TextureAnimation(const ParentType &parent, Gorgon::Animation::ControllerBase &controller)
Creates a new image animation from the given parent.
Definition: TextureAnimation.h:65
Gorgon::Graphics::basic_TextureAnimationProvider::Add
void Add(const Gorgon::Animation::Frame &frame) override
Definition: TextureAnimation.h:304
Gorgon::Graphics::basic_TextureAnimationInjection< Bitmap >::Prepare
void Prepare()
Definition: TextureAnimation.h:510
Gorgon::Graphics::basic_TextureAnimationProvider
Definition: TextureAnimation.h:137
Gorgon::Graphics::ColorMode
ColorMode
Color modes for images.
Definition: Color.h:16
Gorgon::Graphics::basic_TextureAnimation::GetImageSize
virtual Geometry::Size GetImageSize() const override
Should return the size of the image stored in texture. Not the whole texture size.
Definition: TextureAnimation.h:94
Gorgon::Graphics::basic_TextureAnimation::basic_TextureAnimation
basic_TextureAnimation(const ParentType &parent, bool create)
Creates a new image animation from the given parent.
Definition: TextureAnimation.h:69
Gorgon::Graphics::basic_TextureAnimationProvider::end
Iterator end()
Returns an iterator to the end of the animation frames.
Definition: TextureAnimation.h:435
Gorgon::Graphics::basic_TextureAnimationProvider::AnimationType
basic_TextureAnimation< T_, basic_TextureAnimationProvider< T_, A_, F_ >, F_ > AnimationType
Definition: TextureAnimation.h:141
Gorgon::Graphics::basic_TextureAnimationInjection::~basic_TextureAnimationInjection
virtual ~basic_TextureAnimationInjection()
Definition: TextureAnimation.h:13
Gorgon::Graphics::basic_AnimationFrame::GetDuration
unsigned GetDuration() const override
Returns the duration of this frame.
Definition: TextureAnimation.h:29
Gorgon::Animation::ControllerBase
Controllers are required to progress animations.
Definition: Animation.h:65
Gorgon::Graphics::basic_TextureAnimation::Progress
virtual bool Progress(unsigned &leftover) override
This function should progress the animation.
Definition: TextureAnimation.h:476
Gorgon::Graphics::basic_TextureAnimationProvider::ReleaseAll
void ReleaseAll()
Releases ownership of all images in the animation without destroying them.
Definition: TextureAnimation.h:415
Gorgon::Graphics::basic_TextureAnimationProvider::destroylist
Containers::Collection< T_ > destroylist
Definition: TextureAnimation.h:447
Gorgon::Graphics::ColorMode::RGBA
@ RGBA
32bit red, green, blue and alpha channel image. Red component is in the lowest byte order and
Gorgon::Graphics::basic_TextureAnimationProvider::FrameAt
const F_ & FrameAt(int index) const override
Returns the frame at specific point.
Definition: TextureAnimation.h:257
Gorgon::Graphics::basic_TextureAnimationProvider::~basic_TextureAnimationProvider
~basic_TextureAnimationProvider()
Definition: TextureAnimation.h:172
Gorgon::Graphics::basic_TextureAnimationProvider::GetWidth
int GetWidth() const
Returns the size of the first image.
Definition: TextureAnimation.h:185
Gorgon::Graphics::basic_AnimationFrame::IsIn
bool IsIn(unsigned time) const override
Returns if the given time is within this frame.
Definition: TextureAnimation.h:44
Gorgon::Graphics::basic_AnimationFrame
Definition: TextureAnimation.h:21
Gorgon::Graphics::basic_TextureAnimationProvider::Insert
void Insert(const Gorgon::Animation::Frame &frame, int before) override
Inserts the given image before the given frame.
Definition: TextureAnimation.h:370
Gorgon::Graphics::basic_TextureAnimation::GetID
virtual GL::Texture GetID() const override
Should return GL::Texture to be drawn. This could be 0 to denote no texture is to be used.
Definition: TextureAnimation.h:83
Gorgon::Graphics::basic_TextureAnimationProvider::StartOf
unsigned StartOf(unsigned frame) const override
Returns the starting time of the given frame.
Definition: TextureAnimation.h:264
Gorgon::Graphics::basic_TextureAnimationProvider::ConstIterator
typename std::vector< basic_AnimationFrame< T_ > >::const_iterator ConstIterator
Definition: TextureAnimation.h:140
Gorgon::Utils::ASSERT_FALSE
void ASSERT_FALSE(const std::string &message, int skip=1, int depth=4)
Definition: Assert.h:192
Gorgon::Graphics::basic_AnimationFrame::GetStart
unsigned GetStart() const override
Returns the starting time of this frame.
Definition: TextureAnimation.h:34
Gorgon::Graphics::DiscreteAnimationProvider
This class provides discrete and rectangular animation which is suitable for bitmap and texture anima...
Definition: Animations.h:71
Gorgon::Graphics::basic_TextureAnimationProvider::Add
void Add(T_ &&image, unsigned duration=42)
Adds the given image to the end of the animation.
Definition: TextureAnimation.h:291
Gorgon::Graphics::basic_TextureAnimation::ParentType
P_ ParentType
Definition: TextureAnimation.h:61
Gorgon
Root namespace for Gorgon Game Engine.
Definition: Any.h:19
Gorgon::Geometry::basic_Size
This class represents a 2D geometric size.
Definition: Size.h:23
Gorgon::Animation::DiscreteProvider::GetCount
virtual int GetCount() const =0
Returns number of frames.
Gorgon::Graphics::basic_TextureAnimation::GetMode
virtual ColorMode GetMode() const override
Definition: TextureAnimation.h:105
Gorgon::Graphics::basic_AnimationFrame::GetImage
T_ & GetImage() const
Returns the image for this frame.
Definition: TextureAnimation.h:49
Gorgon::Graphics::basic_AnimationFrame::basic_AnimationFrame
basic_AnimationFrame(T_ &image, unsigned duration=42, unsigned start=0)
Definition: TextureAnimation.h:25
Gorgon::Graphics::basic_TextureAnimationInjection< Bitmap >::~basic_TextureAnimationInjection
virtual ~basic_TextureAnimationInjection()
Definition: TextureAnimation.h:508
Gorgon::Graphics::Image
This is an interface for solid texture based image.
Definition: Drawables.h:511
Gorgon::Graphics::basic_TextureAnimation::CurrentFrame
unsigned CurrentFrame() const override
Returns the current frame.
Definition: TextureAnimation.h:127
Gorgon::Graphics::basic_TextureAnimationProvider::basic_TextureAnimationProvider
basic_TextureAnimationProvider()=default
Bitmap.h
ASSERT
#define ASSERT(expression, message,...)
Replaces regular assert to allow messages and backtrace.
Definition: Assert.h:161
Gorgon::Containers::Collection
Collection is a container for reference typed objects.
Definition: Collection.h:21
Gorgon::Graphics::Bitmap
This object contains an bitmap image.
Definition: Bitmap.h:25
Gorgon::Graphics::basic_TextureAnimationProvider::GetSize
Geometry::Size GetSize() const override
Returns the size of the first image.
Definition: TextureAnimation.h:201
Gorgon::Graphics::basic_AnimationFrame::GetEnd
unsigned GetEnd() const override
Returns the ending time of this frame.
Definition: TextureAnimation.h:39
Gorgon::Graphics::basic_TextureAnimationProvider::CreateAnimation
virtual AnimationType & CreateAnimation(bool create=true) const override
Creates a new animation from this resource.
Definition: TextureAnimation.h:219
Gorgon::Geometry::basic_Point
This class represents a 2D point.
Definition: Point.h:32
Gorgon::Graphics::basic_TextureAnimation::FrameType
F_ FrameType
Definition: TextureAnimation.h:62
Gorgon::Graphics::basic_TextureAnimationProvider::Insert
void Insert(T_ &image, int before, unsigned duration=42)
Inserts the given image before the given frame.
Definition: TextureAnimation.h:312
Gorgon::Graphics::basic_TextureAnimationProvider::MoveOutProvider
virtual auto MoveOutProvider() -> decltype(*this) override
Definition: TextureAnimation.h:154
Gorgon::Graphics::basic_TextureAnimationProvider::Remove
void Remove(ConstIterator it)
Removes an image from the animation.
Definition: TextureAnimation.h:420
Gorgon::Graphics::basic_TextureAnimation::DeleteAnimation
virtual void DeleteAnimation() const override
Deletes this animation object.
Definition: TextureAnimation.h:73
Gorgon::Graphics::basic_TextureAnimationProvider::Insert
void Insert(const F_ &frm, int before)
Inserts the given image before the given frame.
Definition: TextureAnimation.h:347
Gorgon::Graphics::Animation
A regular drawable animation.
Definition: Animations.h:14
Gorgon::Animation::DiscreteAnimation::NoFrame
static const unsigned NoFrame
This variable denotes that this animation has no frame at the moment.
Definition: Discrete.h:16
Animations.h
Gorgon::Graphics::basic_TextureAnimationProvider::operator=
basic_TextureAnimationProvider & operator=(const basic_TextureAnimationProvider &)=delete
Gorgon::Graphics::basic_TextureAnimationProvider::end
ConstIterator end() const
Returns an iterator to the end of the animation frames.
Definition: TextureAnimation.h:440
Gorgon::UI::Graphics
@ Graphics
Definition: Template.h:164
Texture.h
Gorgon::Graphics::basic_TextureAnimationProvider::basic_TextureAnimationProvider
basic_TextureAnimationProvider(C_ &&other)
Definition: TextureAnimation.h:149
Gorgon::Graphics::basic_TextureAnimationProvider::GetDuration
unsigned GetDuration() const override
Returns the duration of the animation.
Definition: TextureAnimation.h:269
Gorgon::Graphics::basic_TextureAnimationProvider::Duplicate
basic_TextureAnimationProvider Duplicate() const
Definition: TextureAnimation.h:176
Gorgon::Graphics::basic_TextureAnimation
Definition: TextureAnimation.h:59
Gorgon::Graphics::DiscreteAnimation
A discrete rectangular animation, this is most suitable for bitmap or texture animations.
Definition: Animations.h:24
Gorgon::Graphics::basic_TextureAnimationProvider::FrameIndexAt
unsigned FrameIndexAt(unsigned time) const
Returns which frame is at the given time.
Definition: TextureAnimation.h:242
Gorgon::Graphics::basic_TextureAnimationInjection
Definition: TextureAnimation.h:11
Gorgon::Graphics::basic_TextureAnimation::GetCoordinates
virtual const Geometry::Pointf * GetCoordinates() const override
Should return the coordinates of the texture to be used.
Definition: TextureAnimation.h:116
Gorgon::Graphics::basic_TextureAnimationProvider::begin
ConstIterator begin() const
Returns an iterator to the beginning of the animation frames.
Definition: TextureAnimation.h:430
Gorgon::Graphics::basic_TextureAnimationProvider::operator[]
T_ & operator[](int frame) const
Returns the image at the given frame.
Definition: TextureAnimation.h:234
Gorgon::Graphics::basic_TextureAnimationProvider::Add
void Add(const F_ &frame)
Definition: TextureAnimation.h:298
Gorgon::Graphics::basic_TextureAnimationProvider::FrameType
F_ FrameType
Definition: TextureAnimation.h:142
Gorgon::Animation::Base::controller
ControllerBase * controller
Controller of this animation.
Definition: Animation.h:388
Gorgon::Graphics::basic_TextureAnimationProvider::begin
Iterator begin()
Returns an iterator to the beginning of the animation frames.
Definition: TextureAnimation.h:425
Gorgon::Graphics::basic_TextureAnimationProvider::GetCount
int GetCount() const override
Returns number of frames.
Definition: TextureAnimation.h:209
Gorgon::Graphics::basic_TextureAnimationProvider::Remove
void Remove(unsigned frame) override
Removes an image from the animation.
Definition: TextureAnimation.h:401
Gorgon::Graphics::basic_TextureAnimationProvider::Own
void Own(T_ &image)
Owns the given image so that it would be destroyed with this animation.
Definition: TextureAnimation.h:396
Gorgon::Graphics::basic_TextureAnimationProvider::duration
unsigned duration
Definition: TextureAnimation.h:446
Gorgon::Graphics::basic_TextureAnimationProvider::frames
std::vector< basic_AnimationFrame< T_ > > frames
Definition: TextureAnimation.h:445
Gorgon::Graphics::basic_TextureAnimation::GetDuration
int GetDuration() const override
Returns the duration of the animation if it is a known apriori.
Definition: TextureAnimation.h:79
Gorgon::Graphics::basic_TextureAnimationProvider::Add
void Add(T_ &image, unsigned duration=42, bool own=false)
Adds the given image to the end of the animation.
Definition: TextureAnimation.h:281
Gorgon::Graphics::basic_TextureAnimationProvider::ImageAt
T_ & ImageAt(unsigned time) const
Returns the image that is to be shown at the given time.
Definition: TextureAnimation.h:225
Gorgon::Graphics::basic_TextureAnimationProvider::Clear
void Clear() override
Removes all images from the animation.
Definition: TextureAnimation.h:409
Gorgon::Graphics::basic_TextureAnimationProvider::GetDuration
unsigned GetDuration(unsigned frame) const override
Returns the duration of the given frame.
Definition: TextureAnimation.h:274
Gorgon::Animation::Frame
This is the base class for a single frame in a discreet animation.
Definition: Discrete.h:20