OPTPiX SpriteStudio SDK
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
ssplayer_animedecode.h
1 #ifndef __SSPLAYER_ANIMEDECODE__
2 #define __SSPLAYER_ANIMEDECODE__
3 
4 #include "../loader/ssloader.h"
5 #include "../Helper/ssHelper.h"
6 
7 
8 #include "ssplayer_types.h"
9 #include "ssplayer_cellmap.h"
10 #include "ssplayer_PartState.h"
11 
12 #define foreach(T, c, i) for(T::iterator i = c.begin(); i!=c.end(); ++i)
13 
14 
15 class SsAnimeDecoder;
16 class SsCelMapLinker;
17 
18 
19 //パーツとアニメを関連付ける
20 typedef std::pair<SsPart*,SsPartAnime*> SsPartAndAnime;
21 
22 
23 //パーツのソート順
25 {
26 public:
27  bool operator()(const SsPartState* lhs, const SsPartState* rhs) const
28  {
29  if (lhs->prio == rhs->prio)
30  return lhs->index < rhs->index;
31  return lhs->prio < rhs->prio;
32  }
33 };
34 
35 
36 
38 {
39 public:
40 
41 private:
42 
44  std::vector<SsPartAndAnime> partAnime;
45 
47  std::map<SsString,SsPartAnime*> partAnimeDic;
48 
49  SsCellMapList* curCellMapManager;
50 
51  SsPartState* partState;
52  std::list<SsPartState*> sortList;
53 
54  float nowPlatTime;
55  float frameDelta;
56  int curAnimeEndFrame;
57  int curAnimeFPS;
58  SsAnimation* curAnimation;
59 
60 private:
61  void updateState( int nowTime , SsPart* part , SsPartAnime* part_anime , SsPartState* state );
62  void updateInstance( int nowTime , SsPart* part , SsPartAnime* part_anime , SsPartState* state );
63  void updateMatrix(SsPart* part , SsPartAnime* anime , SsPartState* state);
64  void updateVertices(SsPart* part , SsPartAnime* anime , SsPartState* state);
65 
66  int CalcAnimeLabel2Frame(const SsString& str, int offset );
67  int findAnimetionLabel(const SsString& str);
68 
69 
70 public:
72  virtual ~SsAnimeDecoder()
73  {
74  if ( curCellMapManager )
75  delete curCellMapManager;
76 
77  if ( partState )
78  delete [] partState;
79  }
80 
81  virtual void update();
82  virtual void draw();
83 
84  void setAnimation( SsModel* model , SsAnimation* anime , SsCellMapList* cellmap , SsProject* sspj=0 );
85 
86  void setPlayFrame( float time ) { nowPlatTime = time; }
87  int getAnimeEndFrame() { return curAnimeEndFrame; }
88  int getAnimeFPS() {
89  return curAnimeFPS; }
90 
91 
92  std::list<SsPartState*>& getPartSortList(){return sortList;}
93  std::vector<SsPartAndAnime>& getPartAnime(){ return partAnime; }
94 
95  template<typename mytype> int SsGetKeyValue( int time , SsAttribute* attr , mytype& value );
96  template<typename mytype> void SsInterpolationValue( int time , const SsKeyframe* leftkey , const SsKeyframe* rightkey , mytype& v );
97  void SsInterpolationValue( int time , const SsKeyframe* leftkey , const SsKeyframe* rightkey , SsCellValue& v );
98  void SsInterpolationValue( int time , const SsKeyframe* leftkey , const SsKeyframe* rightkey , SsColorAnime& v );
99  void SsInterpolationValue( int time , const SsKeyframe* leftkey , const SsKeyframe* rightkey , SsVertexAnime& v );
100 
101 
102 
103 };
104 
105 
106 
107 #endif