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

Implements a magnetic distortion effect for pixel groups. More...

#include <Magnet.h>

Inheritance diagram for Magnet:
Collaboration diagram for Magnet:

Public Member Functions

 Magnet (float amplitude=0.5f)
 Constructs a Magnet effect with a specified amplitude.
 
void SetPosition (Vector2D offset)
 Sets the central position of the magnetic effect.
 
void SetAmplitude (float amplitude)
 Sets the amplitude of the magnetic distortion effect.
 
void ApplyEffect (IPixelGroup *pixelGroup) override
 Applies the magnetic distortion effect to the given pixel group.
 
- Public Member Functions inherited from Effect
 Effect ()
 Default constructor for the Effect class.
 
void SetRatio (float ratio)
 Sets the scaling ratio for the effect.
 

Private Attributes

Vector2D offset = Vector2D(0.0f, 0.0f)
 The central offset of the magnetic effect.
 
float amplitude
 The strength of the magnetic distortion.
 
FunctionGenerator fGenSize = FunctionGenerator(FunctionGenerator::Sine, 1.0f, 5000.0f, 2.3f)
 Generator for field size dynamics.
 
FunctionGenerator fGenX = FunctionGenerator(FunctionGenerator::Sine, -96.0f, 96.0f, 2.7f)
 Generator for X-axis warp dynamics.
 
FunctionGenerator fGenY = FunctionGenerator(FunctionGenerator::Sine, -96.0f, 96.0f, 1.7f)
 Generator for Y-axis warp dynamics.
 
FunctionGenerator fGenWarp = FunctionGenerator(FunctionGenerator::Sine, 1.0f, 100.0f, 3.7f)
 Generator for warp intensity dynamics.
 

Additional Inherited Members

- Protected Attributes inherited from Effect
float ratio = 0.0f
 A scaling ratio used for dynamic effect adjustments.
 

Detailed Description

Implements a magnetic distortion effect for pixel groups.

The Magnet effect distorts pixel positions by applying a simulated magnetic field, creating dynamic and fluid distortion patterns.

Definition at line 25 of file Magnet.h.

Constructor & Destructor Documentation

◆ Magnet()

Magnet ( float  amplitude = 0.5f)

Constructs a Magnet effect with a specified amplitude.

Parameters
amplitudeThe initial strength of the magnetic distortion. Default is 0.5f.

Definition at line 3 of file Magnet.cpp.

Member Function Documentation

◆ ApplyEffect()

void ApplyEffect ( IPixelGroup pixelGroup)
overridevirtual

Applies the magnetic distortion effect to the given pixel group.

This method modifies pixel positions dynamically based on the magnetic field simulation.

Parameters
pixelGroupPointer to the IPixelGroup to which the effect will be applied.

Implements Effect.

Definition at line 13 of file Magnet.cpp.

References amplitude, RGBColor::B, Vector2D::CalculateEuclideanDistance(), RGBColor::G, IPixelGroup::GetCenterCoordinate(), IPixelGroup::GetColorBuffer(), IPixelGroup::GetColors(), IPixelGroup::GetCoordinate(), IPixelGroup::GetOffsetXYIndex(), IPixelGroup::GetPixelCount(), offset, RGBColor::R, Vector2D::X, and Vector2D::Y.

◆ SetAmplitude()

void SetAmplitude ( float  amplitude)

Sets the amplitude of the magnetic distortion effect.

Parameters
amplitudeThe new amplitude value.

Definition at line 9 of file Magnet.cpp.

References amplitude.

◆ SetPosition()

void SetPosition ( Vector2D  offset)

Sets the central position of the magnetic effect.

Parameters
offsetThe Vector2D position to set as the central offset.

Definition at line 5 of file Magnet.cpp.

References offset.

Referenced by XenraxAnimation::Update().

Member Data Documentation

◆ amplitude

float amplitude
private

The strength of the magnetic distortion.

Definition at line 28 of file Magnet.h.

Referenced by ApplyEffect(), and SetAmplitude().

◆ fGenSize

FunctionGenerator fGenSize = FunctionGenerator(FunctionGenerator::Sine, 1.0f, 5000.0f, 2.3f)
private

Generator for field size dynamics.

Definition at line 29 of file Magnet.h.

◆ fGenWarp

FunctionGenerator fGenWarp = FunctionGenerator(FunctionGenerator::Sine, 1.0f, 100.0f, 3.7f)
private

Generator for warp intensity dynamics.

Definition at line 32 of file Magnet.h.

◆ fGenX

FunctionGenerator fGenX = FunctionGenerator(FunctionGenerator::Sine, -96.0f, 96.0f, 2.7f)
private

Generator for X-axis warp dynamics.

Definition at line 30 of file Magnet.h.

◆ fGenY

FunctionGenerator fGenY = FunctionGenerator(FunctionGenerator::Sine, -96.0f, 96.0f, 1.7f)
private

Generator for Y-axis warp dynamics.

Definition at line 31 of file Magnet.h.

◆ offset

Vector2D offset = Vector2D(0.0f, 0.0f)
private

The central offset of the magnetic effect.

Definition at line 27 of file Magnet.h.

Referenced by ApplyEffect(), and SetPosition().


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