CrystalSpace

Public API Reference

CS::Math::Noise::Module::Turbulence Class Reference
[Transformer Modules]

Noise module that randomly displaces the input value before returning the output value from a source module. More...

#include <cstool/noise/module/turbulence.h>

Inheritance diagram for CS::Math::Noise::Module::Turbulence:

List of all members.

Public Member Functions

double GetFrequency () const
 Returns the frequency of the turbulence.
double GetPower () const
 Returns the power of the turbulence.
int GetRoughnessCount () const
 Returns the roughness of the turbulence.
int GetSeed () const
 Returns the seed value of the internal Perlin-noise modules that are used to displace the input values.
virtual int GetSourceModuleCount () const
 Returns the number of source modules required by this noise module.
virtual double GetValue (double x, double y, double z) const
 Generates an output value given the coordinates of the specified input value.
void SetFrequency (double frequency)
 Sets the frequency of the turbulence.
void SetPower (double power)
 Sets the power of the turbulence.
void SetRoughness (int roughness)
 Sets the roughness of the turbulence.
void SetSeed (int seed)
 Sets the seed value of the internal noise modules that are used to displace the input values.
 Turbulence ()
 Constructor.

Protected Attributes

double m_power
 The power (scale) of the displacement.
Perlin m_xDistortModule
 Noise module that displaces the x coordinate.
Perlin m_yDistortModule
 Noise module that displaces the y coordinate.
Perlin m_zDistortModule
 Noise module that displaces the z coordinate.

Detailed Description

Noise module that randomly displaces the input value before returning the output value from a source module.

moduleturbulence.png

Turbulence is the pseudo-random displacement of the input value. The GetValue() method randomly displaces the ( x, y, z ) coordinates of the input value before retrieving the output value from the source module. To control the turbulence, an application can modify its frequency, its power, and its roughness.

The frequency of the turbulence determines how rapidly the displacement amount changes. To specify the frequency, call the SetFrequency() method.

The power of the turbulence determines the scaling factor that is applied to the displacement amount. To specify the power, call the SetPower() method.

The roughness of the turbulence determines the roughness of the changes to the displacement amount. Low values smoothly change the displacement amount. High values roughly change the displacement amount, which produces more "kinky" changes. To specify the roughness, call the SetRoughness() method.

Use of this noise module may require some trial and error. Assuming that you are using a generator module as the source module, you should first:

From these initial frequency and power values, modify these values until this noise module produce the desired changes in your terrain or texture. For example:

Displacing the input values result in more realistic terrain and textures. If you are generating elevations for terrain height maps, you can use this noise module to produce more realistic mountain ranges or terrain features that look like flowing lava rock. If you are generating values for textures, you can use this noise module to produce realistic marble-like or "oily" textures.

Internally, there are three CS::Math::Noise::Module::Perlin noise modules that displace the input value; one for the x, one for the y, and one for the z coordinate.

This noise module requires one source module.

Definition at line 112 of file turbulence.h.


Constructor & Destructor Documentation

CS::Math::Noise::Module::Turbulence::Turbulence (  ) 

Constructor.

The default frequency is set to CS::Math::Noise::Module::DEFAULT_TURBULENCE_FREQUENCY.

The default power is set to CS::Math::Noise::Module::DEFAULT_TURBULENCE_POWER.

The default roughness is set to CS::Math::Noise::Module::DEFAULT_TURBULENCE_ROUGHNESS.

The default seed value is set to CS::Math::Noise::Module::DEFAULT_TURBULENCE_SEED.


Member Function Documentation

double CS::Math::Noise::Module::Turbulence::GetFrequency (  )  const

Returns the frequency of the turbulence.

Returns:
The frequency of the turbulence.

The frequency of the turbulence determines how rapidly the displacement amount changes.

double CS::Math::Noise::Module::Turbulence::GetPower (  )  const [inline]

Returns the power of the turbulence.

Returns:
The power of the turbulence.

The power of the turbulence determines the scaling factor that is applied to the displacement amount.

Definition at line 146 of file turbulence.h.

