![]() |
Public API Reference |
![]() |
Noise module that outputs Voronoi cells. More...
#include <cstool/noise/module/voronoi.h>
Public Member Functions | |
void | EnableDistance (bool enable=true) |
Enables or disables applying the distance from the nearest seed point to the output value. | |
double | GetDisplacement () const |
Returns the displacement value of the Voronoi cells. | |
double | GetFrequency () const |
Returns the frequency of the seed points. | |
int | GetSeed () const |
Returns the seed value used by the Voronoi cells. | |
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. | |
bool | IsDistanceEnabled () const |
Determines if the distance from the nearest seed point is applied to the output value. | |
void | SetDisplacement (double displacement) |
Sets the displacement value of the Voronoi cells. | |
void | SetFrequency (double frequency) |
Sets the frequency of the seed points. | |
void | SetSeed (int seed) |
Sets the seed value used by the Voronoi cells. | |
Voronoi () | |
Constructor. | |
Protected Attributes | |
double | m_displacement |
Scale of the random displacement to apply to each Voronoi cell. | |
bool | m_enableDistance |
Determines if the distance from the nearest seed point is applied to the output value. | |
double | m_frequency |
Frequency of the seed points. | |
int | m_seed |
Seed value used by the coherent-noise function to determine the positions of the seed points. |
Noise module that outputs Voronoi cells.
In mathematics, a Voronoi cell is a region containing all the points that are closer to a specific seed point than to any other seed point. These cells mesh with one another, producing polygon-like formations.
By default, this noise module randomly places a seed point within each unit cube. By modifying the frequency of the seed points, an application can change the distance between seed points. The higher the frequency, the closer together this noise module places the seed points, which reduces the size of the cells. To specify the frequency of the cells, call the SetFrequency() method.
This noise module assigns each Voronoi cell with a random constant value from a coherent-noise function. The displacement value controls the range of random values to assign to each cell. The range of random values is +/- the displacement value. Call the SetDisplacement() method to specify the displacement value.
To modify the random positions of the seed points, call the SetSeed() method.
This noise module can optionally add the distance from the nearest seed to the output value. To enable this feature, call the EnableDistance() method. This causes the points in the Voronoi cells to increase in value the further away that point is from the nearest seed point.
Voronoi cells are often used to generate cracked-mud terrain formations or crystal-like textures
This noise module requires no source modules.
Constructor.
The default displacement value is set to CS::Math::Noise::Module::DEFAULT_VORONOI_DISPLACEMENT.
The default frequency is set to CS::Math::Noise::Module::DEFAULT_VORONOI_FREQUENCY.
The default seed value is set to CS::Math::Noise::Module::DEFAULT_VORONOI_SEED.
void CS::Math::Noise::Module::Voronoi::EnableDistance | ( | bool | enable = true | ) | [inline] |
Enables or disables applying the distance from the nearest seed point to the output value.
enable | Specifies whether to apply the distance to the output value or not. |
Applying the distance from the nearest seed point to the output value causes the points in the Voronoi cells to increase in value the further away that point is from the nearest seed point. Setting this value to true (and setting the displacement to a near-zero value) causes this noise module to generate cracked mud formations.
double CS::Math::Noise::Module::Voronoi::GetDisplacement | ( | ) | const [inline] |
Returns the displacement value of the Voronoi cells.
This noise module assigns each Voronoi cell with a random constant value from a coherent-noise function. The displacement value controls the range of random values to assign to each cell. The range of random values is +/- the displacement value.
double CS::Math::Noise::Module::Voronoi::GetFrequency | ( | ) | const [inline] |
int CS::Math::Noise::Module::Voronoi::GetSeed | ( | ) | const [inline] |
virtual int CS::Math::Noise::Module::Voronoi::GetSourceModuleCount | ( | ) | const [inline, virtual] |
Returns the number of source modules required by this noise module.
Implements CS::Math::Noise::Module::Module.
virtual double CS::Math::Noise::Module::Voronoi::GetValue | ( | double | x, |
double | y, | ||
double | z | ||
) | const [virtual] |
Generates an output value given the coordinates of the specified input value.
x | The x coordinate of the input value. |
y | The y coordinate of the input value. |
z | The z coordinate of the input value. |
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.
bool CS::Math::Noise::Module::Voronoi::IsDistanceEnabled | ( | ) | const [inline] |
Determines if the distance from the nearest seed point is applied to the output value.
Applying the distance from the nearest seed point to the output value causes the points in the Voronoi cells to increase in value the further away that point is from the nearest seed point.
void CS::Math::Noise::Module::Voronoi::SetDisplacement | ( | double | displacement | ) | [inline] |
Sets the displacement value of the Voronoi cells.
displacement | The displacement value of the Voronoi cells. |
This noise module assigns each Voronoi cell with a random constant value from a coherent-noise function. The displacement value controls the range of random values to assign to each cell. The range of random values is +/- the displacement value.
void CS::Math::Noise::Module::Voronoi::SetFrequency | ( | double | frequency | ) | [inline] |
void CS::Math::Noise::Module::Voronoi::SetSeed | ( | int | seed | ) | [inline] |
double CS::Math::Noise::Module::Voronoi::m_displacement [protected] |
bool CS::Math::Noise::Module::Voronoi::m_enableDistance [protected] |
double CS::Math::Noise::Module::Voronoi::m_frequency [protected] |
int CS::Math::Noise::Module::Voronoi::m_seed [protected] |