Rigs of Rods 2023.09
Soft-body Physics Simulation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
DataManager.h
Go to the documentation of this file.
1/*
2--------------------------------------------------------------------------------
3This source file is part of SkyX.
4Visit http://www.paradise-studios.net/products/skyx/
5
6Copyright (C) 2009-2012 Xavier Vergu�n Gonz�lez <xavyiy@gmail.com>
7
8This program is free software; you can redistribute it and/or modify it under
9the terms of the GNU Lesser General Public License as published by the Free Software
10Foundation; either version 2 of the License, or (at your option) any later
11version.
12
13This program is distributed in the hope that it will be useful, but WITHOUT
14ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
16
17You should have received a copy of the GNU Lesser General Public License along with
18this program; if not, write to the Free Software Foundation, Inc., 59 Temple
19Place - Suite 330, Boston, MA 02111-1307, USA, or go to
20http://www.gnu.org/copyleft/lesser.txt.
21--------------------------------------------------------------------------------
22*/
23
24#ifndef _SkyX_VClouds_DataManager_H_
25#define _SkyX_VClouds_DataManager_H_
26
27#include "Prerequisites.h"
28
29#include "FastFakeRandom.h"
30
31namespace SkyX { namespace VClouds{
32
33 class VClouds;
34 class Ellipsoid;
35
37 {
38 public:
41 struct Cell
42 {
44 bool hum, act, cld;
45
47 float phum, pext, pact;
48
50 float dens;
51
53 float light;
54 };
55
59 {
61 VOL_TEX1 = 1
62 };
63
68
72
78 void create(const int& nx, const int& ny, const int& nz);
79
83 void update(const Ogre::Real &timeSinceLastFrame);
84
87 void remove();
88
92 inline const bool& isCreated() const
93 {
94 return mCreated;
95 }
96
100 inline void setUpdateTime(const float& UpdateTime)
101 {
102 mUpdateTime = UpdateTime;
103 }
104
108 inline const Ogre::Real& getUpdateTime() const
109 {
110 return mUpdateTime;
111 }
112
117 inline const Ogre::Real _getInterpolation() const
118 {
120 }
121
130 void setWheater(const float& Humidity, const float& AverageCloudsSize, const bool& delayedResponse = true);
131
137 void addEllipsoid(Ellipsoid *e, const bool& UpdateProbabilities = true);
138
141 void forceToUpdateData();
142
143 private:
144
150 void _initData(const int& nx, const int& ny, const int& nz);
151
159 Cell *** _create3DCellArray(const int& nx, const int& ny, const int& nz, const bool& init = true);
160
166 void _delete3DCellArray(Cell ***c, const int& nx, const int& ny);
167
175 void _copy3DCellArraysData(Cell ***src, Cell ***dest, const int& nx, const int& ny, const int& nz);
176
185 void _performCalculations(const int& nx, const int& ny, const int& nz, const int& step, const int& xStart, const int& xEnd);
186
194 void _updateVolTextureData(Cell ***c, const VolTextureId& TexId, const int& nx, const int& ny, const int& nz);
195
207 const float _getDensityAt(Cell ***c, const int& nx, const int& ny, const int& nz, const int& x, const int& y, const int& z, const int& r, const float& strength) const;
208
215 const float _getDensityAt(Cell ***c, const int& x, const int& y, const int& z) const;
216
226 const bool _fact(Cell ***c, const int& nx, const int& ny, const int& nz, const int& x, const int& y, const int& z) const;
227
235 void _clearProbabilities(Cell*** c, const int& nx, const int& ny, const int& nz, const bool& clearData);
236
244 void _updateProbabilities(Cell*** c, const int& nx, const int& ny, const int& nz, const bool& delayedResponse);
245
257 const Ogre::Real _getLightAbsorcionAt(Cell*** c, const int& nx, const int& ny, const int& nz, const int& x, const int& y, const int& z, const Ogre::Vector3& d, const float& att) const;
258
265 void _createVolTexture(const VolTextureId& TexId, const int& nx, const int& ny, const int& nz);
266
270
277
279 int mNx, mNy, mNz;
280
282 Ogre::TexturePtr mVolTextures[2];
285
288
291
295 std::vector<Ellipsoid*> mEllipsoids;
296
299 };
300
301}}
302
303#endif
VClouds * mVClouds
SkyX parent pointer.
int mMaxNumberOfClouds
Max number of clouds(Ellipsoids)
const Ogre::Real _getInterpolation() const
Get current interpolation factor.
float mCurrentTransition
Current transition.
Cell *** mCellsCurrent
Simulation data.
void _updateProbabilities(Cell ***c, const int &nx, const int &ny, const int &nz, const bool &delayedResponse)
Update probabilities based from the Ellipsoid vector.
std::vector< Ellipsoid * > mEllipsoids
Ellipsoids.
const bool & isCreated() const
Has been create(...) already called?
Definition DataManager.h:92
const Ogre::Real _getLightAbsorcionAt(Cell ***c, const int &nx, const int &ny, const int &nz, const int &x, const int &y, const int &z, const Ogre::Vector3 &d, const float &att) const
Get light absorcion factor at a point.
void setWheater(const float &Humidity, const float &AverageCloudsSize, const bool &delayedResponse=true)
Set wheater parameters Use this funtion to update the cloud field parameters, you'll get a smart and ...
void addEllipsoid(Ellipsoid *e, const bool &UpdateProbabilities=true)
Add ellipsoid: clouds are modelled as ellipsoids in our simulation approach, so.
bool mVolTexToUpdate
Current texture.
void create(const int &nx, const int &ny, const int &nz)
Create.
FastFakeRandom * mFFRandom
Fast fake random.
void _updateVolTextureData(Cell ***c, const VolTextureId &TexId, const int &nx, const int &ny, const int &nz)
Update volumetric texture data.
void _initData(const int &nx, const int &ny, const int &nz)
Initialize data.
void setUpdateTime(const float &UpdateTime)
Set update time.
const float _getDensityAt(Cell ***c, const int &nx, const int &ny, const int &nz, const int &x, const int &y, const int &z, const int &r, const float &strength) const
Get continous density at a point.
const Ogre::Real & getUpdateTime() const
Get update time.
int mStep
Current calculation state.
VolTextureId
Volumetric textures enumeration.
Definition DataManager.h:59
bool mCreated
Has been create(...) already called?
void forceToUpdateData()
Forces the data manager to calculate the next step right now.
const bool _fact(Cell ***c, const int &nx, const int &ny, const int &nz, const int &x, const int &y, const int &z) const
Fact funtion.
Cell *** _create3DCellArray(const int &nx, const int &ny, const int &nz, const bool &init=true)
Create tridimensional cell array.
Ogre::TexturePtr mVolTextures[2]
Volumetric textures array.
void _clearProbabilities(Cell ***c, const int &nx, const int &ny, const int &nz, const bool &clearData)
Clear probabilities.
void _createVolTexture(const VolTextureId &TexId, const int &nx, const int &ny, const int &nz)
Create volumetric texture.
float mUpdateTime
Update time.
void _delete3DCellArray(Cell ***c, const int &nx, const int &ny)
Delete tridimensional cell array.
void _performCalculations(const int &nx, const int &ny, const int &nz, const int &step, const int &xStart, const int &xEnd)
Perform celullar automata simulation.
void _copy3DCellArraysData(Cell ***src, Cell ***dest, const int &nx, const int &ny, const int &nz)
Copy 3d cells arrays data.
void update(const Ogre::Real &timeSinceLastFrame)
Update.
Ellipsoid class x^2 y^2 z^2 / + / + / = 1 a^2 b^2 c^2.
Definition Ellipsoid.h:39
float dens
Continous density.
Definition DataManager.h:50
float light
Light absorcion.
Definition DataManager.h:53
bool hum
Humidity, phase and cloud.
Definition DataManager.h:44