libnoise logo

A portable, open-source, coherent noise-generating library for C++


noise::module::Displace Class Reference
[Transformer Modules]

#include <displace.h>

Inheritance diagram for noise::module::Displace:

noise::module::Module List of all members.

Detailed Description

Noise module that uses three source modules to displace each coordinate of the input value before returning the output value from a source module.

moduledisplace.png

Unlike most other noise modules, the index value assigned to a source module determines its role in the displacement operation:

  • Source module 0 (left in the diagram) outputs a value.
  • Source module 1 (lower left in the diagram) specifies the offset to apply to the x coordinate of the input value.
  • Source module 2 (lower center in the diagram) specifies the offset to apply to the y coordinate of the input value.
  • Source module 3 (lower right in the diagram) specifies the offset to apply to the z coordinate of the input value.

The GetValue() method modifies the ( x, y, z ) coordinates of the input value using the output values from the three displacement modules before retrieving the output value from the source module.

The noise::module::Turbulence noise module is a special case of the displacement module; internally, there are three Perlin-noise modules that perform the displacement operation.

This noise module requires four source modules.


Public Member Functions

 Displace ()
 Constructor.
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.
const ModuleGetXDisplaceModule () const
 Returns the x displacement module.
const ModuleGetYDisplaceModule () const
 Returns the y displacement module.
const ModuleGetZDisplaceModule () const
 Returns the z displacement module.
void SetDisplaceModules (const Module &xDisplaceModule, const Module &yDisplaceModule, const Module &zDisplaceModule)
 Sets the x, y, and z displacement modules.
void SetXDisplaceModule (const Module &xDisplaceModule)
 Sets the x displacement module.
void SetYDisplaceModule (const Module &yDisplaceModule)
 Sets the y displacement module.
void SetZDisplaceModule (const Module &zDisplaceModule)
 Sets the z displacement module.

Member Function Documentation

virtual int noise::module::Displace::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 noise::module::Module.

double Displace::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 noise::module::Module.

const Module& noise::module::Displace::GetXDisplaceModule  )  const [inline]
 

Returns the x displacement module.

Returns:
A reference to the x displacement module.
Precondition:
This displacement module has been added to this noise module via a call to SetSourceModule() or SetXDisplaceModule().
Exceptions:
noise::ExceptionNoModule See the preconditions for more information.
The GetValue() method displaces the input value by adding the output value from this displacement module to the x coordinate of the input value before returning the output value from the source module.

const Module& noise::module::Displace::GetYDisplaceModule  )  const [inline]
 

Returns the y displacement module.

Returns:
A reference to the y displacement module.
Precondition:
This displacement module has been added to this noise module via a call to SetSourceModule() or SetYDisplaceModule().
Exceptions:
noise::ExceptionNoModule See the preconditions for more information.
The GetValue() method displaces the input value by adding the output value from this displacement module to the y coordinate of the input value before returning the output value from the source module.

const Module& noise::module::Displace::GetZDisplaceModule  )  const [inline]
 

Returns the z displacement module.

Returns:
A reference to the z displacement module.
Precondition:
This displacement module has been added to this noise module via a call to SetSourceModule() or SetZDisplaceModule().
Exceptions:
noise::ExceptionNoModule See the preconditions for more information.
The GetValue() method displaces the input value by adding the output value from this displacement module to the z coordinate of the input value before returning the output value from the source module.

void noise::module::Displace::SetDisplaceModules const Module xDisplaceModule,
const Module yDisplaceModule,
const Module zDisplaceModule
[inline]
 

Sets the x, y, and z displacement modules.

Parameters:
xDisplaceModule Displacement module that displaces the x coordinate of the input value.
yDisplaceModule Displacement module that displaces the y coordinate of the input value.
zDisplaceModule Displacement module that displaces the z coordinate of the input value.
The GetValue() method displaces the input value by adding the output value from each of the displacement modules to the corresponding coordinates of the input value before returning the output value from the source module.

This method assigns an index value of 1 to the x displacement module, an index value of 2 to the y displacement module, and an index value of 3 to the z displacement module.

These displacement modules must exist throughout the lifetime of this noise module unless another displacement module replaces it.

void noise::module::Displace::SetXDisplaceModule const Module xDisplaceModule  )  [inline]
 

Sets the x displacement module.

Parameters:
xDisplaceModule Displacement module that displaces the x coordinate.
The GetValue() method displaces the input value by adding the output value from this displacement module to the x coordinate of the input value before returning the output value from the source module.

This method assigns an index value of 1 to the x displacement module. Passing this displacement module to this method produces the same results as passing this displacement module to the SetSourceModule() method while assigning it an index value of 1.

This displacement module must exist throughout the lifetime of this noise module unless another displacement module replaces it.

void noise::module::Displace::SetYDisplaceModule const Module yDisplaceModule  )  [inline]
 

Sets the y displacement module.

Parameters:
yDisplaceModule Displacement module that displaces the y coordinate.
The GetValue() method displaces the input value by adding the output value from this displacement module to the y coordinate of the input value before returning the output value from the source module.

This method assigns an index value of 2 to the y displacement module. Passing this displacement module to this method produces the same results as passing this displacement module to the SetSourceModule() method while assigning it an index value of 2.

This displacement module must exist throughout the lifetime of this noise module unless another displacement module replaces it.

void noise::module::Displace::SetZDisplaceModule const Module zDisplaceModule  )  [inline]
 

Sets the z displacement module.

Parameters:
zDisplaceModule Displacement module that displaces the z coordinate.
The GetValue() method displaces the input value by adding the output value from this displacement module to the z coordinate of the input value before returning the output value from the source module.

This method assigns an index value of 3 to the z displacement module. Passing this displacement module to this method produces the same results as passing this displacement module to the SetSourceModule() method while assigning it an index value of 3.

This displacement module must exist throughout the lifetime of this noise module unless another displacement module replaces it.


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