67 #ifndef _graphicsproceduralvortexmodifier_cpp
68 #define _graphicsproceduralvortexmodifier_cpp
70 #include "Graphics/Procedural/Texture/vortexmodifier.h"
72 #include "MathTools/mathtools.h"
98 Real f1_RadiusX = 1.0 /
static_cast<Real>(dwRadiusX);
99 Real f1_RadiusY = 1.0 /
static_cast<Real>(dwRadiusY);
102 for(
Integer Y = 0 ; Y < TargetHeight ; ++Y )
104 Real dY =
static_cast<Real>( Y - dwCenterY ) * f1_RadiusY;
106 for(
Integer X = 0 ; X < TargetWidth ; ++X )
108 Real dX =
static_cast<Real>( X - dwCenterX ) * f1_RadiusX;
109 Real d = MathTools::Sqrt( dX * dX + dY * dY );
114 d = MathTools::Cos( d * MathTools::GetHalfPi() - MathTools::GetHalfPi() );
116 Real nX =
static_cast<Real>( X - dwCenterX );
117 Real nY =
static_cast<Real>( Y - dwCenterY );
121 nX = bX * MathTools::Cos(rad) - nY * MathTools::Sin(rad) + dwCenterX;
122 nY = bX * MathTools::Sin(rad) + nY * MathTools::Cos(rad) + dwCenterY;
124 if( nX >= TargetWidth ) nX = nX - TargetWidth;
125 if( nY >= TargetHeight ) nY = nY - TargetHeight;
126 if( nX < 0 ) nX = TargetWidth + nX;
127 if( nY < 0 ) nY = TargetHeight + nY;
132 Real fracX = nX - iX;
133 Real fracY = nY - iY;
135 Real ul = ( 1.0 - fracX ) * ( 1.0 - fracY );
136 Real ll = ( 1.0 - fracX ) * fracY;
137 Real ur = fracX * ( 1.0 - fracY );
138 Real lr = fracX * fracY;
140 Integer WrapX = ( iX + 1 ) % TargetWidth;
141 Integer WrapY = ( iY + 1 ) % TargetHeight;
160 {
return "VortexModifier"; }
ColourChannelType & GetPixel(const Whole X, const Whole Y, const UInt16 Component)
Gets access to the pixel at the specified position in this buffer. the X or Y location go beyond the ...
VortexModifier & SetVortexRadius(const Vector2 &Radius)
Sets the radius of the twisting circle.
void SetPixelByte(const Whole X, const Whole Y, const ColourChannelType Red, const ColourChannelType Green, const ColourChannelType Blue, const ColourChannelType Alpha=255)
Set colour of a specified pixel using a 0-255 range. the X or Y location go beyond the set size of th...
Vector2 VortexRadius
The size of the twisting circle on the texture.
Whole GetWidth() const
Get the pixel width of this texture.
VortexModifier & SetVortexRadiusY(const Real Y)
Sets the radius on the Y axis of the twisting circle.
virtual ~VortexModifier()
Class destructor.
int Integer
A datatype used to represent any integer close to.
VortexModifier()
Blank constructor.
This is a simple class for holding 4 reals representing the colour any give object or lightsource can...
VortexModifier & SetVortexRadiusX(const Real X)
Sets the radius on the X axis of the twisting circle.
float Real
A Datatype used to represent a real floating point number.
Real GreenChannel
Value from 0.0 to 1.0 representing the amount of green present in the colour. 1.0 if very green...
Real Y
Coordinate on the Y vector.
virtual String GetName() const
Gets the name of this modifier.
Real X
Coordinate on the X vector.
Vector2 VortexCenter
The center of the twisting circle on the texture.
Twists the pixel positions in a circle on the Texture.
This is used to represent a point on a 2 dimentional area, such as a screen.
Real AlphaChannel
Value from 0.0 to 1.0 representing the transparency of the colours. 1.0 is opaque and 0...
virtual void Modify(TextureBuffer &Buffer)
Alters the generated pixels in a TextureBuffer.
VortexModifier & SetVortexCenter(const Vector2 &Center)
Sets the center point where the texture will be twisted.
VortexModifier & SetVortexTwist(const Real Twist)
Sets the angle by which to rotate pixels within the vortex.
A convenience buffer that stores pixel colour values of a texture to be generated.
Real TwistAngle
The amount of twist to be applied in radians.
The bulk of the engine components go in this namspace.
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...
VortexModifier & SetVortexCenterY(const Real Y)
Sets the center point on the Y axis where the texture will be twisted.
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...
VortexModifier & SetVortexCenterX(const Real X)
Sets the center point on the X axis where the texture will be twisted.
Real RedChannel
Value from 0.0 to 1.0 representing the amount of red present in the colour. 1.0 if very red...
std::string String
A datatype used to a series of characters.
void SetData(const TextureBuffer &Other)
Copies image data from another buffer into this buffer.