00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef neo_animation_channel_h
00022 #define neo_animation_channel_h
00023
00029 #include "../core/platform.h"
00030
00031 #if NEO_ENABLE_ANIMATION
00032
00033 #include "../core/hashstring.h"
00034 #include "keyframe.h"
00035
00036 namespace neo {
00037 namespace animation {
00038
00040
00042 class Channel
00043 {
00044 public:
00045
00047
00048 Channel( const std::string& name );
00049
00051 virtual ~Channel();
00052
00054
00058 virtual unsigned int getKeyframeIndex( float time, unsigned int last = 0 ) = 0;
00059
00061
00065 virtual void interpolate( Keyframe* p_dst, float time, unsigned int lastKeyframe ) = 0;
00066
00068
00074 virtual void blend( Keyframe* p_dst, float weight, float time, unsigned int lastKeyframe ) = 0;
00075
00077
00079 virtual Keyframe* allocateKeyframe() const = 0;
00080
00082
00084 virtual void setNumKeyframes( unsigned int num ) = 0;
00085
00087
00088 virtual unsigned int getNumKeyframes() const = 0;
00089
00091
00092 inline const core::HashString& getName() const;
00093
00094 protected:
00095
00097 core::HashString _name;
00098 };
00099
00105 class TransformChannel : public Channel
00106 {
00107 public:
00108
00110
00111 TransformChannel( const std::string& name );
00112
00113 virtual ~TransformChannel();
00114 virtual unsigned int getKeyframeIndex( float time, unsigned int last );
00115 virtual void interpolate( Keyframe* p_dst, float time, unsigned int lastKeyframe );
00116 virtual void blend( Keyframe* p_dst, float weight, float time, unsigned int lastKeyframe );
00117 virtual Keyframe* allocateKeyframe() const;
00118 virtual void setNumKeyframes( unsigned int num );
00119 virtual unsigned int getNumKeyframes() const;
00120
00122
00124 inline const core::Array< TransformKeyframe >& getKeyframes() const;
00125
00127
00130 inline TransformKeyframe* getKeyframe( unsigned int keyframe );
00131
00132 protected:
00133
00135 core::Array< TransformKeyframe > _keyframes;
00136 };
00137
00143 class VectorChannel : public Channel
00144 {
00145 public:
00146
00148
00150 VectorChannel( const std::string& name, unsigned int num = 3 );
00151
00152 virtual ~VectorChannel();
00153 virtual unsigned int getKeyframeIndex( float time, unsigned int last );
00154 virtual void interpolate( Keyframe* p_dst, float time, unsigned int lastKeyframe );
00155 virtual void blend( Keyframe* p_dst, float weight, float time, unsigned int lastKeyframe );
00156 virtual Keyframe* allocateKeyframe() const;
00157 virtual void setNumKeyframes( unsigned int num );
00158 virtual unsigned int getNumKeyframes() const;
00159
00161
00162 void setNumValues( unsigned int num );
00163
00165
00166 inline unsigned int getNumValues() const;
00167
00169
00171 inline const core::Array< VectorKeyframe >& getKeyframes() const;
00172
00174
00177 inline VectorKeyframe* getKeyframe( unsigned int keyframe );
00178
00179 protected:
00180
00182 unsigned int _numValues;
00183
00185 core::Array< VectorKeyframe > _keyframes;
00186 };
00187
00188 #include "channel.inl"
00189
00190 }
00191 }
00192
00193 #endif
00194
00195 #endif