ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
GradientMaterial< colorCount > Class Template Reference

Creates a customizable gradient material for rendering. More...

#include <GradientMaterial.h>

Inheritance diagram for GradientMaterial< colorCount >:
Collaboration diagram for GradientMaterial< colorCount >:

Public Member Functions

 GradientMaterial (RGBColor *rgbColors, float gradientPeriod, bool isRadial, bool isStepped=false)
 Constructs a GradientMaterial instance.
 
void UpdateGradient (RGBColor *rgbColors)
 Updates the colors of the gradient.
 
void SetPositionOffset (Vector2D positionOffset)
 Sets the position offset for the gradient.
 
void SetRotationOffset (Vector2D rotationOffset)
 Sets the rotation offset for the gradient.
 
void SetRotationAngle (float rotationAngle)
 Sets the rotation angle for the gradient.
 
void SetGradientPeriod (float gradientPeriod)
 Sets the gradient's period of repetition.
 
void GradientShift (float ratio)
 Shifts the gradient by a ratio.
 
void HueShift (float hueDeg)
 Shifts the hue of the gradient by a specified degree.
 
void UpdateRGB ()
 Updates the RGB colors in the gradient.
 
RGBColor GetRGB (const Vector3D &position, const Vector3D &normal, const Vector3D &uvw) override
 Gets the RGB color for a given position in the gradient.
 
- Public Member Functions inherited from Material
virtual ~Material ()=default
 Virtual destructor for proper cleanup in derived classes.
 

Private Attributes

RGBColor rgbColors [colorCount]
 Array of colors used in the gradient.
 
RGBColorbaseRGBColors
 Pointer to the base RGB colors.
 
Vector2D positionOffset
 Offset for the gradient's position.
 
Vector2D rotationOffset
 Point about which the gradient rotates.
 
float gradientPeriod = 1.0f
 Period of the gradient repetition.
 
float rotationAngle = 0.0f
 Angle for rotating the gradient.
 
bool isRadial = false
 Whether the gradient is radial.
 
bool isStepped = false
 Whether the gradient is stepped.
 
float gradientShift = 0.0f
 Shift in the gradient pattern.
 

Additional Inherited Members

- Public Types inherited from Material
enum  Method {
  Base , Add , Subtract , Multiply ,
  Divide , Darken , Lighten , Screen ,
  Overlay , SoftLight , Replace , EfficientMask ,
  Bypass
}
 Defines blending methods for combining colors. More...
 

Detailed Description

template<size_t colorCount>
class GradientMaterial< colorCount >

Creates a customizable gradient material for rendering.

The GradientMaterial class supports linear and radial gradients, with options for stepping, position and rotation offsets, and period adjustments.

Template Parameters
colorCountNumber of colors in the gradient.

Definition at line 30 of file GradientMaterial.h.

Constructor & Destructor Documentation

◆ GradientMaterial()

template<size_t colorCount>
GradientMaterial ( RGBColor rgbColors,
float  gradientPeriod,
bool  isRadial,
bool  isStepped = false 
)

Constructs a GradientMaterial instance.

Parameters
rgbColorsArray of colors for the gradient.
gradientPeriodPeriod of the gradient repetition.
isRadialWhether the gradient is radial.
isSteppedWhether the gradient is stepped.

Member Function Documentation

◆ GetRGB()

template<size_t colorCount>
RGBColor GetRGB ( const Vector3D position,
const Vector3D normal,
const Vector3D uvw 
)
overridevirtual

Gets the RGB color for a given position in the gradient.

Parameters
position3D position in the gradient.
normalNormal vector at the position.
uvwTexture coordinates at the position.
Returns
The calculated RGB color.

Implements Material.

Referenced by HorizontalRainbow::GetRGB(), and DepthMaterial::GetRGB().

◆ GradientShift()

template<size_t colorCount>
void GradientShift ( float  ratio)

Shifts the gradient by a ratio.

Parameters
ratioThe ratio by which to shift the gradient.

Referenced by TVStatic::Update(), and XenraxAnimation::Update().

◆ HueShift()

template<size_t colorCount>
void HueShift ( float  hueDeg)

Shifts the hue of the gradient by a specified degree.

Parameters
hueDegDegrees by which to shift the gradient's hue.

Referenced by RainbowNoise::Update(), RainbowNoise2::Update(), TVStatic::Update(), ProtogenArtleckAnimation::Update(), WaffleDaProtoAnimation::Update(), InfraredAnimation::Update(), ProtobottAnimation::Update(), and NukudeFaceAnimation::Update().

◆ SetGradientPeriod()

template<size_t colorCount>
void SetGradientPeriod ( float  gradientPeriod)

◆ SetPositionOffset()

template<size_t colorCount>
void SetPositionOffset ( Vector2D  positionOffset)

Sets the position offset for the gradient.

Parameters
positionOffsetThe new position offset.

Referenced by HorizontalRainbow::Update().

◆ SetRotationAngle()

template<size_t colorCount>
void SetRotationAngle ( float  rotationAngle)

◆ SetRotationOffset()

template<size_t colorCount>
void SetRotationOffset ( Vector2D  rotationOffset)

Sets the rotation offset for the gradient.

Parameters
rotationOffsetThe new rotation offset point.

◆ UpdateGradient()

template<size_t colorCount>
void UpdateGradient ( RGBColor rgbColors)

Updates the colors of the gradient.

Parameters
rgbColorsNew array of colors for the gradient.

Referenced by FlowNoise::SetGradient(), HUB75AnimationSplit::Update(), WS35AnimationSplit::Update(), and ProtogenProject::UpdateFace().

◆ UpdateRGB()

template<size_t colorCount>
void UpdateRGB ( )

Member Data Documentation

◆ baseRGBColors

template<size_t colorCount>
RGBColor* baseRGBColors
private

Pointer to the base RGB colors.

Definition at line 33 of file GradientMaterial.h.

◆ gradientPeriod

template<size_t colorCount>
float gradientPeriod = 1.0f
private

Period of the gradient repetition.

Definition at line 36 of file GradientMaterial.h.

◆ gradientShift

template<size_t colorCount>
float gradientShift = 0.0f
private

Shift in the gradient pattern.

Definition at line 40 of file GradientMaterial.h.

◆ isRadial

template<size_t colorCount>
bool isRadial = false
private

Whether the gradient is radial.

Definition at line 38 of file GradientMaterial.h.

◆ isStepped

template<size_t colorCount>
bool isStepped = false
private

Whether the gradient is stepped.

Definition at line 39 of file GradientMaterial.h.

◆ positionOffset

template<size_t colorCount>
Vector2D positionOffset
private

Offset for the gradient's position.

Definition at line 34 of file GradientMaterial.h.

◆ rgbColors

template<size_t colorCount>
RGBColor rgbColors[colorCount]
private

Array of colors used in the gradient.

Definition at line 32 of file GradientMaterial.h.

◆ rotationAngle

template<size_t colorCount>
float rotationAngle = 0.0f
private

Angle for rotating the gradient.

Definition at line 37 of file GradientMaterial.h.

◆ rotationOffset

template<size_t colorCount>
Vector2D rotationOffset
private

Point about which the gradient rotates.

Definition at line 35 of file GradientMaterial.h.


The documentation for this class was generated from the following file: