RigsofRods
Soft-body Physics Simulation
Data Structures | Public Member Functions | Private Member Functions | Private Attributes
Hydrax::Noise::FFT Class Reference

FFT noise module class. More...

#include <FFT.h>

+ Inheritance diagram for Hydrax::Noise::FFT:
+ Collaboration diagram for Hydrax::Noise::FFT:

Data Structures

struct  Options
 Struct wich contains fft noise module options. More...
 

Public Member Functions

 FFT ()
 Default constructor. More...
 
 FFT (const Options &Options)
 Constructor. More...
 
 ~FFT ()
 Destructor. More...
 
void create ()
 Create. More...
 
bool createGPUNormalMapResources (GPUNormalMapManager *g)
 Create GPUNormalMap resources. More...
 
void remove ()
 Remove. More...
 
void update (const Ogre::Real &timeSinceLastFrame)
 Call it each frame. More...
 
void saveCfg (Ogre::String &Data)
 Save config. More...
 
bool loadCfg (Ogre::ConfigFile &CfgFile)
 Load config. More...
 
float getValue (const float &x, const float &y)
 Get the especified x/y noise value. More...
 
void setOptions (const Options &Options)
 Set/Update fft noise options. More...
 
const OptionsgetOptions () const
 Get current FFT noise options. More...
 
- Public Member Functions inherited from Hydrax::Noise::Noise
 Noise (const Ogre::String &Name, const bool &GPUNormalMapSupported)
 Constructor. More...
 
virtual ~Noise ()
 Destructor. More...
 
virtual void removeGPUNormalMapResources (GPUNormalMapManager *g)
 Remove GPUNormalMap resources. More...
 
const Ogre::String & getName () const
 Get noise name. More...
 
const bool & isCreated () const
 Is created() called? More...
 
const bool & isGPUNormalMapSupported () const
 Is GPU Normal map generation supported. More...
 
const bool & areGPUNormalMapResourcesCreated () const
 Are GPU normal map resources created? More...
 

Private Member Functions

void _initNoise ()
 Initialize noise. More...
 
void _calculeNoise (const float &delta)
 Calcule noise. More...
 
void _executeInverseFFT ()
 Execute inverse fast fourier transform. More...
 
void _normalizeFFTData (const float &scale)
 Normalize fft data. More...
 
const float _getPhillipsSpectrum (const Ogre::Vector2 &waveVector, const Ogre::Vector2 &wind, const float &kwPower_=2.0f) const
 Get the Philipps Spectrum, used to create the amplitudes and phases. More...
 
const float _getGaussianRandomFloat () const
 Get a Gaussian random number with mean 0 and standard deviation 1, using Box - muller transform. More...
 
void _updateGPUNormalMapResources ()
 Update gpu normal map resources. More...
 

Private Attributes

int resolution
 FFT resolution. More...
 
float * re
 Pointers to resolution*resolution float size arrays. More...
 
float * img
 
float maximalValue
 The minimal value of the result data of the fft transformation. More...
 
std::complex< float > * initialWaves
 the data which is referred as h0{x,t), that is, the data of the simulation at the time 0. More...
 
std::complex< float > * currentWaves
 the data of the simulation at time t, which is formed using the data at time 0 and the angular frequencies at time t More...
 
float * angularFrequencies
 the angular frequencies More...
 
float time
 Current time. More...
 
GPUNormalMapManagermGPUNormalMapManager
 GPUNormalMapManager pointer. More...
 
Options mOptions
 Perlin noise options. More...
 

Additional Inherited Members

- Protected Attributes inherited from Hydrax::Noise::Noise
Ogre::String mName
 Module name. More...
 
bool mCreated
 Has create() been already called? More...
 
bool mGPUNormalMapSupported
 Is GPU normal map generation supported? More...
 
bool mGPUNormalMapResourcesCreated
 Are GPU normal map resources created? More...
 

Detailed Description

FFT noise module class.

Definition at line 44 of file FFT.h.

Constructor & Destructor Documentation

◆ FFT() [1/2]

Hydrax::Noise::FFT::FFT ( )

Default constructor.

Definition at line 37 of file FFT.cpp.

◆ FFT() [2/2]

Hydrax::Noise::FFT::FFT ( const Options Options)

Constructor.

Parameters
OptionsFFT noise options

Definition at line 51 of file FFT.cpp.

◆ ~FFT()

Hydrax::Noise::FFT::~FFT ( )

Destructor.

Definition at line 66 of file FFT.cpp.

+ Here is the call graph for this function:

Member Function Documentation

◆ _calculeNoise()

void Hydrax::Noise::FFT::_calculeNoise ( const float &  delta)
private

Calcule noise.

Parameters
deltaTime elapsed since last frame

Definition at line 469 of file FFT.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _executeInverseFFT()

void Hydrax::Noise::FFT::_executeInverseFFT ( )
private

Execute inverse fast fourier transform.

Definition at line 547 of file FFT.cpp.

+ Here is the caller graph for this function:

◆ _getGaussianRandomFloat()

const float Hydrax::Noise::FFT::_getGaussianRandomFloat ( ) const
private

Get a Gaussian random number with mean 0 and standard deviation 1, using Box - muller transform.

