Project

General

Profile

SO3Engine
SO3Anim.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OpenSpace3D
4For the latest info, see http://www.openspace3d.com
5
6Copyright (c) 2012 I-maginer
7
8This program is free software; you can redistribute it and/or modify it under
9the terms of the GNU Lesser General Public License as published by the Free Software
10Foundation; either version 2 of the License, or (at your option) any later
11version.
12
13This program is distributed in the hope that it will be useful, but WITHOUT
14ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16
17You should have received a copy of the GNU Lesser General Public License along with
18this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20http://www.gnu.org/copyleft/lesser.txt
21
22-----------------------------------------------------------------------------
23*/
24
32#ifndef __SO3_ANIM_H__
33#define __SO3_ANIM_H__
34
37
38namespace SO3
39{
40
41class SAnim : public SData
42{
43public:
64protected:
65 Ogre::Animation* ogreAnimation;
68private:
69 SAnimationFrameListener* ogreAnimationFrameListener;
70 const AnimType type;
71 float mSpeed;
72 float mWeight;
73 bool mLoop;
74 bool isPaused;
75 bool skipFrame;
76 SNode* associatedNode;
77 unsigned short animationIndex;
78 unsigned short bUpdatedBySequence;
79public:
80 // No public constructors, class must be derivated
81
84 virtual ~SAnim();
85
88 Ogre::Animation* GetOgreAnimationPointer();
89
93
97
101
104 bool IsSequenceUpdated();
105
108 void SetSequenceUpdated(const bool& value);
109
112 unsigned short GetIndex();
113
118 SAnimTrack* CreateAnimationTrack(const std::string& newAnimationTrackName);
119
126 void DeleteAnimationTrack(SAnimTrack* existingAnimationTrack);
127
130 unsigned short GetNumAnimationsTracks();
131
134 SAnimTrack* GetAnimationTrack(const unsigned short& index);
135
139
142 void SetLength(const float& length);
143
146 float GetLength();
147
150 virtual void SetTimePosition(const float& timePosition);
151
154 float GetTimePosition();
155
158 void Apply(const float& timePosition);
159
162 virtual void SetWeight(const float& weight);
163
166 virtual float GetWeight();
167
170 void SetInitialWeight(const float& weight);
171
174 float GetInitialWeight();
175
178 void SetInitialLoop(const bool& loop);
179
182 bool GetInitialLoop();
183
186 void SetInterpolationMode(const AnimInterpolationMode& interpolationMode);
187
191
194 void SetRotationInterpolationMode(const AnimRotationInterpolationMode& interpolationMode);
195
199
202 virtual void SetEnable(const bool& enable);
203
206 virtual bool GetEnable();
207
210 void SetLoop(const bool& loop);
211
214 bool GetLoop();
215
218 bool SkipFrame();
219
222 void SetSkipFrame(const bool& state);
223
226 void SetOptimise(const bool& optimize);
227
231 //bool GetOptimise();
232
235 void SetSpeed(const float& newSpeed);
236
239 float GetSpeed();
240
243 bool HasEnded();
244
247 void AddTime(const float& time);
248
251 void SetPaused(const bool& pauseState);
252
255 bool GetPaused();
256
259 void Update(const Ogre::FrameEvent& evt);
260
264 virtual void _UpdateImpl(const Ogre::FrameEvent &evt);
265protected:
268 SAnim(SScene* scene, const std::string& animationName, SNode* animationAssociatedNode, const unsigned short& animationId, const AnimType& animationType);
269
273 void AddAnimationTrack(SAnimTrack* existingAnimationTrack);
274
278 void RemoveAnimationTrack(SAnimTrack* existingAnimationTrack);
279
283 virtual SAnimTrack* CreateAnimationTrackImpl(const std::string& newAnimationTrackName);
284
289 virtual Ogre::AnimationState* _GetOgreAnimationState() = 0;
290private:
294 SAnim();
295};
296
297class SAnimationFrameListener : public Ogre::FrameListener
298{
299public:
300protected:
301private:
302 SAnim* animation;
303
304public:
307 SAnimationFrameListener(SAnim* animationListened);
308
312
316 bool frameStarted(const Ogre::FrameEvent& evt);
317protected:
318private:
319};
320
321}
322
323#endif
librairies include
SScene * GetParentScene()
Definition SO3Anim.cpp:110
void RemoveAnimationTrack(SAnimTrack *existingAnimationTrack)
Definition SO3Anim.cpp:192
virtual void SetTimePosition(const float &timePosition)
Definition SO3Anim.cpp:214
virtual void _UpdateImpl(const Ogre::FrameEvent &evt)
Definition SO3Anim.cpp:383
void AddTime(const float &time)
Definition SO3Anim.cpp:351
void SetInitialLoop(const bool &loop)
Definition SO3Anim.cpp:263
void SetOptimise(const bool &optimize)
Definition SO3Anim.cpp:326
void DeleteAnimationTrack(SAnimTrack *existingAnimationTrack)
Definition SO3Anim.cpp:163
bool GetInitialLoop()
Definition SO3Anim.cpp:270
virtual SAnimTrack * CreateAnimationTrackImpl(const std::string &newAnimationTrackName)
Definition SO3Anim.cpp:158
bool IsSequenceUpdated()
Definition SO3Anim.cpp:392
AnimRotationInterpolationMode
Definition SO3Anim.h:60
@ SO3_RIM_LINEAR
Values are interpolated linearly. This is faster but does not necessarily give a completely accurate ...
Definition SO3Anim.h:61
@ SO3_RIM_SPHERICAL
Values are interpolated spherically. This is more accurate but has a higher cost.
Definition SO3Anim.h:62
virtual void SetWeight(const float &weight)
Definition SO3Anim.cpp:237
void Update(const Ogre::FrameEvent &evt)
Definition SO3Anim.cpp:367
virtual Ogre::AnimationState * _GetOgreAnimationState()=0
void Apply(const float &timePosition)
Definition SO3Anim.cpp:220
SAnimTrack * GetAnimationTrack(const unsigned short &index)
Definition SO3Anim.cpp:174
AnimInterpolationMode
Definition SO3Anim.h:55
@ SO3_IM_LINEAR
Values are interpolated along straight lines.
Definition SO3Anim.h:56
@ SO3_IM_SPLINE
Values are interpolated along a spline, resulting in smoother changes in direction.
Definition SO3Anim.h:57
AnimType GetType()
Definition SO3Anim.cpp:125
Ogre::Animation * GetOgreAnimationPointer()
Definition SO3Anim.cpp:115
float GetInitialWeight()
Definition SO3Anim.cpp:258
unsigned short GetIndex()
Definition SO3Anim.cpp:130
AnimInterpolationMode GetInterpolationMode()
Definition SO3Anim.cpp:280
void SetLoop(const bool &loop)
Definition SO3Anim.cpp:311
SAnimTrack * CreateAnimationTrack(const std::string &newAnimationTrackName)
Definition SO3Anim.cpp:145
virtual void SetEnable(const bool &enable)
Definition SO3Anim.cpp:295
SNode * GetParentNode()
Definition SO3Anim.cpp:120
AnimRotationInterpolationMode GetRotationInterpolationMode()
Definition SO3Anim.cpp:290
void SetRotationInterpolationMode(const AnimRotationInterpolationMode &interpolationMode)
Definition SO3Anim.cpp:285
unsigned short GetNumAnimationsTracks()
Definition SO3Anim.cpp:169
void SetPaused(const bool &pauseState)
Definition SO3Anim.cpp:357
void AddAnimationTrack(SAnimTrack *existingAnimationTrack)
Definition SO3Anim.cpp:187
virtual bool GetEnable()
Definition SO3Anim.cpp:302
bool GetPaused()
Definition SO3Anim.cpp:362
@ SO3_SEQUENCE_ANIM
Definition SO3Anim.h:52
@ SO3_UNKNOWN_ANIM
Definition SO3Anim.h:46
@ SO3_POSE_ANIM
Definition SO3Anim.h:51
@ SO3_SCENENODE_ANIM
Definition SO3Anim.h:47
@ SO3_SKELETAL_ANIM
Definition SO3Anim.h:48
@ SO3_FAP_ANIM
Definition SO3Anim.h:50
@ SO3_VERTEX_ANIM
Definition SO3Anim.h:49
Ogre::Animation * ogreAnimation
Definition SO3Anim.h:65
void SetLength(const float &length)
Definition SO3Anim.cpp:199
bool SkipFrame()
Definition SO3Anim.cpp:135
void SetInitialWeight(const float &weight)
Definition SO3Anim.cpp:252
SScene * mScene
Definition SO3Anim.h:67
virtual float GetWeight()
Definition SO3Anim.cpp:243
virtual ~SAnim()
Definition SO3Anim.cpp:62
float GetLength()
Definition SO3Anim.cpp:205
float GetTimePosition()
Definition SO3Anim.cpp:228
SAnimTrackList animationTrackList
Definition SO3Anim.h:66
bool GetLoop()
Definition SO3Anim.cpp:317
void SetInterpolationMode(const AnimInterpolationMode &interpolationMode)
Definition SO3Anim.cpp:275
bool HasEnded()
Definition SO3Anim.cpp:342
float GetSpeed()
Definition SO3Anim.cpp:337
void SetSpeed(const float &newSpeed)
Definition SO3Anim.cpp:332
void SetSequenceUpdated(const bool &value)
Definition SO3Anim.cpp:397
SAnimTrackList GetAnimationsTracks() const
Definition SO3Anim.cpp:182
void SetSkipFrame(const bool &state)
Definition SO3Anim.cpp:140
bool frameStarted(const Ogre::FrameEvent &evt)
Definition SO3Anim.cpp:405
std::vector< SAnimTrack * > SAnimTrackList