67 #ifndef _graphicsproceduralwoodgenerator_cpp
68 #define _graphicsproceduralwoodgenerator_cpp
70 #include "Graphics/Procedural/Texture/woodgenerator.h"
72 #include "Noise/Module/perlin.h"
74 #include "MathTools/mathtools.h"
83 GenColour(1.0,1.0,1.0,1.0),
111 MathTools::MersenneTwisterGenerator32 NumGen(this->
GenSeed);
112 Whole RandNum = NumGen.GenerateUInt();
114 Noise::Module::Perlin Noise;
115 Noise.SetFrequency(1 / 48.0);
116 Noise.SetLacunarity(2.20703125);
117 Noise.SetOctaveCount(3);
118 Noise.SetPersistence(0.5);
121 Real HalfWidth =
static_cast<Real>( TargetWidth ) * 0.5;
122 Real HalfHeight =
static_cast<Real>( TargetHeight ) * 0.5;
124 for(
Whole Y = 0 ; Y < TargetHeight ; ++Y )
126 for(
Whole X = 0 ; X < TargetWidth ; ++X )
128 Real xv = (
static_cast<Real>(X) - HalfWidth ) /
static_cast<Real>( TargetWidth );
129 Real yv = (
static_cast<Real>(Y) - HalfHeight ) /
static_cast<Real>( TargetHeight );
130 Real NoiseVal = std::min<Real>(
Real(1.0), MathTools::Abs( MathTools::Sin( ( MathTools::Sqrt(xv * xv + yv * yv) + this->
GenTurbulence * Noise.GetValue( X + RandNum, Y + RandNum, 0 ) ) * MathTools::GetPi() * 2 * this->
GenRings ) ) );
140 {
return "WoodGenerator"; }
WoodGenerator & SetRings(const Whole Rings)
Sets the number of annual rings.
Whole GenSeed
The seed to be used for the random number generator.
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...
virtual String GetName() const
Gets the name of this generator.
Whole GetWidth() const
Get the pixel width of this texture.
WoodGenerator & SetTurbulence(const Real Turb)
Sets the turbulence that will modify the generated pattern.
ColourValue GenColour
The background colour of the texture to be generated.
virtual ~WoodGenerator()
Class destructor.
WoodGenerator()
Blank constructor.
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...
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...
WoodGenerator & 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...
virtual void AddToTextureBuffer(TextureBuffer &Buffer) const
Replaces and populates the pixels as configured in this generator to a TextureBuffer.
Real GenTurbulence
The amount of disruption to apply to the pattern.
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 ...
Whole GenRings
The number of annual rings to be rendered.
void SetValues(const Real Red, const Real Green, const Real Blue, const Real Alpha)
Sets each of the colour channels.
Creates a wood slice image.
WoodGenerator & SetColour(const ColourValue &Colour)
Sets the colour of the background.
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...
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.