All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 <vector>
28 #include "Prerequisites.h"
29 
30 #include "ColorGradient.h"
31 
32 namespace SkyX
33 {
34  class SkyX;
35 
36  class DllExport CloudLayer
37  {
38  public:
41  struct Options
42  {
44  Ogre::Real Height;
46  Ogre::Real Scale;
48  Ogre::Vector2 WindDirection;
50  Ogre::Real TimeMultiplier;
51 
53  Ogre::Real DistanceAttenuation;
55  Ogre::Real DetailAttenuation;
57  Ogre::Real HeightVolume;
59  Ogre::Real VolumetricDisplacement;
60 
61 
64  Options()
65  : Height(100)
66  , Scale(0.001f)
67  , WindDirection(Ogre::Vector2(1, 1))
68  , TimeMultiplier(0.125f)
69  , DistanceAttenuation(0.05f)
70  , DetailAttenuation(1)
71  , HeightVolume(0.25f)
72  , VolumetricDisplacement(0.01f)
73  {
74  }
75 
82  Options(const Ogre::Real& _Height,
83  const Ogre::Real& _Scale,
84  const Ogre::Vector2& _WindDirection,
85  const Ogre::Real& _TimeMultiplier)
86  : Height(_Height)
87  , Scale(_Scale)
88  , WindDirection(_WindDirection)
89  , TimeMultiplier(_TimeMultiplier)
90  , DistanceAttenuation(0.05f)
91  , DetailAttenuation(1)
92  , HeightVolume(0.25f)
93  , VolumetricDisplacement(0.01f)
94  {
95  }
96 
108  Options(const Ogre::Real& _Height,
109  const Ogre::Real& _Scale,
110  const Ogre::Vector2& _WindDirection,
111  const Ogre::Real& _TimeMultiplier,
112  const Ogre::Real& _DistanceAttenuation,
113  const Ogre::Real& _DetailAttenuation,
114  const Ogre::Real& _HeightVolume,
115  const Ogre::Real& _VolumetricDisplacement)
116  : Height(_Height)
117  , Scale(_Scale)
118  , WindDirection(_WindDirection)
119  , TimeMultiplier(_TimeMultiplier)
120  , DistanceAttenuation(_DistanceAttenuation)
121  , DetailAttenuation(_DetailAttenuation)
122  , HeightVolume(_HeightVolume)
123  , VolumetricDisplacement(_VolumetricDisplacement)
124  {
125  }
126  };
127 
128 
132  CloudLayer(SkyX *s);
133 
138  CloudLayer(SkyX *s, const Options& o);
139 
142  ~CloudLayer();
143 
147  inline void setOptions(const Options& o)
148  {
149  mOptions = o;
150  _updatePassParameters();
151  }
152 
156  inline const Options& getOptions() const
157  {
158  return mOptions;
159  }
160 
164  inline void setAmbientGradient(const ColorGradient& AmbientGradient)
165  {
166  mAmbientGradient = AmbientGradient;
167  }
168 
172  inline const ColorGradient& getAmbientGradient() const
173  {
174  return mAmbientGradient;
175  }
176 
180  inline void setSunGradient(const ColorGradient& SunGradient)
181  {
182  mSunGradient = SunGradient;
183  }
184 
188  inline const ColorGradient& getSunGradient() const
189  {
190  return mSunGradient;
191  }
192 
196  void _registerCloudLayer(Ogre::Pass* CloudLayerPass);
197 
200  void _unregister();
201 
204  void _updateInternalPassParameters();
205 
206  private:
209  void _updatePassParameters();
210 
212  SkyX *mSkyX;
213 
215  Options mOptions;
216 
218  Ogre::Pass *mCloudLayerPass;
219 
221  ColorGradient mAmbientGradient;
222  ColorGradient mSunGradient;
223  };
224 
225  class DllExport CloudsManager
226  {
227  public:
231  CloudsManager(SkyX *h);
232 
235  ~CloudsManager();
236 
239  void update();
240 
245  CloudLayer* add(const CloudLayer::Options& o);
246 
249  void remove(CloudLayer *cl);
250 
253  void removeAll();
254 
257  void registerAll();
258 
262  void unregister(CloudLayer* cl);
263 
266  void unregisterAll();
267 
271  inline const std::vector<CloudLayer*>& getCloudLayers() const
272  {
273  return mCloudLayers;
274  }
275 
276  private:
278  SkyX *mSkyX;
279 
281  std::vector<CloudLayer*> mCloudLayers;
282 
284  std::vector<CloudLayer*>::iterator CloudLayersIt;
285  };
286 }
287 
288 #endif
SkyX(Ogre::SceneManager *sm, Controller *c)
Contructor.
class __declspec(dllimport) BasicController void update(const Ogre::Real &simDeltaTime)
Basic controller class.
#define DllExport
Include external headers.
Definition: Prerequisites.h:45