67 #ifndef _graphicsproceduralnoisegenerator_cpp
68 #define _graphicsproceduralnoisegenerator_cpp
70 #include "Graphics/Procedural/Texture/noisegenerator.h"
72 #include "MathTools/randomnumber.h"
73 #include "Noise/Module/perlin.h"
84 GenColour(1.0,1.0,1.0,1.0),
94 Real RangeSize = MaxVal - MinVal;
95 if( RangeSize > 0.0 ) {
96 for(
Whole Index = 0 ; Index < ToNormalize.size() ; ++Index )
98 ToNormalize[Index] = ( ToNormalize[Index] - MinVal ) / RangeSize;
106 Real MinNoise = 9999999999.9;
107 Real MaxNoise = -999999999.9;
108 Noise::Module::Perlin PerlinMod;
109 for(
Whole CurrX = 0 ; CurrX < X ; ++CurrX )
111 for(
Whole CurrY = 0 ; CurrY < Y ; ++CurrY )
113 Real NoiseVal = PerlinMod.GetValue(CurrX,CurrY,0);
114 if( NoiseVal < MinNoise )
116 if( NoiseVal > MaxNoise )
118 RetField[CurrY * X + CurrX] = NoiseVal;
128 Real MinNoise = 9999999999.9;
129 Real MaxNoise = -999999999.9;
130 MathTools::MersenneTwisterGenerator32 NumGen(this->
GenSeed);
131 for(
Whole Index = 0 ; Index < RetField.size() ; ++Index )
133 Real NoiseVal = NumGen.GenerateScaledReal();
134 if( NoiseVal < MinNoise )
136 if( NoiseVal > MaxNoise )
138 RetField[Index] = NoiseVal;
152 switch( this->
NType )
167 for(
Whole Y = 0 ; Y < TargetHeight ; ++Y )
169 for(
Whole X = 0 ; X < TargetWidth ; ++X )
171 Real NoiseVal = (
Real)Field[Y * TargetWidth + X];
181 {
return "NoiseGenerator"; }
void SetRedByte(const Whole X, const Whole Y, const ColourChannelType Red)
Sets the red colour value of a specified pixel. the X or Y location go beyond the set size of this te...
void FitToRange(NoiseField &ToNormalize, const Real MinVal, const Real MaxVal) const
Converts all of the values in a NoiseField to a 0-1 range.
Procedural::NoiseType NType
The type of noise generator to use when generating the image.
Whole GetWidth() const
Get the pixel width of this texture.
NoiseField GenerateWhiteNoiseField(const Whole X, const Whole Y) const
Generates a grid of white noise.
uint8_t UInt8
An 8-bit unsigned integer.
This is a simple class for holding 4 reals representing the colour any give object or lightsource can...
virtual String GetName() const
Gets the name of this generator.
float Real
A Datatype used to represent a real floating point number.
Fills full image with noise in a given colour.
NoiseField GeneratePerlinNoiseField(const Whole X, const Whole Y) const
Generates a grid of perlin noise.
void SetGreenByte(const Whole X, const Whole Y, const ColourChannelType Green)
Sets the green colour value of a specified pixel. the X or Y location go beyond the set size of this ...
Real GreenChannel
Value from 0.0 to 1.0 representing the amount of green present in the colour. 1.0 if very green...
std::vector< Real > NoiseField
Convenience typedef for a container of generated noise.
NoiseType
An enum used to describe the different types of noise generators.
NoiseGenerator & SetColour(const ColourValue &Colour)
Sets the colour of the background.
NoiseGenerator & SetSeed(const Whole Seed)
Sets the seed for the "random" number generator.
Real AlphaChannel
Value from 0.0 to 1.0 representing the transparency of the colours. 1.0 is opaque and 0...
void SetValues(const Real Red, const Real Green, const Real Blue, const Real Alpha)
Sets each of the colour channels.
NoiseGenerator & SetType(const Procedural::NoiseType Type)
Set the type of noise generation.
A convenience buffer that stores pixel colour values of a texture to be generated.
The bulk of the engine components go in this namspace.
unsigned long Whole
Whole is an unsigned integer, it will be at least 32bits in size.
Whole GetHeight() const
Get the pixel height of this texture.
Real BlueChannel
Value from 0.0 to 1.0 representing the amount of blue present in the colour. 1.0 if very blue...
Real RedChannel
Value from 0.0 to 1.0 representing the amount of red present in the colour. 1.0 if very red...
ColourValue GenColour
The colour of the noise to be generated.
virtual void AddToTextureBuffer(TextureBuffer &Buffer) const
Replaces and populates the pixels as configured in this generator to a TextureBuffer.
void SetAlphaByte(const Whole X, const Whole Y, const ColourChannelType Alpha)
Sets the alpha colour value of a specified pixel. the X or Y location go beyond the set size of this ...
void SetBlueByte(const Whole X, const Whole Y, const ColourChannelType Blue)
Sets the blue colour value of a specified pixel. the X or Y location go beyond the set size of this t...
Whole GenSeed
The seed to be used for the random number generator.
std::string String
A datatype used to a series of characters.
NoiseGenerator()
Class constructor.
virtual ~NoiseGenerator()
Class destructor.