CrystalSpace

Public API Reference

CS::Math::Noise::Module::Voronoi Class Reference
[Generator Modules]

Noise module that outputs Voronoi cells. More...

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

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

List of all members.

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.

Detailed Description

Noise module that outputs Voronoi cells.

modulevoronoi.png

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.

Definition at line 89 of file voronoi.h.


Constructor & Destructor Documentation

CS::Math::Noise::Module::Voronoi::Voronoi (  ) 

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.


Member Function Documentation

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.

Parameters:
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.

Definition at line 120 of file voronoi.h.

double CS::Math::Noise::Module::Voronoi::GetDisplacement (  )  const [inline]

Returns the displacement value of the Voronoi cells.

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.

Definition at line 133 of file voronoi.h.

double CS::Math::Noise::Module::Voronoi::GetFrequency (  )  const [inline]

Returns the frequency of the seed points.

Returns:
The frequency of the seed points.

The frequency determines the size of the Voronoi cells and the distance between these cells.

Definition at line 144 of file voronoi.h.

int CS::Math::Noise::Module::Voronoi::GetSeed (  )  const [inline]

Returns the seed value used by the Voronoi cells.

Returns:
The seed value.

The positions of the seed values are calculated by a coherent-noise function. By modifying the seed value, the output of that function changes.

Definition at line 161 of file voronoi.h.

virtual int CS::Math::Noise::Module::Voronoi::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 149 of file voronoi.h.

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.

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.

bool CS::Math::Noise::Module::Voronoi::IsDistanceEnabled (  )  const [inline]

Determines if the distance from the nearest seed point is applied to the output value.

Returns:
  • true if the distance is applied to the output value.
  • false if 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.

Definition at line 176 of file voronoi.h.

void CS::Math::Noise::Module::Voronoi::SetDisplacement ( double  displacement  )  [inline]

Sets the displacement value of the Voronoi cells.

Parameters:
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.

Definition at line 191 of file voronoi.h.

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

Sets the frequency of the seed points.

Parameters:
frequency The frequency of the seed points.

The frequency determines the size of the Voronoi cells and the distance between these cells.

Definition at line 202 of file voronoi.h.

void CS::Math::Noise::Module::Voronoi::SetSeed ( int  seed  )  [inline]

Sets the seed value used by the Voronoi cells.

Parameters:
seed The seed value.

The positions of the seed values are calculated by a coherent-noise function. By modifying the seed value, the output of that function changes.

Definition at line 214 of file voronoi.h.


Member Data Documentation

Scale of the random displacement to apply to each Voronoi cell.

Definition at line 222 of file voronoi.h.

Determines if the distance from the nearest seed point is applied to the output value.

Definition at line 226 of file voronoi.h.

Frequency of the seed points.

Definition at line 229 of file voronoi.h.

Seed value used by the coherent-noise function to determine the positions of the seed points.

Definition at line 233 of file voronoi.h.


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

Generated for Crystal Space 2.1 by doxygen 1.6.1