ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
Magnet.h
Go to the documentation of this file.
1/**
2 * @file Magnet.h
3 * @brief Defines the `Magnet` effect class for creating magnetic distortion effects on pixel groups.
4 *
5 * The `Magnet` effect simulates a magnetic field that distorts the positions of pixels
6 * based on a central offset, amplitude, and sinusoidal warping functions.
7 *
8 * @date 22/12/2024
9 * @version 1.0
10 * @author Coela Can't
11 */
12
13#pragma once
14
15#include "Effect.h"
16#include "../../Utils/Signals/FunctionGenerator.h"
17
18/**
19 * @class Magnet
20 * @brief Implements a magnetic distortion effect for pixel groups.
21 *
22 * The `Magnet` effect distorts pixel positions by applying a simulated magnetic
23 * field, creating dynamic and fluid distortion patterns.
24 */
25class Magnet : public Effect {
26private:
27 Vector2D offset = Vector2D(0.0f, 0.0f); ///< The central offset of the magnetic effect.
28 float amplitude; ///< The strength of the magnetic distortion.
29 FunctionGenerator fGenSize = FunctionGenerator(FunctionGenerator::Sine, 1.0f, 5000.0f, 2.3f); ///< Generator for field size dynamics.
30 FunctionGenerator fGenX = FunctionGenerator(FunctionGenerator::Sine, -96.0f, 96.0f, 2.7f); ///< Generator for X-axis warp dynamics.
31 FunctionGenerator fGenY = FunctionGenerator(FunctionGenerator::Sine, -96.0f, 96.0f, 1.7f); ///< Generator for Y-axis warp dynamics.
32 FunctionGenerator fGenWarp = FunctionGenerator(FunctionGenerator::Sine, 1.0f, 100.0f, 3.7f); ///< Generator for warp intensity dynamics.
33
34public:
35 /**
36 * @brief Constructs a `Magnet` effect with a specified amplitude.
37 *
38 * @param amplitude The initial strength of the magnetic distortion. Default is 0.5f.
39 */
40 Magnet(float amplitude = 0.5f);
41
42 /**
43 * @brief Sets the central position of the magnetic effect.
44 *
45 * @param offset The `Vector2D` position to set as the central offset.
46 */
48
49 /**
50 * @brief Sets the amplitude of the magnetic distortion effect.
51 *
52 * @param amplitude The new amplitude value.
53 */
54 void SetAmplitude(float amplitude);
55
56 /**
57 * @brief Applies the magnetic distortion effect to the given pixel group.
58 *
59 * This method modifies pixel positions dynamically based on the magnetic field simulation.
60 *
61 * @param pixelGroup Pointer to the `IPixelGroup` to which the effect will be applied.
62 */
63 void ApplyEffect(IPixelGroup* pixelGroup) override;
64};
Defines the base Effect class for applying transformations or effects to pixel groups.
Abstract base class for applying visual effects to pixel groups.
Definition Effect.h:26
A class to generate various waveform functions with customizable parameters.
@ Sine
Sine waveform.
Interface for managing and interacting with a collection of pixels.
Definition IPixelGroup.h:25
Implements a magnetic distortion effect for pixel groups.
Definition Magnet.h:25
FunctionGenerator fGenX
Generator for X-axis warp dynamics.
Definition Magnet.h:30
float amplitude
The strength of the magnetic distortion.
Definition Magnet.h:28
void SetAmplitude(float amplitude)
Sets the amplitude of the magnetic distortion effect.
Definition Magnet.cpp:9
void SetPosition(Vector2D offset)
Sets the central position of the magnetic effect.
Definition Magnet.cpp:5
void ApplyEffect(IPixelGroup *pixelGroup) override
Applies the magnetic distortion effect to the given pixel group.
Definition Magnet.cpp:13
FunctionGenerator fGenWarp
Generator for warp intensity dynamics.
Definition Magnet.h:32
FunctionGenerator fGenSize
Generator for field size dynamics.
Definition Magnet.h:29
Vector2D offset
The central offset of the magnetic effect.
Definition Magnet.h:27
FunctionGenerator fGenY
Generator for Y-axis warp dynamics.
Definition Magnet.h:31
Represents a 2D vector (X, Y) and provides methods for vector arithmetic.
Definition Vector2D.h:27