-
Notifications
You must be signed in to change notification settings - Fork 0
/
RadialGrid.h
230 lines (200 loc) · 6 KB
/
RadialGrid.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
/*
--------------------------------------------------------------------------------
This source file is part of Hydrax.
Visit ---
Copyright (C) 2008 Xavier Verguín González <xavierverguin@hotmail.com>
<xavyiy@gmail.com>
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free Software
Foundation; either version 2 of the License, or (at your option) any later
version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA, or go to
http://www.gnu.org/copyleft/lesser.txt.
--------------------------------------------------------------------------------
*/
#ifndef _Hydrax_Modules_RadialGrid_H_
#define _Hydrax_Modules_RadialGrid_H_
#include "Prerequisites.h"
#include "Hydrax.h"
#include "Mesh.h"
#include "Module.h"
namespace Hydrax{ namespace Module
{
/** Hydrax radial grid module
*/
class RadialGrid : public Module
{
public:
/** Struct wich contains Hydrax simple grid module options
*/
struct Options
{
/// Number of steps (Per circle)
int Steps;
/// Number of circles
int Circles;
/// Radius (In world units)
float Radius;
/// Smooth
bool Smooth;
/// Choppy waves
bool ChoppyWaves;
/// Choppy waves strength
float ChoppyStrength;
/// Step cube size
float StepSizeCube;
/// Step size five
float StepSizeFive;
/// Step lin size
float StepSizeLin;
/// Water strength
float Strength;
/** Default constructor
*/
Options()
: Steps(250)
, Circles(250)
, Radius(100)
, Smooth(false)
, ChoppyWaves(true)
, ChoppyStrength(3.5f)
, StepSizeCube(0.00001f)
, StepSizeFive(0.0f)
, StepSizeLin(0.1f)
, Strength(32.5f)
{
}
/** Constructor
@param _Steps Number of steps per circle
@param _Circles Number of circles
@param _Radius Mesh radius
*/
Options(const int &_Steps,
const int &_Circles,
const float &_Radius)
: Steps(_Steps)
, Circles(_Circles)
, Radius(_Radius)
, Smooth(false)
, ChoppyWaves(true)
, ChoppyStrength(3.5f)
, StepSizeCube(0.00001f)
, StepSizeFive(0.0f)
, StepSizeLin(0.1f)
, Strength(32.5f)
{
}
/** Constructor
@param _Steps Number of steps per circle
@param _Circles Number of circles
@param _Radius Mesh radius
@param _Smooth Smooth vertex?
@param _ChoppyWaves Choppy waves enabled? Note: Only with Materialmanager::NM_VERTEX normal mode.
@param _ChoppyStrength Choppy waves strength Note: Only with Materialmanager::NM_VERTEX normal mode.
@param _StepSizeCube Step cube size
@param _StepSizeFive Step five size
@param _StepSizeLin Step lin size
@param _Strength Water strength
*/
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)
: Steps(_Steps)
, Circles(_Circles)
, Radius(_Radius)
, Smooth(_Smooth)
, ChoppyWaves(_ChoppyWaves)
, ChoppyStrength(_ChoppyStrength)
, StepSizeCube(_StepSizeCube)
, StepSizeFive(_StepSizeFive)
, StepSizeLin(_StepSizeLin)
, Strength(_Strength)
{
}
};
/** Constructor
@param h Hydrax manager pointer
@param n Hydrax noise module
@param NormalMode Switch between MaterialManager::NM_VERTEX and Materialmanager::NM_RTT
*/
RadialGrid(Hydrax *h, Noise::Noise *n, const MaterialManager::NormalMode& NormalMode);
/** Constructor
@param h Hydrax manager pointer
@param n Hydrax noise module
@param NormalMode Switch between MaterialManager::NM_VERTEX and Materialmanager::NM_RTT
@param Options Perlin options
*/
RadialGrid(Hydrax *h, Noise::Noise *n, const MaterialManager::NormalMode& NormalMode, const Options &Options);
/** Destructor
*/
~RadialGrid();
/** Create
*/
void create();
/** Remove
*/
void remove();
/** Call it each frame
@param timeSinceLastFrame Time since last frame(delta)
*/
void update(const Ogre::Real &timeSinceLastFrame);
/** Set options
@param Options Options
*/
void setOptions(const Options &Options);
// /** Save config
// @param Data String reference
// */
// void saveCfg(Ogre::String &Data);
// /** Load config
// @param CgfFile Ogre::ConfigFile reference
// @return True if is the correct module config
// */
// bool loadCfg(Ogre::ConfigFile &CfgFile);
/** Get the current heigth at a especified world-space point
@param Position X/Z World position
@return Heigth at the given position in y-World coordinates, if it's outside of the water return -1
*/
float getHeigth(const Ogre::Vector2 &Position);
/** Get current options
@return Current options
*/
inline const Options& getOptions() const
{
return mOptions;
}
/** Create geometry in module(If special geometry is needed)
@param mMesh Mesh
@return false if it must be create by default Mesh::_createGeometry() fnc.
*/
const bool _createGeometry(Mesh *mMesh) const;
private:
/** Calcule current normals
*/
void _calculeNormals();
/** Perform choppy waves
*/
void _performChoppyWaves();
/// Vertex pointer (Mesh::POS_NORM_VERTEX or Mesh::POS_VERTEX)
void *mVertices;
/// Use it to store vertex positions when choppy displacement is enabled
Mesh::POS_NORM_VERTEX* mVerticesChoppyBuffer;
/// Our projected grid options
Options mOptions;
/// Our Hydrax pointer
Hydrax* mHydrax;
};
}}
#endif