int CS::Math::Noise::Module::Turbulence::GetRoughnessCount (  )  const [inline]

Returns the roughness of the turbulence.

Returns:
The roughness of the turbulence.

The roughness of the turbulence determines the roughness of the changes to the displacement amount. Low values smoothly change the displacement amount. High values roughly change the displacement amount, which produces more "kinky" changes.

Definition at line 159 of file turbulence.h.

int CS::Math::Noise::Module::Turbulence::GetSeed (  )  const

Returns the seed value of the internal Perlin-noise modules that are used to displace the input values.

Returns:
The seed value.

Internally, there are three CS::Math::Noise::Module::Perlin noise modules that displace the input value; one for the x, one for the y, and one for the z coordinate.

virtual int CS::Math::Noise::Module::Turbulence::GetSourceModuleCount (  )  const [inline, virtual]

Returns the number of source modules required by this noise module.

Returns:
The number of source modules required by this noise module.

Implements CS::Math::Noise::Module::Module.

Definition at line 174 of file turbulence.h.

virtual double CS::Math::Noise::Module::Turbulence::GetValue ( double  x,
double  y,
double  z 
) const [virtual]

Generates an output value given the coordinates of the specified input value.

Parameters:
x The x coordinate of the input value.
y The y coordinate of the input value.
z The z coordinate of the input value.
Returns:
The output value.
Precondition:
All source modules required by this noise module have been passed to the SetSourceModule() method.

Before an application can call this method, it must first connect all required source modules via the SetSourceModule() method. If these source modules are not connected to this noise module, this method raises a debug assertion.

To determine the number of source modules required by this noise module, call the GetSourceModuleCount() method.

Implements CS::Math::Noise::Module::Module.

void CS::Math::Noise::Module::Turbulence::SetFrequency ( double  frequency  )  [inline]

Sets the frequency of the turbulence.

Parameters:
frequency The frequency of the turbulence.

The frequency of the turbulence determines how rapidly the displacement amount changes.

Definition at line 187 of file turbulence.h.

void CS::Math::Noise::Module::Turbulence::SetPower ( double  power  )  [inline]

Sets the power of the turbulence.

Parameters:
power The power of the turbulence.

The power of the turbulence determines the scaling factor that is applied to the displacement amount.

Definition at line 201 of file turbulence.h.

void CS::Math::Noise::Module::Turbulence::SetRoughness ( int  roughness  )  [inline]

Sets the roughness of the turbulence.

Parameters:
roughness The roughness of the turbulence.

The roughness of the turbulence determines the roughness of the changes to the displacement amount. Low values smoothly change the displacement amount. High values roughly change the displacement amount, which produces more "kinky" changes.

Internally, there are three CS::Math::Noise::Module::Perlin noise modules that displace the input value; one for the x, one for the y, and one for the z coordinate. The roughness value is equal to the number of octaves used by the CS::Math::Noise::Module::Perlin noise modules.

Definition at line 220 of file turbulence.h.

void CS::Math::Noise::Module::Turbulence::SetSeed ( int  seed  ) 

Sets the seed value of the internal noise modules that are used to displace the input values.

Parameters:
seed The seed value.

Internally, there are three CS::Math::Noise::Module::Perlin noise modules that displace the input value; one for the x, one for the y, and one for the z coordinate. This noise module assigns the following seed values to the CS::Math::Noise::Module::Perlin noise modules:

  • It assigns the seed value (seed + 0) to the x noise module.
  • It assigns the seed value (seed + 1) to the y noise module.
  • It assigns the seed value (seed + 2) to the z noise module.

Member Data Documentation

The power (scale) of the displacement.

Definition at line 245 of file turbulence.h.

Noise module that displaces the x coordinate.

Definition at line 248 of file turbulence.h.

Noise module that displaces the y coordinate.

Definition at line 251 of file turbulence.h.

Noise module that displaces the z coordinate.

Definition at line 254 of file turbulence.h.


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

Generated for Crystal Space 2.0 by doxygen 1.6.1