RigsofRods
Soft-body Physics Simulation
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 "Prerequisites.h"
28 
29 #include "Lightning.h"
30 
31 namespace SkyX { namespace VClouds{
32 
33  class VClouds;
34 
36  {
37  public:
40  class Listener
41  {
42  public:
50  inline virtual void lightningAdded(Lightning* l){}
51  };
52 
57 
61 
64  void create();
65 
68  void remove();
69 
73  void update(const Ogre::Real& timeSinceLastFrame);
74 
83  Lightning* addLightning(const Ogre::Vector3& p, const Ogre::Vector3& d, const Ogre::Real l, const Ogre::uint32& div = static_cast<Ogre::uint32>(Ogre::Math::RangeRandom(12, 30)));
84 
88  void updateMaterial();
89 
93  inline void addListener(Listener* listener)
94  {
95  mListeners.push_back(listener);
96  }
97 
101  void removeListener(Listener* listener);
102 
105  inline void removeListeners()
106  {
107  mListeners.clear();
108  }
109 
113  inline const std::vector<Listener*>& getListeners() const
114  {
115  return mListeners;
116  }
117 
121  void setEnabled(const bool& enable);
122 
127  inline const bool& isEnabled() const
128  {
129  return mEnabled;
130  }
131 
135  void setLightningColor(const Ogre::Vector3& c);
136 
140  inline const Ogre::Vector3& getLightningColor() const
141  {
142  return mLightningColor;
143  }
144 
149  void setLightningTimeMultiplier(const Ogre::Real& m)
150  {
152  }
153 
157  inline const Ogre::Real& getLightningTimeMultiplier() const
158  {
160  }
161 
165  inline void setAverageLightningApparitionTime(const Ogre::Real& alat)
166  {
168  mRemainingTime = alat;
169  }
170 
174  inline const Ogre::Real& getAverageLightningApparitionTime() const
175  {
177  }
178 
182  inline const bool& isCreated() const
183  {
184  return mCreated;
185  }
186 
191  void _updateRenderQueueGroup(const Ogre::uint8& rqg);
192 
197  void _setVisible(const bool& v);
198 
199  private:
201  std::vector<Lightning*> mLightnings;
203  std::vector<Ogre::SceneNode*> mSceneNodes;
204 
206  bool mEnabled;
207 
209  Ogre::Vector3 mLightningColor;
212 
216  Ogre::Real mRemainingTime;
217 
219  Ogre::MaterialPtr mVolCloudsLightningMaterial;
221  Ogre::MaterialPtr mLightningMaterial;
222 
224  std::vector<Listener*> mListeners;
225 
227  bool mCreated;
228 
231  };
232 
233 }}
234 
235 #endif
SkyX::VClouds::LightningManager::mLightningTimeMultiplier
Ogre::Real mLightningTimeMultiplier
Lightning time multiplier.
Definition: LightningManager.h:211
SkyX::VClouds::LightningManager::Listener::lightningAdded
virtual void lightningAdded(Lightning *l)
Lightning added.
Definition: LightningManager.h:50
SkyX::VClouds::LightningManager::mAverageLightningApparitionTime
Ogre::Real mAverageLightningApparitionTime
Average lightning apparition time (in seconds)
Definition: LightningManager.h:214
SkyX::VClouds::LightningManager::mVClouds
VClouds * mVClouds
VClouds pointer.
Definition: LightningManager.h:230
SkyX::VClouds::LightningManager::isCreated
const bool & isCreated() const
Has been create() already called?
Definition: LightningManager.h:182
SkyX::VClouds::LightningManager::LightningManager
LightningManager(VClouds *vc)
Constructor.
Definition: LightningManager.cpp:32
SkyX::VClouds::LightningManager::setEnabled
void setEnabled(const bool &enable)
Enable or disable the lightning system.
Definition: LightningManager.cpp:281
SkyX::VClouds::LightningManager::isEnabled
const bool & isEnabled() const
Get whether the lightning system is enabled or not.
Definition: LightningManager.h:127
SkyX
Definition: AtmosphereManager.cpp:30
SkyX::VClouds::LightningManager::mListeners
std::vector< Listener * > mListeners
Listeners.
Definition: LightningManager.h:224
SkyX::VClouds::LightningManager::mLightnings
std::vector< Lightning * > mLightnings
Lightnings.
Definition: LightningManager.h:201
SkyX::VClouds::LightningManager::mRemainingTime
Ogre::Real mRemainingTime
Remaining time for next lightning.
Definition: LightningManager.h:216
SkyX::VClouds::LightningManager::setLightningColor
void setLightningColor(const Ogre::Vector3 &c)
Set lightning color.
Definition: LightningManager.cpp:253
SkyX::VClouds::LightningManager::update
void update(const Ogre::Real &timeSinceLastFrame)
Update, to be invoked per frame.
Definition: LightningManager.cpp:105
SkyX::VClouds::LightningManager::getAverageLightningApparitionTime
const Ogre::Real & getAverageLightningApparitionTime() const
Get average lightning apparition time.
Definition: LightningManager.h:174
SkyX::VClouds::LightningManager::_updateRenderQueueGroup
void _updateRenderQueueGroup(const Ogre::uint8 &rqg)
Update render queue group.
Definition: LightningManager.cpp:298
SkyX::VClouds::LightningManager::mLightningColor
Ogre::Vector3 mLightningColor
Lightning color.
Definition: LightningManager.h:209
SkyX::VClouds::LightningManager
Definition: LightningManager.h:35
Lightning.h
SkyX::VClouds::LightningManager::setAverageLightningApparitionTime
void setAverageLightningApparitionTime(const Ogre::Real &alat)
Set average lightning apparition time.
Definition: LightningManager.h:165
SkyX::VClouds::LightningManager::~LightningManager
~LightningManager()
Destructor.
Definition: LightningManager.cpp:48
SkyX::VClouds::LightningManager::_setVisible
void _setVisible(const bool &v)
Set visible.
Definition: LightningManager.cpp:306
SkyX::VClouds::Lightning
Definition: Lightning.h:31
SkyX::VClouds::LightningManager::getLightningTimeMultiplier
const Ogre::Real & getLightningTimeMultiplier() const
Set lightning time multiplier.
Definition: LightningManager.h:157
SkyX::VClouds::LightningManager::getListeners
const std::vector< Listener * > & getListeners() const
Get listeners.
Definition: LightningManager.h:113
SkyX::VClouds::LightningManager::Listener
Listener class.
Definition: LightningManager.h:40
SkyX::VClouds::LightningManager::addLightning
Lightning * addLightning(const Ogre::Vector3 &p, const Ogre::Vector3 &d, const Ogre::Real l, const Ogre::uint32 &div=static_cast< Ogre::uint32 >(Ogre::Math::RangeRandom(12, 30)))
Add lightning.
Definition: LightningManager.cpp:202
SkyX::VClouds::VClouds
Definition: VClouds.h:35
SkyX::VClouds::LightningManager::removeListeners
void removeListeners()
Remove listeners.
Definition: LightningManager.h:105
SkyX::VClouds::LightningManager::mSceneNodes
std::vector< Ogre::SceneNode * > mSceneNodes
Scene nodes.
Definition: LightningManager.h:203
SkyX::VClouds::LightningManager::removeListener
void removeListener(Listener *listener)
Remove listener.
Definition: LightningManager.cpp:269
SkyX::VClouds::LightningManager::mLightningMaterial
Ogre::MaterialPtr mLightningMaterial
Lightning material.
Definition: LightningManager.h:221
SkyX::VClouds::LightningManager::mEnabled
bool mEnabled
Is the lightning system enabled?
Definition: LightningManager.h:206
SkyX::VClouds::LightningManager::updateMaterial
void updateMaterial()
Update material.
Definition: LightningManager.cpp:230
SkyX::VClouds::LightningManager::addListener
void addListener(Listener *listener)
Add listener.
Definition: LightningManager.h:93
SkyX::VClouds::LightningManager::getLightningColor
const Ogre::Vector3 & getLightningColor() const
Get lightning color.
Definition: LightningManager.h:140
SkyX::VClouds::LightningManager::mCreated
bool mCreated
Has been create() already called?
Definition: LightningManager.h:227
SkyX::VClouds::LightningManager::remove
void remove()
Remove.
Definition: LightningManager.cpp:80
SkyX::VClouds::LightningManager::setLightningTimeMultiplier
void setLightningTimeMultiplier(const Ogre::Real &m)
Set lightning time multiplier.
Definition: LightningManager.h:149
SkyX::VClouds::LightningManager::create
void create()
Create.
Definition: LightningManager.cpp:53
SkyX::VClouds::LightningManager::mVolCloudsLightningMaterial
Ogre::MaterialPtr mVolCloudsLightningMaterial
Vol. clouds + lightning material.
Definition: LightningManager.h:219