RigsofRods
Soft-body Physics Simulation
SimpleGrid.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_SimpleGrid_H_
26 #define _Hydrax_Modules_SimpleGrid_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 SimpleGrid : public Module
45  {
46  public:
49  struct Options
50  {
56  float Strength;
58  bool Smooth;
63 
67  : Complexity(256)
68  , MeshSize(Size(100))
69  , Strength(32.5f)
70  , Smooth(false)
71  , ChoppyWaves(true)
72  , ChoppyStrength(0.065f)
73  {
74  }
75 
80  Options(const int &_Complexity,
81  const Size &_MeshSize)
82  : Complexity(_Complexity)
83  , MeshSize(_MeshSize)
84  , Strength(32.5f)
85  , Smooth(false)
86  , ChoppyWaves(true)
87  , ChoppyStrength(0.065f)
88  {
89  }
90 
99  Options(const int &_Complexity,
100  const Size &_MeshSize,
101  const float &_Strength,
102  const bool &_Smooth,
103  const bool &_ChoppyWaves,
104  const float &_ChoppyStrength)
105  : Complexity(_Complexity)
106  , MeshSize(_MeshSize)
107  , Strength(_Strength)
108  , Smooth(_Smooth)
109  , ChoppyWaves(_ChoppyWaves)
110  , ChoppyStrength(_ChoppyStrength)
111  {
112  }
113  };
114 
120  SimpleGrid(Hydrax *h, Noise::Noise *n, const MaterialManager::NormalMode& NormalMode);
121 
128  SimpleGrid(Hydrax *h, Noise::Noise *n, const MaterialManager::NormalMode& NormalMode, const Options &Options);
129 
132  ~SimpleGrid();
133 
136  void create();
137 
140  void remove();
141 
145  void update(const Ogre::Real &timeSinceLastFrame);
146 
150  void setOptions(const Options &Options);
151 
155  void saveCfg(Ogre::String &Data);
156 
160  bool loadCfg(Ogre::ConfigFile &CfgFile);
161 
166  float getHeigth(const Ogre::Vector2 &Position);
167 
171  inline const Options& getOptions() const
172  {
173  return mOptions;
174  }
175 
176  private:
179  void _calculeNormals();
180 
183  void _performChoppyWaves();
184 
186  void *mVertices;
187 
190 
193 
196  };
197 }}
198 
201 
202 #endif
Hydrax::Module::SimpleGrid::Options::ChoppyWaves
bool ChoppyWaves
Choppy waves.
Definition: SimpleGrid.h:60
Hydrax::Module::SimpleGrid::SimpleGrid
SimpleGrid(Hydrax *h, Noise::Noise *n, const MaterialManager::NormalMode &NormalMode)
Constructor.
Definition: SimpleGrid.cpp:50
Hydrax::Module::SimpleGrid::Options::Strength
float Strength
Strength.
Definition: SimpleGrid.h:56
Hydrax
Definition: CfgFileManager.cpp:28
Hydrax::Module::SimpleGrid::Options::Options
Options(const int &_Complexity, const Size &_MeshSize)
Constructor.
Definition: SimpleGrid.h:80
Hydrax::Module::SimpleGrid::mVerticesChoppyBuffer
Mesh::POS_NORM_VERTEX * mVerticesChoppyBuffer
Use it to store vertex positions when choppy displacement is enabled.
Definition: SimpleGrid.h:189
Hydrax::Size
Struct wich contains an especific width and height value.
Definition: Help.h:40
Hydrax::Module::SimpleGrid::_calculeNormals
void _calculeNormals()
Calcule current normals.
Definition: SimpleGrid.cpp:371
Hydrax.h
Hydrax::Module::SimpleGrid::getHeigth
float getHeigth(const Ogre::Vector2 &Position)
Get the current heigth at a especified world-space point.
Definition: SimpleGrid.cpp:433
Hydrax::Module::SimpleGrid::Options::Options
Options(const int &_Complexity, const Size &_MeshSize, const float &_Strength, const bool &_Smooth, const bool &_ChoppyWaves, const float &_ChoppyStrength)
Constructor.
Definition: SimpleGrid.h:99
Hydrax::Module::SimpleGrid::_performChoppyWaves
void _performChoppyWaves()
Perform choppy waves.
Definition: SimpleGrid.cpp:406
Hydrax::Module::SimpleGrid::remove
void remove()
Remove.
Definition: SimpleGrid.cpp:208
Hydrax::Module::SimpleGrid::Options::Options
Options()
Default constructor.
Definition: SimpleGrid.h:66
Hydrax::Module::SimpleGrid::getOptions
const Options & getOptions() const
Get current options.
Definition: SimpleGrid.h:171
Hydrax::Module::SimpleGrid::loadCfg
bool loadCfg(Ogre::ConfigFile &CfgFile)
Load config.
Definition: SimpleGrid.cpp:249
Hydrax::Module::SimpleGrid::setOptions
void setOptions(const Options &Options)
Set options.
Definition: SimpleGrid.cpp:76
Hydrax::Noise::Noise
Base noise class, Override it for create different ways of create water noise.
Definition: Noise.h:42
Hydrax::Module::SimpleGrid
Hydrax simple grid module.
Definition: SimpleGrid.h:44
Hydrax::MaterialManager::NormalMode
NormalMode
Normal generation mode.
Definition: MaterialManager.h:100
Hydrax::Module::SimpleGrid::Options
Struct wich contains Hydrax simple grid module options.
Definition: SimpleGrid.h:49
Hydrax::Module::Module
Base module class, Override it for create different ways of create water noise.
Definition: Module.h:46
Hydrax::Module::SimpleGrid::Options::Complexity
int Complexity
Projected grid complexity (N*N)
Definition: SimpleGrid.h:52
Hydrax::Module::SimpleGrid::~SimpleGrid
~SimpleGrid()
Destructor.
Definition: SimpleGrid.cpp:69
Hydrax::Module::SimpleGrid::mHydrax
Hydrax * mHydrax
Our Hydrax pointer.
Definition: SimpleGrid.h:195
Hydrax::Module::SimpleGrid::saveCfg
void saveCfg(Ogre::String &Data)
Save config.
Definition: SimpleGrid.cpp:237
Hydrax::Module::SimpleGrid::Options::MeshSize
Size MeshSize
Size.
Definition: SimpleGrid.h:54
Hydrax::Module::SimpleGrid::update
void update(const Ogre::Real &timeSinceLastFrame)
Call it each frame.
Definition: SimpleGrid.cpp:267
Hydrax::Module::SimpleGrid::mOptions
Options mOptions
Our projected grid options.
Definition: SimpleGrid.h:192
Mesh.h
Hydrax::Mesh::POS_NORM_VERTEX
Vertex struct for position and normals data.
Definition: Mesh.h:60
Hydrax::Module::SimpleGrid::mVertices
void * mVertices
Vertex pointer (Mesh::POS_NORM_VERTEX or Mesh::POS_VERTEX)
Definition: SimpleGrid.h:186
Hydrax::Module::SimpleGrid::create
void create()
Create.
Definition: SimpleGrid.cpp:155
Module.h
Hydrax::Module::SimpleGrid::Options::ChoppyStrength
float ChoppyStrength
Choppy waves strength.
Definition: SimpleGrid.h:62
Hydrax::Module::SimpleGrid::Options::Smooth
bool Smooth
Smooth.
Definition: SimpleGrid.h:58