67 #ifndef _graphicsproceduralrandompixelsmodifier_cpp
68 #define _graphicsproceduralrandompixelsmodifier_cpp
70 #include "Graphics/Procedural/Texture/randompixelsmodifier.h"
71 #include "Graphics/Procedural/Texture/rectanglemodifier.h"
73 #include "MathTools/mathtools.h"
82 PixelColour(1.0,1.0,1.0,1.0),
96 std::vector<IntVector2> PixelList;
98 MathTools::MersenneTwisterGenerator32 NumGen(this->
GeneratorSeed);
101 if( GenerateCount == 0 ) {
102 GenerateCount = (
static_cast<Whole>( MathTools::Sqrt( static_cast<Real>( Buffer.
GetWidth() ) ) ) + static_cast<Whole>( MathTools::Sqrt( static_cast<Real>( Buffer.
GetHeight() ) ) ) ) * 10;
105 if( GenerateCount == Area ) {
110 while( PixelList.size() != GenerateCount )
112 Point.
X = NumGen.GenerateUInt() % Buffer.
GetWidth();
113 Point.
Y = NumGen.GenerateUInt() % Buffer.
GetHeight();
115 Boole InList =
false;
116 for( std::vector<IntVector2>::iterator iter = PixelList.begin() ; iter != PixelList.end() ; iter++ )
118 if( iter->X == Point.
X && iter->Y == Point.
Y ) {
125 PixelList.push_back(Point);
126 Buffer.
SetPixel(Point.
X, Point.
Y, this->PixelColour);
132 {
return "RandomPixelsModifier"; }
141 { this->
PixelColour.
SetValues(static_cast<Real>(Red) / 255.0,static_cast<Real>(Green) / 255.0,static_cast<Real>(Blue) / 255.0,static_cast<Real>(Alpha) / 255.0);
return *
this; }
bool Boole
Generally acts a single bit, true or false.
RandomPixelsModifier & SetPixelCount(const Whole Count)
Sets the number of pixels to generate.
Whole PixelCount
The number of randomly placed pixels to generate.
virtual void Modify(TextureBuffer &Buffer)
Alters the generated pixels in a TextureBuffer.
RectangleModifier & SetColour(const ColourValue &Colour)
Sets the colour of the rectangle to be generated.
Whole GetWidth() const
Get the pixel width of this texture.
A modifer that will draw coloured pixels at random positions on the texture.
virtual String GetName() const
Gets the name of this modifier.
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.
Whole Y
Position on the Y axis.
Convenience class for pixel processing.
ColourValue PixelColour
The colour of the randomly placed pixels.
void SetValues(const Real Red, const Real Green, const Real Blue, const Real Alpha)
Sets each of the colour channels.
RandomPixelsModifier & SetSeed(const Whole Seed)
Sets the seed for the random number generator used to determine pixel positions.
A modifier that draws a simple coloured rectangle onto the texture.
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.
RandomPixelsModifier & SetColour(const ColourValue &Colour)
Sets the colour of the pixels to be generated.
void SetPixel(const Whole X, const Whole Y, const ColourValue &Colour)
Set colour of a specified pixel using a ColourValue. the X or Y location go beyond the set size of th...
RandomPixelsModifier()
Blank constructor.
virtual void Modify(TextureBuffer &Buffer)
Alters the generated pixels in a TextureBuffer.
Whole GeneratorSeed
The seed to be used for the randomly generatated texture positions the pixels will be drawn to...
virtual ~RandomPixelsModifier()
Class destructor.
std::string String
A datatype used to a series of characters.
Whole X
Position on the X axis.