ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
AudioReactiveGradient Class Reference

A material class for creating an audio-reactive gradient effect. More...

#include <AudioReactiveGradient.h>

Inheritance diagram for AudioReactiveGradient:
Collaboration diagram for AudioReactiveGradient:

Public Member Functions

 AudioReactiveGradient (Vector2D size, Vector2D offset, bool bounce=false, bool circular=false)
 Constructs an AudioReactiveGradient with specified parameters.
 
 ~AudioReactiveGradient ()
 Destroys the AudioReactiveGradient instance.
 
void SetMaterial (Material *material)
 Sets a secondary material for additional effects.
 
floatGetFourierData ()
 Retrieves the Fourier-transformed audio data.
 
void SetSize (Vector2D size)
 Sets the size of the gradient.
 
void SetPosition (Vector2D offset)
 Sets the position of the gradient.
 
void SetRotation (float angle)
 Sets the rotation angle of the gradient.
 
void SetHueAngle (float hueAngle)
 Sets the hue angle for color adjustments.
 
void SetRadius (float radius)
 Sets the radius for circular gradient patterns.
 
void Update (float *readData)
 Updates the gradient based on new audio data.
 
RGBColor GetRGB (const Vector3D &position, const Vector3D &normal, const Vector3D &uvw) override
 Retrieves the color of the gradient at a specific position.
 
- Public Member Functions inherited from Material
virtual ~Material ()=default
 Virtual destructor for proper cleanup in derived classes.
 

Private Attributes

BouncePhysicsbPhy [128]
 Array of BouncePhysics instances for handling dynamic bouncing.
 
Vector2D size
 The size of the gradient area.
 
Vector2D offset
 The offset of the gradient from the origin.
 
float angle = 0.0f
 Rotation angle of the gradient.
 
float hueAngle = 0.0f
 Hue angle for color adjustments.
 
float radius = 0.0f
 Radius for circular gradient patterns.
 
uint8_t colors
 Number of colors in the gradient.
 
floatdata
 Pointer to the audio data array.
 
float bounceData [128]
 Processed bounce data for audio reactivity.
 
uint8_t bins = 128
 Number of bins for audio data processing.
 
bool bounce = false
 Flag indicating if bouncing effects are enabled.
 
bool circular = false
 Flag indicating if circular patterns are enabled.
 
RGBColor rainbowSpectrum [6] = {RGBColor(255, 0, 0), RGBColor(255, 255, 0), RGBColor(0, 255, 0), RGBColor(0, 255, 255), RGBColor(0, 0, 255), RGBColor(255, 0, 255)}
 Predefined rainbow colors.
 
GradientMaterial< 6 > gM = GradientMaterial<6>(rainbowSpectrum, 1.0f, false)
 Gradient material for the rainbow spectrum.
 
Materialmaterial
 Pointer to a secondary material for additional effects.
 

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

A material class for creating an audio-reactive gradient effect.

The AudioReactiveGradient class generates a gradient effect that dynamically reacts to audio data. It supports features like bouncing effects, circular patterns, and customizable gradient colors.

Definition at line 28 of file AudioReactiveGradient.h.

Constructor & Destructor Documentation

◆ AudioReactiveGradient()

AudioReactiveGradient ( Vector2D  size,
Vector2D  offset,
bool  bounce = false,
bool  circular = false 
)

Constructs an AudioReactiveGradient with specified parameters.

Parameters
sizeThe size of the gradient.
offsetThe offset of the gradient.
bounceEnable or disable bouncing effects.
circularEnable or disable circular patterns.

Definition at line 3 of file AudioReactiveGradient.cpp.

References bounce, bPhy, circular, Vector2D::Divide(), gM, material, offset, and size.

◆ ~AudioReactiveGradient()

Destroys the AudioReactiveGradient instance.

Definition at line 17 of file AudioReactiveGradient.cpp.

References bPhy.

Member Function Documentation

◆ GetFourierData()

float * GetFourierData ( )

Retrieves the Fourier-transformed audio data.

Returns
Pointer to the audio data array.

Definition at line 27 of file AudioReactiveGradient.cpp.

References bounce, bounceData, and data.

◆ GetRGB()

RGBColor GetRGB ( const Vector3D position,
const Vector3D normal,
const Vector3D uvw 
)
overridevirtual

