All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
VClouds.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_VClouds_H_
25 #define _SkyX_VClouds_VClouds_H_
26 
27 #include <vector>
28 
29 #include "Prerequisites.h"
30 
31 #include "VClouds/DataManager.h"
34 
35 namespace SkyX { namespace VClouds {
36 
38  {
39  public:
43  {
48  inline RenderQueueGroups(const Ogre::uint8& vc, const Ogre::uint8& vcl)
49  : vclouds(vc), vcloudsLightnings(vcl)
50  {
51  }
52 
54  Ogre::uint8 vclouds;
56  Ogre::uint8 vcloudsLightnings;
57  };
58 
62  {
65  Ogre::Vector2 Height;
67  Ogre::Radian Alpha, Beta;
69  float Radius;
73  int Na, Nb, Nc;
74 
78  : Height(Ogre::Vector2(10, 50))
79  , Alpha(Ogre::Degree(12)), Beta(Ogre::Degree(40))
80  , Radius(100)
81  , NumberOfBlocks(12)
82  , Na(10), Nb(8), Nc(6)
83  {
84  }
85 
97  GeometrySettings(const Ogre::Vector2& _Height, const float& _Radius,
98  const Ogre::Radian& _Alpha = Ogre::Degree(12),
99  const Ogre::Radian& _Beta = Ogre::Degree(40),
100  const int& _NumberOfBlocks = 12, const int& _Na = 10,
101  const int& _Nb = 8, const int& _Nc = 6)
102  : Height(_Height)
103  , Alpha(_Alpha), Beta(_Beta)
104  , Radius(_Radius)
105  , NumberOfBlocks(_NumberOfBlocks)
106  , Na(_Na), Nb(_Nb), Nc(_Nc)
107  {
108  }
109  };
110 
113  struct CameraData
114  {
115  public:
118  inline CameraData()
119  : camera(0)
120  , lastPosition(Ogre::Vector3(0, 0, 0))
121  , cameraOffset(Ogre::Vector2(0, 0))
122  , geometryDisplacement(Ogre::Vector3(0, 0, 0))
123  {
124  }
125 
129  explicit inline CameraData(Ogre::Camera* c)
130  : camera(c)
131  , lastPosition(c->getDerivedPosition())
132  , cameraOffset(Ogre::Vector2(0, 0))
133  , geometryDisplacement(Ogre::Vector3(0, 0, 0))
134  {
135  }
136 
138  Ogre::Camera* camera;
140  Ogre::Vector3 lastPosition;
142  Ogre::Vector2 cameraOffset;
144  Ogre::Vector3 geometryDisplacement;
145  };
146 
150  VClouds(Ogre::SceneManager *sm);
151 
154  ~VClouds();
155 
158  void create();
159 
163  void create(const GeometrySettings& gs);
164 
170  void create(const Ogre::Vector2& Height, const float& Radius);
171 
174  void remove();
175 
179  void update(const Ogre::Real& timeSinceLastFrame);
180 
185  void notifyCameraRender(Ogre::Camera* c,
186  const Ogre::Real& timeSinceLastCameraFrame);
187 
195  void registerCamera(Ogre::Camera* c);
196 
202  void unregisterCamera(Ogre::Camera* c);
203 
207  inline const bool& isCreated() const
208  {
209  return mCreated;
210  }
211 
216  inline void setGeometrySettings(const GeometrySettings& gs)
217  {
218  mGeometrySettings = gs;
219  }
220 
224  inline const GeometrySettings& getGeometrySettings() const
225  {
226  return mGeometrySettings;
227  }
228 
240  const Ogre::Vector2& DistanceFallingParams)
241  {
242  mDistanceFallingParams = DistanceFallingParams;
243  }
244 
259  inline const Ogre::Vector2& getDistanceFallingParams() const
260  {
261  return mDistanceFallingParams;
262  }
263 
267  void setRenderQueueGroups(const RenderQueueGroups& rqg);
268 
273  {
274  return mRenderQueueGroups;
275  }
276 
280  inline void setWindDirection(const Ogre::Radian& WindDirection)
281  {
282  mWindDirection = WindDirection;
283  }
284 
288  inline const Ogre::Radian& getWindDirection() const
289  {
290  return mWindDirection;
291  }
292 
296  inline const Ogre::Vector2 getWindDirectionV2() const
297  {
298  return Ogre::Vector2(Ogre::Math::Cos(mWindDirection),
299  Ogre::Math::Sin(mWindDirection));
300  }
301 
305  inline void setWindSpeed(const float& WindSpeed)
306  {
307  mWindSpeed = WindSpeed;
308  }
309 
313  inline const float& getWindSpeed() const
314  {
315  return mWindSpeed;
316  }
317 
321  inline void setSunDirection(const Ogre::Vector3& SunDirection)
322  {
323  mSunDirection = SunDirection;
324  }
325 
329  inline const Ogre::Vector3& getSunDirection() const
330  {
331  return mSunDirection;
332  }
333 
337  void setSunColor(const Ogre::Vector3& SunColor);
338 
342  inline const Ogre::Vector3& getSunColor() const
343  {
344  return mSunColor;
345  }
346 
350  void setAmbientColor(const Ogre::Vector3& AmbientColor);
351 
355  inline const Ogre::Vector3& getAmbientColor() const
356  {
357  return mAmbientColor;
358  }
359 
367  void setLightResponse(const Ogre::Vector4& LightResponse);
368 
372  inline const Ogre::Vector4& getLightResponse() const
373  {
374  return mLightResponse;
375  }
376 
380  void setAmbientFactors(const Ogre::Vector4& AmbientFactors);
381 
385  inline const Ogre::Vector4& getAmbientFactors() const
386  {
387  return mAmbientFactors;
388  }
389 
393  inline void setGlobalOpacity(const Ogre::Real& GlobalOpacity)
394  {
395  mGlobalOpacity = GlobalOpacity;
396  }
397 
401  inline const Ogre::Real& getGlobalOpacity() const
402  {
403  return mGlobalOpacity;
404  }
405 
409  inline void setCloudFieldScale(const Ogre::Real& CloudFieldScale)
410  {
411  mCloudFieldScale = CloudFieldScale;
412  }
413 
417  inline const Ogre::Real& getCloudFieldScale() const
418  {
419  return mCloudFieldScale;
420  }
421 
425  inline void setNoiseScale(const Ogre::Real& NoiseScale)
426  {
427  mNoiseScale = NoiseScale;
428  }
429 
433  inline const Ogre::Real& getNoiseScale() const
434  {
435  return mNoiseScale;
436  }
437 
451  void setWheater(const float& Humidity, const float& AverageCloudsSize,
452  const bool& DelayedResponse);
453 
458  inline const Ogre::Vector2& getWheater() const
459  {
460  return mWheater;
461  }
462 
466  void setVisible(const bool& visible);
467 
471  void setEnabled(bool _enabled);
472 
476  inline const bool& isVisible() const
477  {
478  return mVisible;
479  }
480 
484  inline Ogre::SceneManager* getSceneManager()
485  {
486  return mSceneManager;
487  }
488 
492  inline Ogre::Camera* getCamera()
493  {
494  return mCamera;
495  }
496 
501  {
502  return mDataManager;
503  }
504 
509  {
510  return mGeometryManager;
511  }
512 
517  {
518  return mLightningManager;
519  }
520 
525  inline std::vector<CameraData>& _getCamerasData()
526  {
527  return mCamerasData;
528  }
529 
530  private:
532  Ogre::SceneManager *mSceneManager;
533 
535  Ogre::Camera* mCamera;
536 
538  bool mCreated;
539 
541  GeometrySettings mGeometrySettings;
542 
544  Ogre::Vector2 mDistanceFallingParams;
545 
547  RenderQueueGroups mRenderQueueGroups;
548 
550  Ogre::Radian mWindDirection;
552  float mWindSpeed;
553 
556  Ogre::Vector2 mWheater;
559  bool mDelayedResponse;
560 
562  Ogre::Vector3 mSunDirection;
563 
565  Ogre::Vector3 mSunColor;
567  Ogre::Vector3 mAmbientColor;
568 
575  Ogre::Vector4 mLightResponse;
579  Ogre::Vector4 mAmbientFactors;
580 
582  float mGlobalOpacity;
583 
585  float mCloudFieldScale;
587  float mNoiseScale;
588 
590  bool mVisible;
591 
593  DataManager *mDataManager;
595  GeometryManager *mGeometryManager;
597  LightningManager *mLightningManager;
598 
600  std::vector<CameraData> mCamerasData;
601 
603  Ogre::MaterialPtr mVolCloudsMaterial;
604 
606  Ogre::MaterialPtr mVolCloudsLightningMaterial;
607  };
608 }}
609 
610 #endif
const Ogre::Vector2 & getWheater() const
Get wheater.
Definition: VClouds.h:458
CameraData()
Default constructor.
Definition: VClouds.h:118
CameraData(Ogre::Camera *c)
Constructor.
Definition: VClouds.h:129
LightningManager * getLightningManager()
Get lightning manager.
Definition: VClouds.h:516
const Ogre::Vector2 & getDistanceFallingParams() const
Get distance falling params.
Definition: VClouds.h:259
const bool & isCreated() const
Has been create() already called?
Definition: VClouds.h:207
float Radius
Radius.
Definition: VClouds.h:69
const Ogre::Vector4 & getAmbientFactors() const
Get ambient factors.
Definition: VClouds.h:385
const Ogre::Vector2 getWindDirectionV2() const
Get wind direction as a Vector2.
Definition: VClouds.h:296
Ogre::uint8 vclouds
VClouds render queue group.
Definition: VClouds.h:54
Ogre::uint8 vclouds
VClouds render queue group.
Definition: SkyX.h:83
const RenderQueueGroups & getRenderQueueGroups() const
Get render queue groups.
Definition: VClouds.h:272
const Ogre::Real & getGlobalOpacity() const
Get global opacity.
Definition: VClouds.h:401
Ogre::Camera * getCamera()
Get current rendering camera.
Definition: VClouds.h:492
GeometryManager * getGeometryManager()
Get geometry manager.
Definition: VClouds.h:508
Definition: LightningManager.h:37
const Ogre::Vector3 & getSunColor() const
Get sun color.
Definition: VClouds.h:342
DataManager * getDataManager()
Get data manager.
Definition: VClouds.h:500
const Ogre::Real & getCloudFieldScale() const
Get cloud field scale.
Definition: VClouds.h:417
Camera data struct.
Definition: VClouds.h:113
Ogre::Vector2 Height
Height: x = Altitude over the camera, y: Field height (both in world coordinates) ...
Definition: VClouds.h:65
const Ogre::Vector3 & getAmbientColor() const
Get Ambient color.
Definition: VClouds.h:355
Definition: VClouds.h:37
void create()
Create SkyX.
Ogre::uint8 vcloudsLightnings
VClouds lightnings render queue group.
Definition: SkyX.h:85
void notifyCameraRender(Ogre::Camera *c)
Notify camera render (to be invoked per camera and per frame)
Definition: GeometryManager.h:36
Ogre::Radian Beta
Definition: VClouds.h:67
Definition: DataManager.h:37
Ogre::Camera * mCamera
Current rendering camera.
Definition: SkyX.h:404
GeometrySettings()
Default constructor.
Definition: VClouds.h:77
Ogre::Vector3 lastPosition
Last camera position.
Definition: VClouds.h:140
Ogre::Vector2 cameraOffset
Camera offset.
Definition: VClouds.h:142
const Ogre::Vector4 & getLightResponse() const
Get light response.
Definition: VClouds.h:372
Ogre::Camera * camera
Camera.
Definition: VClouds.h:138
RenderQueueGroups(const Ogre::uint8 &vc, const Ogre::uint8 &vcl)
Constructor.
Definition: VClouds.h:48
Ogre::Vector3 mSunDirection
Sun direction.
Definition: BasicController.h:128
const Ogre::Real & getNoiseScale() const
Get noise scale.
Definition: VClouds.h:433
const float & getWindSpeed() const
Get wind speed.
Definition: VClouds.h:313
void setSunDirection(const Ogre::Vector3 &SunDirection)
Set sun direction.
Definition: VClouds.h:321
void setCloudFieldScale(const Ogre::Real &CloudFieldScale)
Set cloud field scale.
Definition: VClouds.h:409
const bool & isVisible() const
Is VClouds visible?
Definition: VClouds.h:476
const Ogre::Vector3 & getSunDirection() const
Get sun direction.
Definition: VClouds.h:329
std::vector< CameraData > & _getCamerasData()
Get cameras data.
Definition: VClouds.h:525
Geometry settings.
Definition: VClouds.h:61
SkyX(Ogre::SceneManager *sm, Controller *c)
Contructor.
void setWindDirection(const Ogre::Radian &WindDirection)
Set wind direction.
Definition: VClouds.h:280
void setEnabled(bool _enabled)
Definition: SkyX.h:355
void setWindSpeed(const float &WindSpeed)
Set wind speed.
Definition: VClouds.h:305
void setRenderQueueGroups(const RenderQueueGroups &rqg)
Set render queue groups.
Ogre::Vector3 geometryDisplacement
Geometry displacement.
Definition: VClouds.h:144
bool mCreated
Is SkyX created?
Definition: SkyX.h:422
GeometrySettings(const Ogre::Vector2 &_Height, const float &_Radius, const Ogre::Radian &_Alpha=Ogre::Degree(12), const Ogre::Radian &_Beta=Ogre::Degree(40), const int &_NumberOfBlocks=12, const int &_Na=10, const int &_Nb=8, const int &_Nc=6)
Constructor.
Definition: VClouds.h:97
void setGlobalOpacity(const Ogre::Real &GlobalOpacity)
Set global opacity.
Definition: VClouds.h:393
void setDistanceFallingParams(const Ogre::Vector2 &DistanceFallingParams)
Set distance falling params.
Definition: VClouds.h:239
RenderQueueGroups mRenderQueueGroups
Render queue groups.
Definition: SkyX.h:419
const GeometrySettings & getGeometrySettings() const
Get geometry settings.
Definition: VClouds.h:224
void setVisible(const bool &visible)
Set visible.
void setNoiseScale(const Ogre::Real &NoiseScale)
Set noise scale.
Definition: VClouds.h:425
int Nc
Definition: VClouds.h:73
Ogre::SceneManager * getSceneManager()
Get scene manager.
Definition: VClouds.h:484
Ogre::uint8 vcloudsLightnings
VClouds lightnings render queue group.
Definition: VClouds.h:56
Ogre::SceneManager * mSceneManager
Scene manager.
Definition: SkyX.h:398
void setGeometrySettings(const GeometrySettings &gs)
Set geometry settings.
Definition: VClouds.h:216
int NumberOfBlocks
Number of blocks.
Definition: VClouds.h:71
Render queue groups.
Definition: VClouds.h:42
class __declspec(dllimport) BasicController void update(const Ogre::Real &simDeltaTime)
Basic controller class.
#define DllExport
Include external headers.
Definition: Prerequisites.h:45
bool mVisible
Is SkyX visible?
Definition: SkyX.h:432
const Ogre::Radian & getWindDirection() const
Get wind direction.
Definition: VClouds.h:288