Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __SP_ANIMATION_H__
00009 #define __SP_ANIMATION_H__
00010
00011
00012 #include "Base/spStandard.hpp"
00013 #include "SceneGraph/spSceneNode.hpp"
00014 #include "SceneGraph/Animation/spAnimationPlayback.hpp"
00015
00016 #include <list>
00017
00018
00019 namespace sp
00020 {
00021 namespace scene
00022 {
00023
00024
00026 enum EAnimationTypes
00027 {
00028 ANIMATION_NODE,
00029 ANIMATION_MORPHTARGET,
00030 ANIMATION_SKELETAL,
00031 };
00032
00034 enum EAnimationFlags
00035 {
00036 ANIMFLAG_NO_GROUPING = 0x01,
00037 ANIMFLAG_NO_TRANSFORMATION = 0x02,
00038 };
00039
00040
00048 class SP_EXPORT Animation
00049 {
00050
00051 public:
00052
00053 virtual ~Animation();
00054
00055
00056
00066 virtual bool play(const EAnimPlaybackModes Mode, u32 FirstFrame = 0, u32 LastFrame = ANIM_LAST_FRAME);
00067
00069 virtual void pause(bool IsPaused = true);
00070
00072 virtual void stop(bool IsReset = false);
00073
00075 virtual void clearKeyframes() = 0;
00076
00078 virtual void setFrame(u32 Index);
00079
00081 virtual void updateAnimation(SceneNode* Node) = 0;
00082
00084 virtual u32 getKeyframeCount() const = 0;
00085
00087 virtual void interpolate(u32 IndexFrom, u32 IndexTo, f32 Interpolation) = 0;
00088
00090 virtual bool interpolateRange(u32 FirstFrame, u32 LastFrame, f32 Interpolation);
00091
00093 virtual void interpolateBlended(
00094 const AnimationPlayback &PlaybackFrom, const AnimationPlayback &PlaybackTo, f32 BlendingFactor
00095 );
00096
00101 virtual void addSceneNode(SceneNode* Object);
00102
00104 virtual void removeSceneNode(SceneNode* Object);
00105
00107 virtual void clearSceneNodes();
00108
00114 virtual void copy(const Animation* Other) = 0;
00115
00116
00117
00119 inline EAnimationTypes getType() const
00120 {
00121 return Type_;
00122 }
00123
00125 inline void setName(const io::stringc &Name)
00126 {
00127 Name_ = Name;
00128 }
00130 inline io::stringc getName() const
00131 {
00132 return Name_;
00133 }
00134
00139 inline void setFlags(s32 Flags)
00140 {
00141 Flags_ = Flags;
00142 }
00144 inline s32 getFlags() const
00145 {
00146 return Flags_;
00147 }
00148
00150 inline bool playing() const
00151 {
00152 return Playback_.playing();
00153 }
00154
00156 inline u32 getFrame() const
00157 {
00158 return Playback_.getFrame();
00159 }
00160
00162 inline u32 getMinFrame() const
00163 {
00164 return MinFrame_;
00165 }
00167 inline u32 getMaxFrame() const
00168 {
00169 return MaxFrame_;
00170 }
00171
00173 inline void setInterpolation(f32 Interpolation)
00174 {
00175 Playback_.setInterpolation(Interpolation);
00176 }
00178 inline f32 getInterpolation() const
00179 {
00180 return Playback_.getInterpolation();
00181 }
00182
00184 inline EAnimPlaybackModes getPlaybackMode() const
00185 {
00186 return Playback_.getMode();
00187 }
00188
00190 inline void setSpeed(f32 Speed)
00191 {
00192 Playback_.setSpeed(Speed);
00193 }
00194 inline f32 getSpeed() const
00195 {
00196 return Playback_.getSpeed();
00197 }
00198
00200 inline const AnimationPlayback& getPlayback() const
00201 {
00202 return Playback_;
00203 }
00205 inline AnimationPlayback& getPlayback()
00206 {
00207 return Playback_;
00208 }
00209
00211 inline const std::list<SceneNode*>& getSceneNodeList() const
00212 {
00213 return SceneNodes_;
00214 }
00215
00216 protected:
00217
00218
00219
00220 Animation(const EAnimationTypes Type);
00221
00223 virtual void updatePlayback(f32 Speed);
00224
00226 u32 getValidFrame(u32 Index) const;
00227
00228 void copyBase(const Animation* Other);
00229
00230
00231
00232 u32 MinFrame_, MaxFrame_;
00233
00234 AnimationPlayback Playback_;
00235
00236 s32 Flags_;
00237
00238 private:
00239
00240
00241
00242 EAnimationTypes Type_;
00243 io::stringc Name_;
00244
00245 std::list<SceneNode*> SceneNodes_;
00246
00247 };
00248
00249
00250 }
00251
00252 }
00253
00254
00255 #endif
00256
00257
00258
00259