CS::Math::Noise::Module::Terrace Class Reference (Crystal Space 2.0 Public API Reference)

| ## Public API Reference

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Protected Member Functions | Protected Attributes
CS::Math::Noise::Module::Terrace Class Reference
Modifier Modules

Noise module that maps the output value from a source module onto a terrace-forming curve. More...

`#include <cstool/noise/module/terrace.h>`

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

List of all members.

## Public Member Functions
void | AddControlPoint (double value)
| Adds a control point to the terrace-forming curve.
void | ClearAllControlPoints ()
| Deletes all the control points on the terrace-forming curve.
const double * | GetControlPointArray () const
| Returns a pointer to the array of control points on the terrace-forming curve.
int | GetControlPointCount () const
| Returns the number of control points on the terrace-forming curve.
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 | InvertTerraces (bool invert=true)
| Enables or disables the inversion of the terrace-forming curve between the control points.
bool | IsTerracesInverted () const
| Determines if the terrace-forming curve between the control.
void | MakeControlPoints (int controlPointCount)
| Creates a number of equally-spaced control points that range from.
| Terrace ()
| Constructor.
| ~Terrace ()
| Destructor.
## Protected Member Functions
int | FindInsertionPos (double value)
| Determines the array index in which to insert the control point into the internal control point array.
void | InsertAtPos (int insertionPos, double value)
| Inserts the control point at the specified position in the internal control point array.
## Protected Attributes
int | m_controlPointCount
| Number of control points stored in this noise module.
bool | m_invertTerraces
| Determines if the terrace-forming curve between all control points is inverted.
double * | m_pControlPoints
| Array that stores the control points.

## Detailed Description

Noise module that maps the output value from a source module onto a terrace-forming curve.

This noise module maps the output value from the source module onto a terrace-forming curve. The start of this curve has a slope of zero; its slope then smoothly increases. This curve also contains control points which resets the slope to zero at that point, producing a "terracing" effect. Refer to the following illustration:

To add a control point to this noise module, call the AddControlPoint() method.

An application must add a minimum of two control points to the curve. If this is not done, the GetValue() method fails. The control points can have any value, although no two control points can have the same value. There is no limit to the number of control points that can be added to the curve.

This noise module clamps the output value from the source module if that value is less than the value of the lowest control point or greater than the value of the highest control point.

This noise module is often used to generate terrain features such as your stereotypical desert canyon.

This noise module requires one source module.

Definition at line 72 of file terrace.h.

## Constructor & Destructor Documentation

CS::Math::Noise::Module::Terrace::Terrace | ( |  | ) |

Constructor.

CS::Math::Noise::Module::Terrace::~Terrace | ( |  | ) |

Destructor.

## Member Function Documentation

void CS::Math::Noise::Module::Terrace::AddControlPoint | ( | double | value | ) |

Adds a control point to the terrace-forming curve.

Parameters:

  value | The value of the control point to add.

Precondition:
  No two control points have the same value.

Exceptions:

  CS::Math::Noise::ExceptionInvalidParam | An invalid parameter was specified; see the preconditions for more information. Two or more control points define the terrace-forming curve. The start of this curve has a slope of zero; its slope then smoothly increases. At the control points, its slope resets to zero. It does not matter which order these points are added.

void CS::Math::Noise::Module::Terrace::ClearAllControlPoints | ( |  | ) |

Deletes all the control points on the terrace-forming curve.

Postcondition:
  All control points on the terrace-forming curve are deleted.

int CS::Math::Noise::Module::Terrace::FindInsertionPos | ( | double | value | ) | `[protected]`

Determines the array index in which to insert the control point into the internal control point array.

Parameters:

  value | The value of the control point.

Returns:
  The array index in which to insert the control point.

Precondition:
  No two control points have the same value.

Exceptions:

  CS::Math::Noise::ExceptionInvalidParam | An invalid parameter was specified; see the preconditions for more information. By inserting the control point at the returned array index, this class ensures that the control point array is sorted by value. The code that maps a value onto the curve requires a sorted control point array.

const double* CS::Math::Noise::Module::Terrace::GetControlPointArray | ( |  | ) | const`[inline]`

Returns a pointer to the array of control points on the terrace-forming curve.

Returns:
  A pointer to the array of control points in this noise module.

Two or more control points define the terrace-forming curve. The start of this curve has a slope of zero; its slope then smoothly increases. At the control points, its slope resets to zero. Before calling this method, call GetControlPointCount() to determine the number of control points in this array. It is recommended that an application does not store this pointer for later use since the pointer to the array may change if the application calls another method of this object.

Definition at line 120 of file terrace.h.

int CS::Math::Noise::Module::Terrace::GetControlPointCount | ( |  | ) | const`[inline]`

Returns the number of control points on the terrace-forming curve.

Returns:
  The number of control points on the terrace-forming curve.

Definition at line 129 of file terrace.h.

virtual int CS::Math::Noise::Module::Terrace::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 134 of file terrace.h.

virtual double CS::Math::Noise::Module::Terrace::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::Terrace::InsertAtPos | ( | int | insertionPos,
|  | double | value
| ) |  | `[protected]`

Inserts the control point at the specified position in the internal control point array.

Parameters:

  insertionPos | The zero-based array position in which to insert the control point.
  value | The value of the control point.

To make room for this new control point, this method reallocates the control point array and shifts all control points occurring after the insertion position up by one. Because the curve mapping algorithm in this noise module requires that all control points in the array be sorted by value, the new control point should be inserted at the position in which the order is still preserved.

void CS::Math::Noise::Module::Terrace::InvertTerraces | ( | bool | invert = `true` | ) | `[inline]`

Enables or disables the inversion of the terrace-forming curve between the control points.

Parameters:

  invert | Specifies whether to invert the curve between the control points.

Definition at line 144 of file terrace.h.

bool CS::Math::Noise::Module::Terrace::IsTerracesInverted | ( |  | ) | const`[inline]`

Determines if the terrace-forming curve between the control.

points is inverted.

Returns:
  - true if the curve between the control points is inverted.
  - false if the curve between the control points is not inverted.

Definition at line 156 of file terrace.h.

void CS::Math::Noise::Module::Terrace::MakeControlPoints | ( | int | controlPointCount | ) |

Creates a number of equally-spaced control points that range from.

-1 to +1.

Parameters:

  controlPointCount | The number of control points to generate.

Precondition:
  The number of control points must be greater than or equal to 2.

Postcondition:
  The previous control points on the terrace-forming curve are deleted.

Exceptions:

  CS::Math::Noise::ExceptionInvalidParam | An invalid parameter was specified; see the preconditions for more information. Two or more control points define the terrace-forming curve. The start of this curve has a slope of zero; its slope then smoothly increases. At the control points, its slope resets to zero.

## Member Data Documentation

int CS::Math::Noise::Module::Terrace::m_controlPointCount`[protected]`

Number of control points stored in this noise module.

Definition at line 220 of file terrace.h.

bool CS::Math::Noise::Module::Terrace::m_invertTerraces`[protected]`

Determines if the terrace-forming curve between all control points is inverted.

Definition at line 224 of file terrace.h.

double* CS::Math::Noise::Module::Terrace::m_pControlPoints`[protected]`

Array that stores the control points.

Definition at line 227 of file terrace.h.

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

- cstool/noise/module/terrace.h