OpenPolygon  1.0.0
OpenPolygon is a Rendering Engine
animationmanager.h
1 /*
2  Copyright (C) 2014 - 2016 Mutzii
3 
4  This program is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 */
18 #ifndef ANIMATIONMANAGER_H
19 #define ANIMATIONMANAGER_H
20 
21 #include "index.h"
22 #include "animation.h"
23 #include "mesh.h"
24 #include "nodeanimscene.h"
25 
26 namespace Engine
27 {
28  /* FLIP Position Coord: Y-Achse to Z-Achse & Z-Achse to Y-Achse */
29  static const int POS_FLIP_YZ = 0x1;
30 
31  /* FLIP Rotation Coord: Y-Achse to Z-Achse & Z-Achse to Y-Achse */
32  static const int ROT_FLIP_YZ = 0x2;
33 
34  /* Make absolute Coordinates */
35  static const int ABS_POSITIONS = 0x4;
36 
41  {
42  public:
43 
44  friend class AnimationManager;
45 
46  AnimationLoader( const std::string & extension );
47  virtual ~AnimationLoader(){}
48 
55  virtual void ReadFile( const std::string & motion_file , NodeAnimScene * node_anim_scene )=0;
56 
57  protected:
58 
59  unsigned int mFlags;
60  std::string mExtension;
61  };
62 
63 
67  class AnimationManager : public Arch::ITempDatabase<Animation>
68  {
69  public:
70 
71  /* Map of Animations with Component IDs */
72  using AnimationMap = std::map< uint , Animation * >;
73 
74  /* List of Animation Loaders */
75  using AnimLoaderList = std::list< AnimationLoader * >;
76 
77  public:
79  ~AnimationManager() = default;
80 
81  void prepareVBO( Animation * anim , Mesh * mesh );
82 
83  void AddTransformations( Animation * anim , Mesh * mesh );
84 
94  Animation * createAnimation( const std::string & animation_name ,
95  const std::string & motion_file ,
96  Mesh * mesh ) throw( std::runtime_error );
97 
98 
99  void CreateBones( Animation * animation , const std::string & motion_file );
100 
101 
108  Animation * getAnimation( uint component_id );
109 
115  void destroy( uint component_id );
116 
117 
118  /* Animation Importer Include */
119 
127  const NodeAnimScene * ReadFile( const std::string & motion_file , unsigned int flags );
128 
135  bool IsExtensionSupported( const std::string & extension );
136 
142  void registerLoader( AnimationLoader * loader );
143 
144  protected:
145 
151  void addExtensionSupport( const std::string & extension );
152 
159  void prepareAnimation( Animation * anim , Mesh * mesh );
160 
161  private:
162 
163  AnimationMap mAnimationMap;
165  /* Importer */
166  Strings mExtensions;
167  AnimLoaderList mAnimationLoaders;
168  NodeAnimScene mNodeScene;
169  };
170 
171 
172 }
173 #endif // ANIMATIONMANAGER_H
Definition: element.h:23
The AnimationManager controlled Animations.
Definition: animationmanager.h:67
Animation * getAnimation(uint component_id)
getAnimation
Definition: AnimationManager.cpp:342
void destroy(uint component_id)
remove
Definition: AnimationManager.cpp:349
void addExtensionSupport(const std::string &extension)
addExtensionSupport
Definition: AnimationManager.cpp:372
void registerLoader(AnimationLoader *loader)
registerLoader
Definition: AnimationManager.cpp:366
The AnimationLoader is a interface class for custom Loader specifically for Animations.
Definition: animationmanager.h:40
void prepareVBO(Animation *anim, Mesh *mesh)
AnimationManager::prepareVBO.
Definition: AnimationManager.cpp:39
unsigned int mFlags
Definition: animationmanager.h:59
const NodeAnimScene * ReadFile(const std::string &motion_file, unsigned int flags)
ReadFile.
Definition: AnimationManager.cpp:377
bool IsExtensionSupported(const std::string &extension)
IsExtensionSupported.
Definition: AnimationManager.cpp:355
The Mesh class.
Definition: mesh.h:32
virtual void ReadFile(const std::string &motion_file, NodeAnimScene *node_anim_scene)=0
ReadFile.
Animation * createAnimation(const std::string &animation_name, const std::string &motion_file, Mesh *mesh)
createAnimation
Definition: AnimationManager.cpp:257
std::string mExtension
Definition: animationmanager.h:60
The NodeAnimScene class.
Definition: nodeanimscene.h:36
The Animation class.
Definition: animation.h:32
void prepareAnimation(Animation *anim, Mesh *mesh)
createBoneIndex
Definition: AnimationManager.cpp:161