Returns
Gaussian random number with mean 0 and standard deviation 1, using Box - muller transform

Definition at line 506 of file FFT.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getPhillipsSpectrum()

const float Hydrax::Noise::FFT::_getPhillipsSpectrum ( const Ogre::Vector2 &  waveVector,
const Ogre::Vector2 &  wind,
const float &  kwPower_ = 2.0f 
) const
private

Get the Philipps Spectrum, used to create the amplitudes and phases.

Parameters
waveVectorWave vector
windWind direction
kwPower_kwPower
Returns
Philipps Spectrum

Definition at line 525 of file FFT.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _initNoise()

void Hydrax::Noise::FFT::_initNoise ( )
private

Initialize noise.

Definition at line 433 of file FFT.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _normalizeFFTData()

void Hydrax::Noise::FFT::_normalizeFFTData ( const float &  scale)
private

Normalize fft data.

Parameters
scaleUser defined scale

Definition at line 714 of file FFT.cpp.

+ Here is the caller graph for this function:

◆ _updateGPUNormalMapResources()

void Hydrax::Noise::FFT::_updateGPUNormalMapResources ( )
private

Update gpu normal map resources.

Definition at line 371 of file FFT.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ create()

void Hydrax::Noise::FFT::create ( )
virtual

Create.

Reimplemented from Hydrax::Noise::Noise.

Definition at line 73 of file FFT.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createGPUNormalMapResources()

bool Hydrax::Noise::FFT::createGPUNormalMapResources ( GPUNormalMapManager g)
virtual

Create GPUNormalMap resources.

Parameters
gGPUNormalMapManager pointer
Returns
true if it needs to be created, false if not

Reimplemented from Hydrax::Noise::Noise.

Definition at line 175 of file FFT.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getOptions()

const Options& Hydrax::Noise::FFT::getOptions ( ) const
inline

Get current FFT noise options.

Returns
Current fft noise options

Definition at line 213 of file FFT.h.

◆ getValue()

float Hydrax::Noise::FFT::getValue ( const float &  x,
const float &  y 
)
virtual

Get the especified x/y noise value.

Parameters
xX Coord
yY Coord
Returns
Noise value

Implements Hydrax::Noise::Noise.

Definition at line 757 of file FFT.cpp.

◆ loadCfg()

bool Hydrax::Noise::FFT::loadCfg ( Ogre::ConfigFile &  CfgFile)
virtual

Load config.

Returns
True if is the correct noise config

Reimplemented from Hydrax::Noise::Noise.

Definition at line 404 of file FFT.cpp.

+ Here is the call graph for this function:

◆ remove()

void Hydrax::Noise::FFT::remove ( )
virtual

Remove.

Reimplemented from Hydrax::Noise::Noise.

Definition at line 85 of file FFT.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveCfg()

void Hydrax::Noise::FFT::saveCfg ( Ogre::String &  Data)
virtual

Save config.

Parameters
DataString reference

Reimplemented from Hydrax::Noise::Noise.

Definition at line 391 of file FFT.cpp.

+ Here is the call graph for this function:

◆ setOptions()

void Hydrax::Noise::FFT::setOptions ( const Options Options)

Set/Update fft noise options.

Parameters
OptionsFFT noise options

Definition at line 125 of file FFT.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update()

void Hydrax::Noise::FFT::update ( const Ogre::Real &  timeSinceLastFrame)
virtual

Call it each frame.

Parameters
timeSinceLastFrameTime since last frame(delta)

Implements Hydrax::Noise::Noise.

Definition at line 423 of file FFT.cpp.

+ Here is the call graph for this function:

Field Documentation

◆ angularFrequencies

float* Hydrax::Noise::FFT::angularFrequencies
private

the angular frequencies

Definition at line 266 of file FFT.h.

◆ currentWaves

std::complex<float>* Hydrax::Noise::FFT::currentWaves
private

the data of the simulation at time t, which is formed using the data at time 0 and the angular frequencies at time t

Definition at line 264 of file FFT.h.

◆ img

float * Hydrax::Noise::FFT::img
private

Definition at line 257 of file FFT.h.

◆ initialWaves

std::complex<float>* Hydrax::Noise::FFT::initialWaves
private

the data which is referred as h0{x,t), that is, the data of the simulation at the time 0.

Definition at line 262 of file FFT.h.

◆ maximalValue

float Hydrax::Noise::FFT::maximalValue
private

The minimal value of the result data of the fft transformation.

Definition at line 259 of file FFT.h.

◆ mGPUNormalMapManager

GPUNormalMapManager* Hydrax::Noise::FFT::mGPUNormalMapManager
private

GPUNormalMapManager pointer.

Definition at line 271 of file FFT.h.

◆ mOptions

Options Hydrax::Noise::FFT::mOptions
private

Perlin noise options.

Definition at line 274 of file FFT.h.

◆ re

float* Hydrax::Noise::FFT::re
private

Pointers to resolution*resolution float size arrays.

Definition at line 257 of file FFT.h.

◆ resolution

int Hydrax::Noise::FFT::resolution
private

FFT resolution.

Definition at line 255 of file FFT.h.

◆ time

float Hydrax::Noise::FFT::time
private

Current time.

Definition at line 268 of file FFT.h.


The documentation for this class was generated from the following files: