67 #ifndef _graphicsproceduraltextilegenerator_cpp
68 #define _graphicsproceduraltextilegenerator_cpp
70 #include "Graphics/Procedural/Texture/textilegenerator.h"
72 #include "Noise/Module/perlin.h"
74 #include "MathTools/mathtools.h"
83 GenColour(1.0,1.0,1.0,1.0),
95 MathTools::MersenneTwisterGenerator32 NumGen(this->
GenSeed);
96 Whole RandNum = NumGen.GenerateUInt();
97 Noise::Module::Perlin Noise;
98 Noise.SetFrequency(1.0 / 8.0);
99 Noise.SetLacunarity(2.0);
100 Noise.SetOctaveCount(3);
101 Noise.SetPersistence(0.65);
102 Real FilterLevel = 0.7;
103 Real PreserveLevel = 0.3;
109 Real NoiseVal = std::max( 0.0, std::min( 1.0, ( MathTools::Sin( X + Noise.GetValue( X + RandNum, Y + RandNum, 0 ) ) + MathTools::Sin( Y + Noise.GetValue( X + RandNum, Y + RandNum, 0 ) ) ) * 0.25 + 0.5 ) );
110 Buffer.
SetRedByte( X, Y, (
UInt8)std::min<Real>( PreserveLevel * this->
GenColour.
RedChannel * 255.0 + FilterLevel * this->GenColour.RedChannel * 255.0 * NoiseVal, 255.0) );
119 {
return "TextileGenerator"; }
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...
TextileGenerator & SetSeed(const Whole Seed)
Sets the seed for the "random" number generator.
Whole GetWidth() const
Get the pixel width of this texture.
uint8_t UInt8
An 8-bit unsigned integer.
virtual ~TextileGenerator()
Class destructor.
This is a simple class for holding 4 reals representing the colour any give object or lightsource can...
TextileGenerator & SetColour(const ColourValue &Colour)
Sets the colour of the background.
ColourValue GenColour
The background colour of the textile to be generated.
float Real
A Datatype used to represent a real floating point number.
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...
virtual void AddToTextureBuffer(TextureBuffer &Buffer) const
Replaces and populates the pixels as configured in this generator to a TextureBuffer.
Real AlphaChannel
Value from 0.0 to 1.0 representing the transparency of the colours. 1.0 is opaque and 0...
void SetAlphaReal(const Whole X, const Whole Y, const Real Alpha)
Sets the alpha colour value of a specified pixel. the X or Y location go beyond the set size of this ...
void SetValues(const Real Red, const Real Green, const Real Blue, const Real Alpha)
Sets each of the colour channels.
TextileGenerator()
Class constructor.
virtual String GetName() const
Gets the name of this generator.
A convenience buffer that stores pixel colour values of a texture to be generated.
Whole GenSeed
The seed to be used for the random number generator.
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...
Creates a textile structured image.
Real RedChannel
Value from 0.0 to 1.0 representing the amount of red present in the colour. 1.0 if very red...
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...
std::string String
A datatype used to a series of characters.