Emergency 20 Dokumentation  4.2.0
FadeEffectComponent.h
Go to the documentation of this file.
1 // Copyright (C) 2012-2018 Promotion Software GmbH
2 
3 
4 //[-------------------------------------------------------]
5 //[ Header guard ]
6 //[-------------------------------------------------------]
7 #pragma once
8 
9 
10 //[-------------------------------------------------------]
11 //[ Includes ]
12 //[-------------------------------------------------------]
13 #include "em5/Export.h"
14 
17 
18 
19 //[-------------------------------------------------------]
20 //[ Namespace ]
21 //[-------------------------------------------------------]
22 namespace em5
23 {
24 
25 
26  //[-------------------------------------------------------]
27  //[ Classes ]
28  //[-------------------------------------------------------]
34  {
35 
36 
37  //[-------------------------------------------------------]
38  //[ Public definitions ]
39  //[-------------------------------------------------------]
40  public:
41  static const uint32 COMPONENT_ID;
42 
43 
44  //[-------------------------------------------------------]
45  //[ Public methods ]
46  //[-------------------------------------------------------]
47  public:
55  explicit FadeEffectComponent(qsf::Prototype* prototype);
56 
61  virtual ~FadeEffectComponent();
62 
63  void fadeIn(qsf::Time effectDuration = qsf::Time::fromSeconds(1.0f));
64 
65  void fadeOut(qsf::Time effectDuration = qsf::Time::fromSeconds(1.0f), bool deleteOwner = false);
66 
67  void init(bool fadeIn = true, qsf::Time effectDuration = qsf::Time::fromSeconds(1.0f), bool deleteOwner = false);
68 
73  bool isFading() const;
74 
75  bool isFadeIn() const;
76  const qsf::Time& getFadeTime() const;
77 
78 
79  //[-------------------------------------------------------]
80  //[ Protected virtual qsf::Component methods ]
81  //[-------------------------------------------------------]
82  protected:
83  //[-------------------------------------------------------]
84  //[ Lifecycle ]
85  //[-------------------------------------------------------]
86  virtual void onShutdown() override;
87 
88 
89  //[-------------------------------------------------------]
90  //[ Protected virtual qsf::MovableObjectRenderingListener methods ]
91  //[-------------------------------------------------------]
92  protected:
93  virtual qsf::Component* getMovableObjectRenderingListenerComponent() override;
94  virtual void onObjectRendering(const qsf::Component& component, const Ogre::Camera& ogreCamera) override;
95 
96 
97  //[-------------------------------------------------------]
98  //[ Private methods ]
99  //[-------------------------------------------------------]
100  private:
101  void activateJob();
102  void deactivateJob();
103  void updateJob(const qsf::JobArguments& jobArguments);
104 
105  void updateFadeIn(const qsf::Time& secondsPassed);
106  void updateFadeOut(const qsf::Time& secondsPassed);
107 
115  void setFadeEffect(float visibility);
116 
117  void synchronizeInternalAndRendererVisibility();
118  void updateMaterialAndInternalFadeAmount(bool enable, float visibility) const;
119 
120 
121  //[-------------------------------------------------------]
122  //[ Private data ]
123  //[-------------------------------------------------------]
124  private:
125  qsf::JobProxy mUpdateJobProxy;
126  qsf::Time mEffectDuration;
127  qsf::Time mRunningTime;
128  bool mDeleteOwner;
129  bool mFadeIn;
130  // Internal and renderer fade visibility
131  float mInternalVisibility;
132  float mRendererVisibility;
133 
134 
135  //[-------------------------------------------------------]
136  //[ CAMP reflection system ]
137  //[-------------------------------------------------------]
138  QSF_CAMP_RTTI() // Only adds the virtual method "campClassId()", nothing more
139 
140 
141  };
142 
143 
144 //[-------------------------------------------------------]
145 //[ Namespace ]
146 //[-------------------------------------------------------]
147 } // em5
148 
149 
150 //[-------------------------------------------------------]
151 //[ CAMP reflection system ]
152 //[-------------------------------------------------------]
Definition: ActionPriority.h:13
Job proxy class.
Definition: JobProxy.h:51
Abstract component class.
Definition: Component.h:105
Job proxy based OGRE movable object rendering listener.
Definition: JobProxyMovableObjectRenderingListener.h:31
unsigned int uint32
Definition: PlatformTypes.h:181
#define EM5_API_EXPORT
Definition: Export.h:28
Job arguments class: holds data to be passed to the called job method by the job manager.
Definition: JobArguments.h:40
static const uint32 COMPONENT_ID
"em5::FadeEffectComponent" unique component ID
Definition: FadeEffectComponent.h:41
#define QSF_CAMP_RTTI()
Only adds the virtual method "campClassId()", nothing more.
Definition: CampClass.h:75
#define QSF_CAMP_TYPE_NONCOPYABLE(type)
See "CAMP_TYPE_NONCOPYABLE" for details.
Definition: CampClass.h:112
static Time fromSeconds(float seconds)
Definition: Time-inl.h:74
Prototype class.
Definition: Prototype.h:100
EMERGENCY 5 fade effect component.
Definition: FadeEffectComponent.h:33
Data type for encapsulating time information. It might represents points in time and time spans...
Definition: Time.h:32