00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef neo_animation_animator_h
00022 #define neo_animation_animator_h
00023
00028 #include "../core/platform.h"
00029
00030 #if NEO_ENABLE_ANIMATION
00031
00032 #include "../core/array.h"
00033 #include "../core/hashtable.h"
00034 #include "animation.h"
00035 #include "blend.h"
00036 #include "sequence.h"
00037
00038 namespace neo {
00039 namespace animation {
00040
00041 class Keyframe;
00042
00044
00046 class Animator
00047 {
00048 public:
00049
00051 Animator();
00052
00054
00055 Animator( const Animator& animator );
00056
00058 virtual ~Animator();
00059
00061
00064 void addAnimation( const std::string& name, const AnimationPtr& p_anim );
00065
00067
00070 AnimationPtr getAnimation( const std::string& name ) const;
00071
00073
00075 inline const core::HashTable< std::string, AnimationPtr >& getAnimations() const;
00076
00078
00081 void addSequence( const std::string& name, const Sequence& sequence );
00082
00084
00087 Sequence* getSequence( const std::string& name );
00088
00090
00094 void setBlendChainDepth( unsigned int depth );
00095
00097
00098 inline unsigned int getBlendChainDepth() const;
00099
00101
00103 void playSequence( const std::string& name );
00104
00106
00108 void pauseSequence();
00109
00111
00112 void resumeSequence();
00113
00115
00116 void stopSequence();
00117
00119
00123 void playAnimation( unsigned int stage, const std::string& name, bool loop );
00124
00126
00130 void pauseAnimation( unsigned int stage );
00131
00133
00135 void resumeAnimation( unsigned int stage );
00136
00138
00140 void stopAnimation( unsigned int stage );
00141
00143
00144 virtual void update( float dt );
00145
00147
00148 virtual void blend();
00149
00151
00153 AnimationInstance* getStageAnimation( unsigned int stage );
00154
00156
00158 float getStageWeight( unsigned int stage );
00159
00161
00163 void setStageWeight( unsigned int stage, float weight );
00164
00166
00168 float getStageTimeScale( unsigned int stage );
00169
00171
00173 void setStageTimeScale( unsigned int stage, float scale );
00174
00176
00177 void setStageTimeScaleAll( float scale );
00178
00180
00182 std::string getStageAnimationName( unsigned int stage );
00183
00185
00186 unsigned int getNumActiveStages() const;
00187
00189
00192 inline const Keyframe* getAnimationChannel( const core::HashString& channel ) const;
00193
00195
00196 bool isSequencePlaying() const;
00197
00199
00202 Animator& operator = ( const Animator& animator );
00203
00204 private:
00205
00207 core::HashTable< std::string, AnimationPtr > _animations;
00208
00210 core::Array< BlendStage* > _blend;
00211
00213 core::HashTable< std::string, Keyframe* > _keyframes;
00214
00216 bool _dirtyBlend;
00217
00219 core::HashTable< std::string, Sequence > _sequences;
00220
00222 Sequence* _p_sequence;
00223
00225 bool _sequencePaused;
00226
00228 bool _initSequenceAction;
00229
00231 bool _isSequenceProcess;
00232 };
00233
00234 #include "animator.inl"
00235
00236 }
00237 }
00238
00239 #endif
00240
00241 #endif