00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef neo_animation_animation_h
00022 #define neo_animation_animation_h
00023
00029 #include "../core/platform.h"
00030
00031 #if NEO_ENABLE_ANIMATION
00032
00033 #include "../core/pointer.h"
00034 #include "../core/array.h"
00035 #include "../core/hashstring.h"
00036 #include "../core/resource.h"
00037 #include "../math/core.h"
00038
00039 namespace neo {
00040 namespace animation {
00041
00042 class Channel;
00043 class Keyframe;
00044
00046
00048 class Animation : public core::RefCount, public core::Resource
00049 {
00050 public:
00051
00053
00054 Animation( const std::string& name );
00055
00057 virtual ~Animation();
00058
00060 float _length;
00061
00063 core::HashTable< std::string, Channel* > _channels;
00064 };
00065
00066 NEO_DECLARE_SMARTPOINTER( Animation )
00067
00068
00069
00071 class AnimationInstance
00072 {
00073 public:
00074
00076
00078 AnimationInstance( const AnimationPtr& p_anim );
00079
00081
00082 AnimationInstance( const AnimationInstance& instance );
00083
00085 virtual ~AnimationInstance();
00086
00088
00090 void update( float dt );
00091
00093
00095 void interpolate( core::HashTable< std::string, Keyframe* >& dest );
00096
00098
00101 void blend( core::HashTable< std::string, Keyframe* >& dest, float weight );
00102
00104
00106 void setAnimation( const AnimationPtr& p_anim );
00107
00109
00111 inline const AnimationPtr& getAnimation() const;
00112
00114
00116 inline void reset( float time = 0.0f );
00117
00119
00121 inline void play( bool play = true );
00122
00124
00126 inline void loop( bool loop = true );
00127
00129
00131 inline float getCurrentTime() const;
00132
00134
00135 inline bool isLooping() const;
00136
00138
00139 inline bool isPlaying() const;
00140
00142
00143 inline bool isLooped() const;
00144
00145 protected:
00146
00148 AnimationPtr _p_animation;
00149
00151 core::Array< unsigned int > _keyframeIndex;
00152
00154 float _time;
00155
00157 float _timeNorm;
00158
00160 bool _loop;
00161
00163 bool _play;
00164
00166 bool _looped;
00167 };
00168
00169 #include "animation.inl"
00170
00171 }
00172 }
00173
00174 #endif
00175
00176 #endif