Retrieves the color of the gradient at a specific position.

Parameters
positionThe position in 3D space.
normalThe surface normal vector.
uvwThe texture coordinates.
Returns
The computed color as an RGBColor.

Implements Material.

Definition at line 67 of file AudioReactiveGradient.cpp.

References angle, bins, bounce, bounceData, circular, Mathematics::CosineInterpolation(), data, Material::GetRGB(), hueAngle, Mathematics::IsClose(), Mathematics::Map(), material, Mathematics::MPI, offset, radius, Vector2D::Rotate(), size, Vector2D::X, Vector3D::X, Vector2D::Y, and Vector3D::Y.

◆ SetHueAngle()

◆ SetMaterial()

void SetMaterial ( Material material)

Sets a secondary material for additional effects.

Parameters
materialPointer to the secondary material.

Definition at line 23 of file AudioReactiveGradient.cpp.

References material.

◆ SetPosition()

◆ SetRadius()

◆ SetRotation()

◆ SetSize()

◆ Update()

Member Data Documentation

◆ angle

float angle = 0.0f
private

Rotation angle of the gradient.

Definition at line 33 of file AudioReactiveGradient.h.

Referenced by GetRGB(), and SetRotation().

◆ bins

uint8_t bins = 128
private

Number of bins for audio data processing.

Definition at line 39 of file AudioReactiveGradient.h.

Referenced by GetRGB().

◆ bounce

bool bounce = false
private

Flag indicating if bouncing effects are enabled.

Definition at line 40 of file AudioReactiveGradient.h.

Referenced by AudioReactiveGradient(), GetFourierData(), GetRGB(), and Update().

◆ bounceData

float bounceData[128]
private

Processed bounce data for audio reactivity.

Definition at line 38 of file AudioReactiveGradient.h.

Referenced by GetFourierData(), GetRGB(), and Update().

◆ bPhy

BouncePhysics* bPhy[128]
private

Array of BouncePhysics instances for handling dynamic bouncing.

Definition at line 30 of file AudioReactiveGradient.h.

Referenced by AudioReactiveGradient(), Update(), and ~AudioReactiveGradient().

◆ circular

bool circular = false
private

Flag indicating if circular patterns are enabled.

Definition at line 41 of file AudioReactiveGradient.h.

Referenced by AudioReactiveGradient(), and GetRGB().

◆ colors

uint8_t colors
private

Number of colors in the gradient.

Definition at line 36 of file AudioReactiveGradient.h.

◆ data

float* data
private

Pointer to the audio data array.

Definition at line 37 of file AudioReactiveGradient.h.

Referenced by GetFourierData(), GetRGB(), and Update().

◆ gM

Gradient material for the rainbow spectrum.

Definition at line 44 of file AudioReactiveGradient.h.

Referenced by AudioReactiveGradient().

◆ hueAngle

float hueAngle = 0.0f
private

Hue angle for color adjustments.

Definition at line 34 of file AudioReactiveGradient.h.

Referenced by GetRGB(), and SetHueAngle().

◆ material

Material* material
private

Pointer to a secondary material for additional effects.

Definition at line 46 of file AudioReactiveGradient.h.

Referenced by AudioReactiveGradient(), GetRGB(), and SetMaterial().

◆ offset

Vector2D offset
private

The offset of the gradient from the origin.

Definition at line 32 of file AudioReactiveGradient.h.

Referenced by AudioReactiveGradient(), GetRGB(), and SetPosition().

◆ radius

float radius = 0.0f
private

Radius for circular gradient patterns.

Definition at line 35 of file AudioReactiveGradient.h.

Referenced by GetRGB(), and SetRadius().

◆ rainbowSpectrum

RGBColor rainbowSpectrum[6] = {RGBColor(255, 0, 0), RGBColor(255, 255, 0), RGBColor(0, 255, 0), RGBColor(0, 255, 255), RGBColor(0, 0, 255), RGBColor(255, 0, 255)}
private

Predefined rainbow colors.

Definition at line 43 of file AudioReactiveGradient.h.

◆ size

Vector2D size
private

The size of the gradient area.

Definition at line 31 of file AudioReactiveGradient.h.

Referenced by AudioReactiveGradient(), GetRGB(), and SetSize().


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