RigsofRods
Soft-body Physics Simulation
RadialGrid.h
Go to the documentation of this file.
1 /*
2 --------------------------------------------------------------------------------
3 This source file is part of Hydrax.
4 Visit ---
5 
6 Copyright (C) 2008 Xavier Verguín González <xavierverguin@hotmail.com>
7  <xavyiy@gmail.com>
8 
9 This program is free software; you can redistribute it and/or modify it under
10 the terms of the GNU Lesser General Public License as published by the Free Software
11 Foundation; either version 2 of the License, or (at your option) any later
12 version.
13 
14 This program is distributed in the hope that it will be useful, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
17 
18 You should have received a copy of the GNU Lesser General Public License along with
19 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
20 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
21 http://www.gnu.org/copyleft/lesser.txt.
22 --------------------------------------------------------------------------------
23 */
24 
25 #ifndef _Hydrax_Modules_RadialGrid_H_
26 #define _Hydrax_Modules_RadialGrid_H_
27 
28 
29 
30 #include "Hydrax.h"
31 #include "Mesh.h"
32 #include "Module.h"
33 
36 
39 
40 namespace Hydrax{ namespace Module
41 {
44  class RadialGrid : public Module
45  {
46  public:
49  struct Options
50  {
52  int Steps;
54  int Circles;
56  float Radius;
58  bool Smooth;
64  float StepSizeCube;
66  float StepSizeFive;
68  float StepSizeLin;
70  float Strength;
71 
75  : Steps(250)
76  , Circles(250)
77  , Radius(100)
78  , Smooth(false)
79  , ChoppyWaves(true)
80  , ChoppyStrength(3.5f)
81  , StepSizeCube(0.00001f)
82  , StepSizeFive(0.0f)
83  , StepSizeLin(0.1f)
84  , Strength(32.5f)
85  {
86  }
87 
93  Options(const int &_Steps,
94  const int &_Circles,
95  const float &_Radius)
96  : Steps(_Steps)
97  , Circles(_Circles)
98  , Radius(_Radius)
99  , Smooth(false)
100  , ChoppyWaves(true)
101  , ChoppyStrength(3.5f)
102  , StepSizeCube(0.00001f)
103  , StepSizeFive(0.0f)
104  , StepSizeLin(0.1f)
105  , Strength(32.5f)
106  {
107  }
108 
121  Options(const int &_Steps,
122  const int &_Circles,
123  const float &_Radius,
124  const bool &_Smooth,
125  const bool &_ChoppyWaves,
126  const float &_ChoppyStrength,
127  const float &_StepSizeCube,
128  const float &_StepSizeFive,
129  const float &_StepSizeLin,
130  const float &_Strength)
131  : Steps(_Steps)
132  , Circles(_Circles)
133  , Radius(_Radius)
134  , Smooth(_Smooth)
135  , ChoppyWaves(_ChoppyWaves)
136  , ChoppyStrength(_ChoppyStrength)
137  , StepSizeCube(_StepSizeCube)
138  , StepSizeFive(_StepSizeFive)
139  , StepSizeLin(_StepSizeLin)
140  , Strength(_Strength)
141  {
142  }
143  };
144 
150  RadialGrid(Hydrax *h, Noise::Noise *n, const MaterialManager::NormalMode& NormalMode);
151 
158  RadialGrid(Hydrax *h, Noise::Noise *n, const MaterialManager::NormalMode& NormalMode, const Options &Options);
159 
162  ~RadialGrid();
163 
166  void create();
167 
170  void remove();
171 
175  void update(const Ogre::Real &timeSinceLastFrame);
176 
180  void setOptions(const Options &Options);
181 
185  void saveCfg(Ogre::String &Data);
186 
190  bool loadCfg(Ogre::ConfigFile &CfgFile);
191 
196  float getHeigth(const Ogre::Vector2 &Position);
197 
201  inline const Options& getOptions() const
202  {
203  return mOptions;
204  }
205 
210  const bool _createGeometry(Mesh *mMesh) const;
211 
212  private:
215  void _calculeNormals();
216 
219  void _performChoppyWaves();
220 
222  void *mVertices;
223 
226 
229 
232  };
233 }}
234 
237 
238 #endif
Hydrax::Module::RadialGrid::update
void update(const Ogre::Real &timeSinceLastFrame)
Call it each frame.
Definition: RadialGrid.cpp:434
Hydrax::Module::RadialGrid::saveCfg
void saveCfg(Ogre::String &Data)
Save config.
Definition: RadialGrid.cpp:396
Hydrax::Module::RadialGrid::Options::Options
Options(const int &_Steps, const int &_Circles, const float &_Radius, const bool &_Smooth, const bool &_ChoppyWaves, const float &_ChoppyStrength, const float &_StepSizeCube, const float &_StepSizeFive, const float &_StepSizeLin, const float &_Strength)
Constructor.
Definition: RadialGrid.h:121
Hydrax::Module::RadialGrid
Hydrax radial grid module.
Definition: RadialGrid.h:44
Hydrax::Module::RadialGrid::_createGeometry
const bool _createGeometry(Mesh *mMesh) const
Create geometry in module(If special geometry is needed)
Definition: RadialGrid.cpp:254
Hydrax
Definition: CfgFileManager.cpp:28
Hydrax::Module::RadialGrid::Options::Circles
int Circles
Number of circles.
Definition: RadialGrid.h:54
Hydrax::Module::RadialGrid::Options::StepSizeFive
float StepSizeFive
Step size five.
Definition: RadialGrid.h:66
Hydrax.h
Hydrax::Module::RadialGrid::_calculeNormals
void _calculeNormals()
Calcule current normals.
Definition: RadialGrid.cpp:528
Hydrax::Module::RadialGrid::getOptions
const Options & getOptions() const
Get current options.
Definition: RadialGrid.h:201
Hydrax::Module::RadialGrid::Options::StepSizeLin
float StepSizeLin
Step lin size.
Definition: RadialGrid.h:68
Hydrax::Module::RadialGrid::mOptions
Options mOptions
Our projected grid options.
Definition: RadialGrid.h:228
Hydrax::Module::RadialGrid::getHeigth
float getHeigth(const Ogre::Vector2 &Position)
Get the current heigth at a especified world-space point.
Definition: RadialGrid.cpp:665
Hydrax::Module::RadialGrid::mVerticesChoppyBuffer
Mesh::POS_NORM_VERTEX * mVerticesChoppyBuffer
Use it to store vertex positions when choppy displacement is enabled.
Definition: RadialGrid.h:225
Hydrax::Module::RadialGrid::Options::Options
Options(const int &_Steps, const int &_Circles, const float &_Radius)
Constructor.
Definition: RadialGrid.h:93
Hydrax::Noise::Noise
Base noise class, Override it for create different ways of create water noise.
Definition: Noise.h:42
Hydrax::MaterialManager::NormalMode
NormalMode
Normal generation mode.
Definition: MaterialManager.h:100
Hydrax::Module::RadialGrid::mHydrax
Hydrax * mHydrax
Our Hydrax pointer.
Definition: RadialGrid.h:231
Hydrax::Module::Module
Base module class, Override it for create different ways of create water noise.
Definition: Module.h:46
Hydrax::Module::RadialGrid::Options::StepSizeCube
float StepSizeCube
Step cube size.
Definition: RadialGrid.h:64
Hydrax::Mesh
Class wich contains all funtions/variables related to Hydrax water mesh.
Definition: Mesh.h:46
Hydrax::Module::RadialGrid::Options::Options
Options()
Default constructor.
Definition: RadialGrid.h:74
Hydrax::Module::RadialGrid::Options::Strength
float Strength
Water strength.
Definition: RadialGrid.h:70
Hydrax::Module::RadialGrid::setOptions
void setOptions(const Options &Options)
Set options.
Definition: RadialGrid.cpp:76
Hydrax::Module::RadialGrid::loadCfg
bool loadCfg(Ogre::ConfigFile &CfgFile)
Load config.
Definition: RadialGrid.cpp:412
Mesh.h
Hydrax::Module::RadialGrid::mVertices
void * mVertices
Vertex pointer (Mesh::POS_NORM_VERTEX or Mesh::POS_VERTEX)
Definition: RadialGrid.h:222
Hydrax::Mesh::POS_NORM_VERTEX
Vertex struct for position and normals data.
Definition: Mesh.h:60
Hydrax::Module::RadialGrid::Options
Struct wich contains Hydrax simple grid module options.
Definition: RadialGrid.h:49
Hydrax::Module::RadialGrid::Options::ChoppyStrength
float ChoppyStrength
Choppy waves strength.
Definition: RadialGrid.h:62
Hydrax::Module::RadialGrid::remove
void remove()
Remove.
Definition: RadialGrid.cpp:367
Hydrax::Module::RadialGrid::Options::Radius
float Radius
Radius (In world units)
Definition: RadialGrid.h:56
Hydrax::Module::RadialGrid::Options::Steps
int Steps
Number of steps (Per circle)
Definition: RadialGrid.h:52
Hydrax::Module::RadialGrid::_performChoppyWaves
void _performChoppyWaves()
Perform choppy waves.
Definition: RadialGrid.cpp:603
Module.h
Hydrax::Module::RadialGrid::create
void create()
Create.
Definition: RadialGrid.cpp:173
Hydrax::Module::RadialGrid::Options::ChoppyWaves
bool ChoppyWaves
Choppy waves.
Definition: RadialGrid.h:60
Hydrax::Module::RadialGrid::Options::Smooth
bool Smooth
Smooth.
Definition: RadialGrid.h:58
Hydrax::Module::RadialGrid::RadialGrid
RadialGrid(Hydrax *h, Noise::Noise *n, const MaterialManager::NormalMode &NormalMode)
Constructor.
Definition: RadialGrid.cpp:50
Hydrax::Module::RadialGrid::~RadialGrid
~RadialGrid()
Destructor.
Definition: RadialGrid.cpp:69