CS::Math::Noise::Module::Select Class Reference
[Selector Modules]
Noise module that outputs the value selected from one of two source modules chosen by the output value from a control module. More...
#include <cstool/noise/module/select.h>
Public Member Functions | |
const Module & | GetControlModule () const |
Returns the control module. | |
double | GetEdgeFalloff () const |
Returns the falloff value at the edge transition. | |
double | GetLowerBound () const |
Returns the lower bound of the selection range. | |
virtual int | GetSourceModuleCount () const |
Returns the number of source modules required by this noise module. | |
double | GetUpperBound () const |
Returns the upper bound of the selection range. | |
virtual double | GetValue (double x, double y, double z) const |
Generates an output value given the coordinates of the specified input value. | |
Select () | |
Constructor. | |
void | SetBounds (double lowerBound, double upperBound) |
Sets the lower and upper bounds of the selection range. | |
void | SetControlModule (const Module &controlModule) |
Sets the control module. | |
void | SetEdgeFalloff (double edgeFalloff) |
Sets the falloff value at the edge transition. | |
Protected Attributes | |
double | m_edgeFalloff |
Edge-falloff value. | |
double | m_lowerBound |
Lower bound of the selection range. | |
double | m_upperBound |
Upper bound of the selection range. |
Detailed Description
Noise module that outputs the value selected from one of two source modules chosen by the output value from a control module.
Unlike most other noise modules, the index value assigned to a source module determines its role in the selection operation:
- Source module 0 (upper left in the diagram) outputs a value.
- Source module 1 (lower left in the diagram) outputs a value.
- Source module 2 (bottom of the diagram) is known as the control module. The control module determines the value to select. If the output value from the control module is within a range of values known as the selection range, this noise module outputs the value from the source module with an index value of 1. Otherwise, this noise module outputs the value from the source module with an index value of 0.
To specify the bounds of the selection range, call the SetBounds() method.
An application can pass the control module to the SetControlModule() method instead of the SetSourceModule() method. This may make the application code easier to read.
By default, there is an abrupt transition between the output values from the two source modules at the selection-range boundary. To smooth the transition, pass a non-zero value to the SetEdgeFalloff() method. Higher values result in a smoother transition.
This noise module requires three source modules.
Definition at line 83 of file select.h.
Constructor & Destructor Documentation
CS::Math::Noise::Module::Select::Select | ( | ) |
Constructor.
The default falloff value at the edge transition is set to CS::Math::Noise::Module::DEFAULT_SELECT_EDGE_FALLOFF.
The default lower bound of the selection range is set to CS::Math::Noise::Module::DEFAULT_SELECT_LOWER_BOUND.
The default upper bound of the selection range is set to CS::Math::Noise::Module::DEFAULT_SELECT_UPPER_BOUND.
Member Function Documentation
const Module& CS::Math::Noise::Module::Select::GetControlModule | ( | ) | const [inline] |
Returns the control module.
- Returns:
- A reference to the control module.
- Precondition:
- A control module has been added to this noise module via a call to SetSourceModule() or SetControlModule().
- Exceptions:
-
CS::Math::Noise::ExceptionNoModule See the preconditions for more information.
The control module determines the output value to select. If the output value from the control module is within a range of values known as the selection range, the GetValue() method outputs the value from the source module with an index value of 1. Otherwise, this method outputs the value from the source module with an index value of 0.
double CS::Math::Noise::Module::Select::GetEdgeFalloff | ( | ) | const [inline] |
Returns the falloff value at the edge transition.
- Returns:
- The falloff value at the edge transition.
The falloff value is the width of the edge transition at either edge of the selection range.
By default, there is an abrupt transition between the output values from the two source modules at the selection-range boundary.
double CS::Math::Noise::Module::Select::GetLowerBound | ( | ) | const [inline] |
Returns the lower bound of the selection range.
- Returns:
- The lower bound of the selection range.
If the output value from the control module is within the selection range, the GetValue() method outputs the value from the source module with an index value of 1. Otherwise, this method outputs the value from the source module with an index value of 0.
virtual int CS::Math::Noise::Module::Select::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.
double CS::Math::Noise::Module::Select::GetUpperBound | ( | ) | const [inline] |
Returns the upper bound of the selection range.
- Returns:
- The upper bound of the selection range.
If the output value from the control module is within the selection range, the GetValue() method outputs the value from the source module with an index value of 1. Otherwise, this method outputs the value from the source module with an index value of 0.
virtual double CS::Math::Noise::Module::Select::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::Select::SetBounds | ( | double | lowerBound, | |
double | upperBound | |||
) |
Sets the lower and upper bounds of the selection range.
- Parameters:
-
lowerBound The lower bound. upperBound The upper bound.
- Precondition:
- The lower bound must be less than or equal to the upper bound.
- Exceptions:
-
CS::Math::Noise::ExceptionInvalidParam An invalid parameter was specified; see the preconditions for more information.
If the output value from the control module is within the selection range, the GetValue() method outputs the value from the source module with an index value of 1. Otherwise, this method outputs the value from the source module with an index value of 0.
void CS::Math::Noise::Module::Select::SetControlModule | ( | const Module & | controlModule | ) | [inline] |
Sets the control module.
- Parameters:
-
controlModule The control module.
The control module determines the output value to select. If the output value from the control module is within a range of values known as the selection range, the GetValue() method outputs the value from the source module with an index value of 1. Otherwise, this method outputs the value from the source module with an index value of 0.
This method assigns the control module an index value of 2. Passing the control module to this method produces the same results as passing the control module to the SetSourceModule() method while assigning that noise module an index value of 2.
This control module must exist throughout the lifetime of this noise module unless another control module replaces that control module.
void CS::Math::Noise::Module::Select::SetEdgeFalloff | ( | double | edgeFalloff | ) |
Sets the falloff value at the edge transition.
- Parameters:
-
edgeFalloff The falloff value at the edge transition.
The falloff value is the width of the edge transition at either edge of the selection range.
By default, there is an abrupt transition between the values from the two source modules at the boundaries of the selection range.
For example, if the selection range is 0.5 to 0.8, and the edge falloff value is 0.1, then the GetValue() method outputs:
- the output value from the source module with an index value of 0 if the output value from the control module is less than 0.4 ( = 0.5 - 0.1).
- a linear blend between the two output values from the two source modules if the output value from the control module is between 0.4 ( = 0.5 - 0.1) and 0.6 ( = 0.5 + 0.1).
- the output value from the source module with an index value of 1 if the output value from the control module is between 0.6 ( = 0.5 + 0.1) and 0.7 ( = 0.8 - 0.1).
- a linear blend between the output values from the two source modules if the output value from the control module is between 0.7 ( = 0.8 - 0.1 ) and 0.9 ( = 0.8 + 0.1).
- the output value from the source module with an index value of 0 if the output value from the control module is greater than 0.9 ( = 0.8 + 0.1).
Member Data Documentation
double CS::Math::Noise::Module::Select::m_edgeFalloff [protected] |
double CS::Math::Noise::Module::Select::m_lowerBound [protected] |
double CS::Math::Noise::Module::Select::m_upperBound [protected] |
The documentation for this class was generated from the following file:
- cstool/noise/module/select.h
Generated for Crystal Space 2.0 by doxygen 1.6.1