All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
LightningManager.h
Go to the documentation of this file.
1 /*
2 --------------------------------------------------------------------------------
3 This source file is part of SkyX.
4 Visit http://www.paradise-studios.net/products/skyx/
5 
6 Copyright (C) 2009-2012 Xavier Verguín González <xavyiy@gmail.com>
7 
8 This program is free software; you can redistribute it and/or modify it under
9 the terms of the GNU Lesser General Public License as published by the Free Software
10 Foundation; either version 2 of the License, or (at your option) any later
11 version.
12 
13 This program is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16 
17 You should have received a copy of the GNU Lesser General Public License along with
18 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20 http://www.gnu.org/copyleft/lesser.txt.
21 --------------------------------------------------------------------------------
22 */
23 
24 #ifndef _SkyX_VClouds_LightningManager_H_
25 #define _SkyX_VClouds_LightningManager_H_
26 
27 #include <vector>
28 
29 #include "Prerequisites.h"
30 
31 #include "Lightning.h"
32 
33 namespace SkyX { namespace VClouds {
34 
35  class VClouds;
36 
38  {
39  public:
42  class Listener
43  {
44  public:
54  inline virtual void lightningAdded(Lightning* l) {}
55  virtual ~Listener() {}
56  };
57 
61  explicit LightningManager(VClouds* vc);
62 
66 
69  void create();
70 
73  void remove();
74 
78  void update(const Ogre::Real& timeSinceLastFrame);
79 
90  Lightning* addLightning(const Ogre::Vector3& p, const Ogre::Vector3& d,
91  const Ogre::Real l,
92  const Ogre::uint32& div = static_cast<Ogre::uint32>(
93  Ogre::Math::RangeRandom(12, 30)));
94 
98  void updateMaterial();
99 
103  inline void addListener(Listener* listener)
104  {
105  mListeners.push_back(listener);
106  }
107 
111  void removeListener(Listener* listener);
112 
115  inline void removeListeners()
116  {
117  mListeners.clear();
118  }
119 
123  inline const std::vector<Listener*>& getListeners() const
124  {
125  return mListeners;
126  }
127 
131  void setEnabled(const bool& enable);
132 
137  inline const bool& isEnabled() const
138  {
139  return mEnabled;
140  }
141 
145  void setLightningColor(const Ogre::Vector3& c);
146 
150  inline const Ogre::Vector3& getLightningColor() const
151  {
152  return mLightningColor;
153  }
154 
159  void setLightningTimeMultiplier(const Ogre::Real& m)
160  {
161  mLightningTimeMultiplier = m;
162  }
163 
167  inline const Ogre::Real& getLightningTimeMultiplier() const
168  {
169  return mLightningTimeMultiplier;
170  }
171 
175  inline void setAverageLightningApparitionTime(const Ogre::Real& alat)
176  {
177  mAverageLightningApparitionTime = alat;
178  mRemainingTime = alat;
179  }
180 
184  inline const Ogre::Real& getAverageLightningApparitionTime() const
185  {
186  return mAverageLightningApparitionTime;
187  }
188 
192  inline const bool& isCreated() const
193  {
194  return mCreated;
195  }
196 
202  void _updateRenderQueueGroup(const Ogre::uint8& rqg);
203 
208  void _setVisible(const bool& v);
209 
210  private:
212  VClouds *mVClouds;
213 
215  std::vector<Lightning*> mLightnings;
217  std::vector<Ogre::SceneNode*> mSceneNodes;
218 
220  bool mEnabled;
221 
223  Ogre::Vector3 mLightningColor;
225  Ogre::Real mLightningTimeMultiplier;
226 
228  Ogre::Real mAverageLightningApparitionTime;
230  Ogre::Real mRemainingTime;
231 
233  Ogre::MaterialPtr mVolCloudsLightningMaterial;
235  Ogre::MaterialPtr mLightningMaterial;
236 
238  std::vector<Listener*> mListeners;
239 
241  bool mCreated;
242  };
243 }}
244 #endif
const bool & isEnabled() const
Get whether the lightning system is enabled or not.
Definition: LightningManager.h:137
bool mEnabled
True if skyx is enabled.
Definition: SkyX.h:449
Definition: LightningManager.h:37
const std::vector< Listener * > & getListeners() const
Get listeners.
Definition: LightningManager.h:123
Definition: VClouds.h:37
void create()
Create SkyX.
void addListener(Listener *listener)
Add listener.
Definition: LightningManager.h:103
const Ogre::Vector3 & getLightningColor() const
Get lightning color.
Definition: LightningManager.h:150
void removeListeners()
Remove listeners.
Definition: LightningManager.h:115
GAZEBO_VISIBLE void enable()
Enable sensors.
virtual ~Listener()
Definition: LightningManager.h:55
Listener class.
Definition: LightningManager.h:42
virtual void lightningAdded(Lightning *l)
Lightning added.
Definition: LightningManager.h:54
SkyX(Ogre::SceneManager *sm, Controller *c)
Contructor.
void setLightningTimeMultiplier(const Ogre::Real &m)
Set lightning time multiplier.
Definition: LightningManager.h:159
void setEnabled(bool _enabled)
Definition: SkyX.h:355
const Ogre::Real & getAverageLightningApparitionTime() const
Get average lightning apparition time.
Definition: LightningManager.h:184
bool mCreated
Is SkyX created?
Definition: SkyX.h:422
Definition: Lightning.h:32
const bool & isCreated() const
Has been create() already called?
Definition: LightningManager.h:192
void setAverageLightningApparitionTime(const Ogre::Real &alat)
Set average lightning apparition time.
Definition: LightningManager.h:175
const Ogre::Real & getLightningTimeMultiplier() const
Set lightning time multiplier.
Definition: LightningManager.h:167
class __declspec(dllimport) BasicController void update(const Ogre::Real &simDeltaTime)
Basic controller class.
#define DllExport
Include external headers.
Definition: Prerequisites.h:45