6
#ifndef __FADE_CONTROLLER_H__
7
#define __FADE_CONTROLLER_H__
9
#include "IAnimationNode.h"
10
#include "IAnimationGraph.h"
11
#include "ConnectionReceiver.h"
16
class FadeController :
22
mIsAnimationRun(false),
27
FadeController(const std::string& _name, IAnimationGraph* _graph) :
28
IAnimationNode(_name, _graph),
29
mIsAnimationRun(false),
34
virtual ~FadeController()
38
virtual void setEvent(const std::string& _name, float _value = 0)
42
mIsAnimationRun = true;
44
mConnection.forceEvent("Start");
46
else if (_name == "Stop") mIsAnimationRun = false;
49
virtual void addConnection(const std::string& _eventout, IAnimationNode* _node, const std::string& _eventin)
51
mConnection.addConnection(_eventout, _node, _eventin);
54
virtual void removeConnection(const std::string& _eventout, IAnimationNode* _node, const std::string& _eventin)
56
mConnection.removeConnection(_eventout, _node, _eventin);
59
virtual void addTime(float _value)
61
const float fade_time = 0.3;
66
mWeight += _value * (1 / fade_time);
67
if (mWeight > 1) mWeight = 1;
68
mConnection.forceEvent("Weight", mWeight);
75
mWeight -= _value * (1 / fade_time);
76
if (mWeight < 0) mWeight = 0;
77
mConnection.forceEvent("Weight", mWeight);
80
mConnection.forceEvent("Stop");
86
ConnectionReceiver mConnection;
92
} // namespace animation
94
#endif // __FADE_CONTROLLER_H__
6
#ifndef __FADE_CONTROLLER_H__
7
#define __FADE_CONTROLLER_H__
9
#include "IAnimationNode.h"
10
#include "IAnimationGraph.h"
11
#include "ConnectionReceiver.h"
16
class FadeController :
22
mIsAnimationRun(false),
27
FadeController(const std::string& _name, IAnimationGraph* _graph) :
28
IAnimationNode(_name, _graph),
29
mIsAnimationRun(false),
34
virtual ~FadeController()
38
virtual void setEvent(const std::string& _name, float _value = 0)
42
mIsAnimationRun = true;
44
mConnection.forceEvent("Start");
46
else if (_name == "Stop") mIsAnimationRun = false;
49
virtual void addConnection(const std::string& _eventout, IAnimationNode* _node, const std::string& _eventin)
51
mConnection.addConnection(_eventout, _node, _eventin);
54
virtual void removeConnection(const std::string& _eventout, IAnimationNode* _node, const std::string& _eventin)
56
mConnection.removeConnection(_eventout, _node, _eventin);
59
virtual void addTime(float _value)
61
const float fade_time = 0.3f;
66
mWeight += _value * (1 / fade_time);
67
if (mWeight > 1) mWeight = 1;
68
mConnection.forceEvent("Weight", mWeight);
75
mWeight -= _value * (1 / fade_time);
76
if (mWeight < 0) mWeight = 0;
77
mConnection.forceEvent("Weight", mWeight);
80
mConnection.forceEvent("Stop");
86
ConnectionReceiver mConnection;
92
} // namespace animation
94
#endif // __FADE_CONTROLLER_H__