Gorgon Game Engine
Discrete.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "../Animation.h"
4 
5 namespace Gorgon { namespace Animation {
6 
7  // Represents an instance of a discrete animation made out of frames
8  class DiscreteAnimation : public virtual Base {
9  public:
10 
13  virtual unsigned CurrentFrame() const = 0;
14 
16  static const unsigned NoFrame = (unsigned)-1;
17  };
18 
20  class Frame {
21  public:
22  virtual ~Frame() { }
23 
25  virtual unsigned GetDuration() const = 0;
26 
28  virtual unsigned GetStart() const = 0;
29 
31  virtual unsigned GetEnd() const {
32  return GetStart() + GetDuration();
33  }
34 
36  virtual bool IsIn(unsigned time) const {
37  return time >= GetStart() && time < GetEnd();
38  }
39  };
40 
45  class DiscreteProvider : public virtual Provider {
46  public:
49  virtual void Add(const Frame &frame) = 0;
50 
56  virtual void Insert(const Frame &frame, int before) = 0;
57 
62  virtual void MoveBefore(unsigned index, int before) = 0;
63 
65  virtual void Remove(unsigned index) = 0;
66 
68  virtual const Frame &FrameAt(int index) const = 0;
69 
71  const Frame &operator[](int index) const { return FrameAt(index); }
72 
74  virtual unsigned StartOf(unsigned frame) const = 0;
75 
77  virtual unsigned GetDuration() const = 0;
78 
80  virtual unsigned GetDuration(unsigned frame) const = 0;
81 
83  virtual void Clear() = 0;
84 
86  virtual int GetCount() const = 0;
87 
88  protected:
89  };
90 } }
Gorgon::Animation::DiscreteAnimation
Definition: Discrete.h:8
Gorgon::Animation::DiscreteProvider::Clear
virtual void Clear()=0
Clears all frames from this animation.
Gorgon::Animation::DiscreteProvider::MoveBefore
virtual void MoveBefore(unsigned index, int before)=0
Moves the frame with the given index to the specified point the animation.
Gorgon::Animation::Frame::~Frame
virtual ~Frame()
Definition: Discrete.h:22
Gorgon::Animation::Frame::GetStart
virtual unsigned GetStart() const =0
Returns the starting time of this frame.
Gorgon::Animation::DiscreteProvider::StartOf
virtual unsigned StartOf(unsigned frame) const =0
Returns the starting time of the given frame.
Gorgon::Animation::DiscreteProvider::Add
virtual void Add(const Frame &frame)=0
Adds a frame to the end of the animation.
Gorgon
Root namespace for Gorgon Game Engine.
Definition: Any.h:19
Gorgon::Animation::DiscreteProvider::GetCount
virtual int GetCount() const =0
Returns number of frames.
Gorgon::Animation::Provider
This interface marks a class as animation provider.
Definition: Animation.h:283
Gorgon::Animation::Base
This is the base class for all animations.
Definition: Animation.h:306
Gorgon::Animation::DiscreteProvider::Remove
virtual void Remove(unsigned index)=0
Removes the given frame.
Gorgon::Animation::Frame::IsIn
virtual bool IsIn(unsigned time) const
Returns if the given time is within this frame.
Definition: Discrete.h:36
Gorgon::Animation::DiscreteProvider
Provides a discreet animation that is made out of frames.
Definition: Discrete.h:45
Gorgon::Resource::GID::Animation
constexpr Type Animation
Definition: GID.h:187
Gorgon::Animation::DiscreteProvider::FrameAt
virtual const Frame & FrameAt(int index) const =0
Returns the frame at specific point.
Gorgon::Animation::DiscreteProvider::Insert
virtual void Insert(const Frame &frame, int before)=0
Adds a frame to the specified point the animation.
Gorgon::Animation::Frame::GetEnd
virtual unsigned GetEnd() const
Returns the ending time of this frame.
Definition: Discrete.h:31
Gorgon::Animation::DiscreteAnimation::NoFrame
static const unsigned NoFrame
This variable denotes that this animation has no frame at the moment.
Definition: Discrete.h:16
Gorgon::Animation::DiscreteAnimation::CurrentFrame
virtual unsigned CurrentFrame() const =0
Returns the current frame.
Gorgon::Animation::Frame::GetDuration
virtual unsigned GetDuration() const =0
Returns the duration of this frame.
Gorgon::Animation::DiscreteProvider::GetDuration
virtual unsigned GetDuration() const =0
Returns the duration of the animation.
Gorgon::Animation::DiscreteProvider::GetDuration
virtual unsigned GetDuration(unsigned frame) const =0
Returns the duration of the given frame.
Gorgon::Animation::Frame
This is the base class for a single frame in a discreet animation.
Definition: Discrete.h:20
Gorgon::Animation::DiscreteProvider::operator[]
const Frame & operator[](int index) const
Returns the frame at specific point.
Definition: Discrete.h:71