RigsofRods
Soft-body Physics Simulation
CloudsManager.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_CloudsManager_H_
25 #define _SkyX_CloudsManager_H_
26 
27 #include "Prerequisites.h"
28 
29 #include "ColorGradient.h"
30 
31 namespace SkyX
32 {
33  class SkyX;
34 
35  class CloudLayer
36  {
37  public:
40  struct Options
41  {
43  Ogre::Real Height;
45  Ogre::Real Scale;
47  Ogre::Vector2 WindDirection;
49  Ogre::Real TimeMultiplier;
50 
52  Ogre::Real DistanceAttenuation;
54  Ogre::Real DetailAttenuation;
56  Ogre::Real HeightVolume;
59 
60 
64  : Height(100)
65  , Scale(0.001f)
66  , WindDirection(Ogre::Vector2(1,1))
67  , TimeMultiplier(0.125f)
68  , DistanceAttenuation(0.05f)
70  , HeightVolume(0.25f)
71  , VolumetricDisplacement(0.01f)
72  {
73  }
74 
81  Options(const Ogre::Real& _Height,
82  const Ogre::Real& _Scale,
83  const Ogre::Vector2& _WindDirection,
84  const Ogre::Real& _TimeMultiplier)
85  : Height(_Height)
86  , Scale(_Scale)
87  , WindDirection(_WindDirection)
88  , TimeMultiplier(_TimeMultiplier)
89  , DistanceAttenuation(0.05f)
91  , HeightVolume(0.25f)
92  , VolumetricDisplacement(0.01f)
93  {
94  }
95 
107  Options(const Ogre::Real& _Height,
108  const Ogre::Real& _Scale,
109  const Ogre::Vector2& _WindDirection,
110  const Ogre::Real& _TimeMultiplier,
111  const Ogre::Real& _DistanceAttenuation,
112  const Ogre::Real& _DetailAttenuation,
113  const Ogre::Real& _HeightVolume,
114  const Ogre::Real& _VolumetricDisplacement)
115  : Height(_Height)
116  , Scale(_Scale)
117  , WindDirection(_WindDirection)
118  , TimeMultiplier(_TimeMultiplier)
119  , DistanceAttenuation(_DistanceAttenuation)
120  , DetailAttenuation(_DetailAttenuation)
121  , HeightVolume(_HeightVolume)
122  , VolumetricDisplacement(_VolumetricDisplacement)
123  {
124  }
125  };
126 
127 
131  CloudLayer(SkyX *s);
132 
137  CloudLayer(SkyX *s, const Options& o);
138 
141  ~CloudLayer();
142 
146  inline void setOptions(const Options& o)
147  {
148  mOptions = o;
150  }
151 
155  inline const Options& getOptions() const
156  {
157  return mOptions;
158  }
159 
163  inline void setAmbientGradient(const ColorGradient& AmbientGradient)
164  {
165  mAmbientGradient = AmbientGradient;
166  }
167 
171  inline const ColorGradient& getAmbientGradient() const
172  {
173  return mAmbientGradient;
174  }
175 
179  inline void setSunGradient(const ColorGradient& SunGradient)
180  {
181  mSunGradient = SunGradient;
182  }
183 
187  inline const ColorGradient& getSunGradient() const
188  {
189  return mSunGradient;
190  }
191 
195  void _registerCloudLayer(Ogre::Pass* CloudLayerPass);
196 
199  void _unregister();
200 
204 
205  private:
208  void _updatePassParameters();
209 
212 
216 
218  Ogre::Pass *mCloudLayerPass;
219 
222  };
223 
225  {
226  public:
230  CloudsManager(SkyX *h);
231 
234  ~CloudsManager();
235 
238  void update();
239 
245 
248  void remove(CloudLayer *cl);
249 
252  void removeAll();
253 
256  void registerAll();
257 
261  void unregister(CloudLayer* cl);
262 
265  void unregisterAll();
266 
270  inline const std::vector<CloudLayer*>& getCloudLayers() const
271  {
272  return mCloudLayers;
273  }
274 
275  private:
277  std::vector<CloudLayer*> mCloudLayers;
279  std::vector<CloudLayer*>::iterator CloudLayersIt;
280 
283  };
284 }
285 
286 #endif
SkyX::CloudLayer::Options::Options
Options(const Ogre::Real &_Height, const Ogre::Real &_Scale, const Ogre::Vector2 &_WindDirection, const Ogre::Real &_TimeMultiplier)
Constructor.
Definition: CloudsManager.h:81
SkyX::ColorGradient
Definition: ColorGradient.h:31
SkyX::CloudLayer
Definition: CloudsManager.h:35
SkyX::CloudLayer::Options::Height
Ogre::Real Height
Cloud layer height.
Definition: CloudsManager.h:43
ColorGradient.h
Prerequisites.h
SkyX::CloudsManager::registerAll
void registerAll()
Register all.
Definition: CloudsManager.cpp:283
SkyX::CloudLayer::mSunGradient
ColorGradient mSunGradient
Definition: CloudsManager.h:215
SkyX::CloudLayer::setSunGradient
void setSunGradient(const ColorGradient &SunGradient)
Set sun gradient.
Definition: CloudsManager.h:179
SkyX::CloudLayer::Options::DistanceAttenuation
Ogre::Real DistanceAttenuation
Distance attenuation.
Definition: CloudsManager.h:52
SkyX::CloudLayer::Options
Cloud layer options.
Definition: CloudsManager.h:40
SkyX::CloudLayer::Options::Options
Options(const Ogre::Real &_Height, const Ogre::Real &_Scale, const Ogre::Vector2 &_WindDirection, const Ogre::Real &_TimeMultiplier, const Ogre::Real &_DistanceAttenuation, const Ogre::Real &_DetailAttenuation, const Ogre::Real &_HeightVolume, const Ogre::Real &_VolumetricDisplacement)
Constructor.
Definition: CloudsManager.h:107
SkyX
Definition: AtmosphereManager.cpp:30
SkyX::CloudLayer::getOptions
const Options & getOptions() const
Get options.
Definition: CloudsManager.h:155
SkyX::CloudLayer::CloudLayer
CloudLayer(SkyX *s)
Default onstructor.
Definition: CloudsManager.cpp:31
SkyX::CloudLayer::Options::VolumetricDisplacement
Ogre::Real VolumetricDisplacement
Volumetric displacement(For volumetric effects on the gpu)
Definition: CloudsManager.h:58
SkyX::CloudLayer::Options::Scale
Ogre::Real Scale
Cloud layer scale.
Definition: CloudsManager.h:45
SkyX::CloudsManager::mSkyX
SkyX * mSkyX
SkyX parent pointer.
Definition: CloudsManager.h:282
SkyX::CloudLayer::setAmbientGradient
void setAmbientGradient(const ColorGradient &AmbientGradient)
Set ambient gradient.
Definition: CloudsManager.h:163
SkyX::CloudLayer::Options::TimeMultiplier
Ogre::Real TimeMultiplier
Time multiplier.
Definition: CloudsManager.h:49
SkyX::CloudsManager
Definition: CloudsManager.h:224
SkyX::CloudLayer::~CloudLayer
~CloudLayer()
Destructor.
Definition: CloudsManager.cpp:81
SkyX::CloudLayer::getSunGradient
const ColorGradient & getSunGradient() const
Get sun color gradient.
Definition: CloudsManager.h:187
SkyX::CloudsManager::getCloudLayers
const std::vector< CloudLayer * > & getCloudLayers() const
Get cloud layers.
Definition: CloudsManager.h:270
SkyX::CloudsManager::remove
void remove(CloudLayer *cl)
Remove the specified cloud layer.
Definition: CloudsManager.cpp:260
SkyX::CloudLayer::getAmbientGradient
const ColorGradient & getAmbientGradient() const
Get ambient color gradient.
Definition: CloudsManager.h:171
SkyX::CloudLayer::_unregister
void _unregister()
Unregister cloud pass.
Definition: CloudsManager.cpp:116
SkyX::CloudLayer::mCloudLayerPass
Ogre::Pass * mCloudLayerPass
Cloud layer pass.
Definition: CloudsManager.h:218
SkyX::CloudsManager::~CloudsManager
~CloudsManager()
Destructor.
Definition: CloudsManager.cpp:215
SkyX::CloudsManager::removeAll
void removeAll()
Remove all cloud layers.
Definition: CloudsManager.cpp:273
SkyX::CloudsManager::CloudLayersIt
std::vector< CloudLayer * >::iterator CloudLayersIt
Cloud layers iterator.
Definition: CloudsManager.h:279
SkyX::CloudLayer::Options::DetailAttenuation
Ogre::Real DetailAttenuation
Detail attenuation.
Definition: CloudsManager.h:54
SkyX::CloudsManager::add
CloudLayer * add(const CloudLayer::Options &o)
Add a cloud layer.
Definition: CloudsManager.cpp:220
SkyX::CloudsManager::mCloudLayers
std::vector< CloudLayer * > mCloudLayers
Cloud layers std::vector.
Definition: CloudsManager.h:277
SkyX::CloudLayer::mOptions
Options mOptions
Cloud layer options.
Definition: CloudsManager.h:211
SkyX::CloudLayer::Options::WindDirection
Ogre::Vector2 WindDirection
Wind direction.
Definition: CloudsManager.h:47
SkyX::CloudsManager::unregisterAll
void unregisterAll()
Unregister all cloud layers.
Definition: CloudsManager.cpp:304
SkyX::CloudLayer::Options::Options
Options()
Default constructor.
Definition: CloudsManager.h:63
SkyX::CloudsManager::CloudsManager
CloudsManager(SkyX *h)
Constructor.
Definition: CloudsManager.cpp:210
SkyX::CloudsManager::unregister
void unregister(CloudLayer *cl)
Unregister cloud layer.
Definition: CloudsManager.cpp:293
SkyX::CloudsManager::update
void update()
Update cloud layers.
Definition: CloudsManager.cpp:312
SkyX::CloudLayer::mAmbientGradient
ColorGradient mAmbientGradient
Ambient and Sun color gradients.
Definition: CloudsManager.h:214
SkyX::CloudLayer::mSkyX
SkyX * mSkyX
SkyX parent pointer.
Definition: CloudsManager.h:221
SkyX::CloudLayer::_registerCloudLayer
void _registerCloudLayer(Ogre::Pass *CloudLayerPass)
Register layer.
Definition: CloudsManager.cpp:86
SkyX::CloudLayer::Options::HeightVolume
Ogre::Real HeightVolume
Cloud layer height volume(For volumetric effects on the gpu)
Definition: CloudsManager.h:56
Ogre
Definition: ExtinguishableFireAffector.cpp:35
SkyX::CloudLayer::_updateInternalPassParameters
void _updateInternalPassParameters()
Update internal cloud pass parameters.
Definition: CloudsManager.cpp:152
SkyX::CloudLayer::_updatePassParameters
void _updatePassParameters()
Update cloud pass parameters.
Definition: CloudsManager.cpp:125
SkyX::CloudLayer::setOptions
void setOptions(const Options &o)
Set options.
Definition: CloudsManager.h:146