Rigs of Rods 2023.09
Soft-body Physics Simulation
Loading...
Searching...
No Matches
SimpleGrid.h
Go to the documentation of this file.
1/*
2--------------------------------------------------------------------------------
3This source file is part of Hydrax.
4Visit ---
5
6Copyright (C) 2008 Xavier Verguín González <xavierverguin@hotmail.com>
7 <xavyiy@gmail.com>
8
9This program is free software; you can redistribute it and/or modify it under
10the terms of the GNU Lesser General Public License as published by the Free Software
11Foundation; either version 2 of the License, or (at your option) any later
12version.
13
14This program is distributed in the hope that it will be useful, but WITHOUT
15ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
17
18You should have received a copy of the GNU Lesser General Public License along with
19this program; if not, write to the Free Software Foundation, Inc., 59 Temple
20Place - Suite 330, Boston, MA 02111-1307, USA, or go to
21http://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
40namespace 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
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
187
190
193
196 };
197}}
198
201
202#endif
NormalMode
Normal generation mode.
Base module class, Override it for create different ways of create water noise.
Definition Module.h:47
Hydrax simple grid module.
Definition SimpleGrid.h:45
Hydrax * mHydrax
Our Hydrax pointer.
Definition SimpleGrid.h:195
bool loadCfg(Ogre::ConfigFile &CfgFile)
Load config.
Mesh::POS_NORM_VERTEX * mVerticesChoppyBuffer
Use it to store vertex positions when choppy displacement is enabled.
Definition SimpleGrid.h:189
void _performChoppyWaves()
Perform choppy waves.
void setOptions(const Options &Options)
Set options.
const Options & getOptions() const
Get current options.
Definition SimpleGrid.h:171
Options mOptions
Our projected grid options.
Definition SimpleGrid.h:192
float getHeigth(const Ogre::Vector2 &Position)
Get the current heigth at a especified world-space point.
void update(const Ogre::Real &timeSinceLastFrame)
Call it each frame.
void * mVertices
Vertex pointer (Mesh::POS_NORM_VERTEX or Mesh::POS_VERTEX)
Definition SimpleGrid.h:186
void _calculeNormals()
Calcule current normals.
void saveCfg(Ogre::String &Data)
Save config.
Base noise class, Override it for create different ways of create water noise.
Definition Noise.h:43
Vertex struct for position and normals data.
Definition Mesh.h:61
Struct wich contains Hydrax simple grid module options.
Definition SimpleGrid.h:50
Options(const int &_Complexity, const Size &_MeshSize)
Constructor.
Definition SimpleGrid.h:80
float ChoppyStrength
Choppy waves strength.
Definition SimpleGrid.h:62
Options()
Default constructor.
Definition SimpleGrid.h:66
Options(const int &_Complexity, const Size &_MeshSize, const float &_Strength, const bool &_Smooth, const bool &_ChoppyWaves, const float &_ChoppyStrength)
Constructor.
Definition SimpleGrid.h:99
int Complexity
Projected grid complexity (N*N)
Definition SimpleGrid.h:52
Struct wich contains an especific width and height value.
Definition Help.h:41