Oxygine  1
2g game engine
AnimationFrame.h
1 #pragma once
2 #include "oxygine-include.h"
3 #include "math/Rect.h"
4 #include "core/Texture.h"
5 #include "core/NativeTexture.h"
6 
7 namespace oxygine
8 {
9  class Diffuse
10  {
11  public:
12  Diffuse(): premultiplied(true) {}
13  spNativeTexture base;
14  spNativeTexture alpha;
15  bool premultiplied;
16  };
17 
19  {
20  public:
21  HitTestData(): data(0), w(0), h(0), pitch(0) {}
22 
23  const unsigned char* data;
24  short w, h;
25  unsigned char pitch;
26  };
27 
29  {
30  public:
31  AnimationFrame() : _srcRect(0, 0, 1, 1), _destRect(0, 0, 1, 1), _resAnim(0), _row(0), _column(0) {}
32  AnimationFrame(spNativeTexture t);
33 
34  void init(ResAnim* rs, const Diffuse& df,
35  const RectF& srcRect, const RectF& destRect, const Vector2& frame_size);
36  void init2(ResAnim* rs, short column, short row, const Diffuse& df,
37  const RectF& srcRect, const RectF& destRect, const Vector2& frame_size);
39  AnimationFrame getClipped(const RectF& rect) const;
40  AnimationFrame getFlipped(bool vertical, bool horizontal) const;
41 
43  const Vector2& getSize() const {return _frameSize;}
44  float getWidth() const {return _frameSize.x;}
45  float getHeight() const {return _frameSize.y;}
46 
47  ResAnim* getResAnim() const {return _resAnim;}
48  short getColumn() const {return _column;}
49  short getRow() const {return _row;}
50  const RectF& getSrcRect() const {return _srcRect;}
51  const RectF& getDestRect() const {return _destRect;}
52  const Diffuse& getDiffuse() const {return _diffuse;}
53  const HitTestData& getHitTestData()const { return _hittest; }
54 
55  void setSrcRect(const RectF& r) {_srcRect = r;}
56  void setDestRect(const RectF& r) {_destRect = r;}
57  void setResAnim(ResAnim* rs) {_resAnim = rs;}
58  void setDiffuse(const Diffuse& d) { _diffuse = d; }
59  void setSize(const Vector2& size) {_frameSize = size;}
60  void setSize(float w, float h) { setSize(Vector2(w, h)); }
61  void setHitTestData(const HitTestData& ad) { _hittest = ad; }
62  void setRow(int v) {_row = v;}
63  void setColumn(int v) {_column = v;}
64 
65  void flipX();
66  void flipY();
67 
68  private:
69  enum flags
70  {
71  clipped = 0x01,
72  };
73 
74  Diffuse _diffuse;
75 
76  RectF _srcRect;
77  RectF _destRect;
78  Vector2 _frameSize;//real size without clipping
79  ResAnim* _resAnim;
80  short _row;
81  short _column;
82 
83  HitTestData _hittest;
84  //unsigned short _flags;
85  };
86 }
const Vector2 & getSize() const
Definition: AnimationFrame.h:43
Definition: AnimationFrame.h:18
Definition: AnimationFrame.h:28
–oxgl-end–!
Definition: Actor.h:14
AnimationFrame getClipped(const RectF &rect) const
Definition: ResAnim.h:13
Definition: AnimationFrame.h:9