DataManager.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_DataManager_H_
25 #define _SkyX_VClouds_DataManager_H_
26 
27 #include <vector>
28 #include "Prerequisites.h"
29 
30 #include "VClouds/FastFakeRandom.h"
31 
32 namespace SkyX { namespace VClouds {
33 
34  class VClouds;
35  class Ellipsoid;
36 
38  {
39  public:
42  struct Cell
43  {
45  bool hum, act, cld;
46 
48  float phum, pext, pact;
49 
51  float dens;
52 
54  float light;
55  };
56 
60  {
61  VOL_TEX0 = 0,
62  VOL_TEX1 = 1
63  };
64 
68  DataManager(VClouds *vc);
69 
72  ~DataManager();
73 
79  void create(const int& nx, const int& ny, const int& nz);
80 
84  void update(const Ogre::Real &timeSinceLastFrame);
85 
88  void remove();
89 
93  inline const bool& isCreated() const
94  {
95  return mCreated;
96  }
97 
102  inline void setUpdateTime(const float& UpdateTime)
103  {
104  mUpdateTime = UpdateTime;
105  }
106 
110  inline const Ogre::Real& getUpdateTime() const
111  {
112  return mUpdateTime;
113  }
114 
119  inline const Ogre::Real _getInterpolation() const
120  {
121  return mCurrentTransition/mUpdateTime;
122  }
123 
138  void setWheater(const float& Humidity, const float& AverageCloudsSize,
139  const bool& delayedResponse = true);
140 
147  void addEllipsoid(Ellipsoid *e, const bool& UpdateProbabilities = true);
148 
151  void forceToUpdateData();
152 
153  private:
154 
160  void _initData(const int& nx, const int& ny, const int& nz);
161 
169  Cell *** _create3DCellArray(const int& nx, const int& ny, const int& nz,
170  const bool& init = true);
171 
177  void _delete3DCellArray(Cell ***c, const int& nx, const int& ny);
178 
186  void _copy3DCellArraysData(Cell ***src, Cell ***dest, const int& nx,
187  const int& ny, const int& nz);
188 
197  void _performCalculations(const int& nx, const int& ny, const int& nz,
198  const int& step, const int& xStart,
199  const int& xEnd);
200 
208  void _updateVolTextureData(Cell ***c, const VolTextureId& TexId,
209  const int& nx, const int& ny, const int& nz);
210 
222  float _getDensityAt(Cell ***c, const int& nx, const int& ny,
223  const int& nz, const int& x, const int& y, const int& z,
224  const int& r, const float& strength) const;
225 
232  float _getDensityAt(Cell ***c, const int& x, const int& y,
233  const int& z) const;
234 
244  bool _fact(Cell ***c, const int& nx, const int& ny,
245  const int& nz, const int& x, const int& y, const int& z) const;
246 
254  void _clearProbabilities(Cell*** c, const int& nx, const int& ny,
255  const int& nz, const bool& clearData);
256 
265  void _updateProbabilities(Cell*** c, const int& nx, const int& ny,
266  const int& nz, const bool& delayedResponse);
267 
279  Ogre::Real _getLightAbsorcionAt(Cell*** c, const int& nx,
280  const int& ny, const int& nz,
281  const int& x, const int& y,
282  const int& z, const Ogre::Vector3& d,
283  const float& att) const;
284 
291  void _createVolTexture(const VolTextureId& TexId, const int& nx,
292  const int& ny, const int& nz);
293 
295  VClouds *mVClouds;
296 
298  Cell ***mCellsCurrent, ***mCellsTmp;
299 
301  FastFakeRandom *mFFRandom;
302 
304  int mNx, mNy, mNz;
305 
307  float mCurrentTransition;
309  float mUpdateTime;
311  int mStep, mXStart, mXEnd;
312 
314  int mMaxNumberOfClouds;
315 
317  Ogre::TexturePtr mVolTextures[2];
318 
320  bool mVolTexToUpdate;
321 
323  bool mCreated;
324 
326  std::vector<Ellipsoid*> mEllipsoids;
327  };
328 }}
329 
330 #endif
Definition: FastFakeRandom.h:31
const Ogre::Real & getUpdateTime() const
Get update time.
Definition: DataManager.h:110
bool hum
Humidity, phase and cloud.
Definition: DataManager.h:45
Definition: VClouds.h:37
void create()
Create SkyX.
const bool & isCreated() const
Has been create(...) already called?
Definition: DataManager.h:93
Definition: DataManager.h:37
float light
Light absorcion.
Definition: DataManager.h:54
float phum
Probabilities.
Definition: DataManager.h:48
VolTextureId
Volumetric textures enumeration.
Definition: DataManager.h:59
Cell struct.
Definition: DataManager.h:42
Ellipsoid class x^2 y^2 z^2 / + / + / = 1 a^2 b^2 c^2.
Definition: Ellipsoid.h:38
GAZEBO_VISIBLE void init()
float dens
Continous density.
Definition: DataManager.h:51
SkyX(Ogre::SceneManager *sm, Controller *c)
Contructor.
void setUpdateTime(const float &UpdateTime)
Set update time.
Definition: DataManager.h:102
const Ogre::Real _getInterpolation() const
Get current interpolation factor.
Definition: DataManager.h:119
bool mCreated
Is SkyX created?
Definition: SkyX.h:422
class __declspec(dllimport) BasicController void update(const Ogre::Real &simDeltaTime)
Basic controller class.
#define DllExport
Include external headers.
Definition: Prerequisites.h:45