ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
HorizontalRainbow.h
Go to the documentation of this file.
1/**
2 * @file HorizontalRainbow.h
3 * @brief A dynamic horizontal rainbow gradient material.
4 *
5 * This file defines the HorizontalRainbow class, which generates a horizontal
6 * rainbow gradient effect that can be animated over time.
7 *
8 * @date 22/12/2024
9 * @author Coela Can't
10 */
11
12#pragma once
13
14#include "../AnimatedMaterial.h" // Base class for animated materials.
15#include "../Static/GradientMaterial.h" // Include for gradient materials.
16#include "../Static/SimplexNoise.h" // Include for simplex noise generation.
17
18/**
19 * @class HorizontalRainbow
20 * @brief A dynamic horizontal rainbow gradient material.
21 *
22 * The HorizontalRainbow class generates a colorful horizontal gradient using
23 * a predefined rainbow spectrum and supports dynamic animation of the gradient.
24 */
26private:
27 RGBColor noiseSpectrum[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.
28 GradientMaterial<6> gNoiseMat = GradientMaterial<6>(&noiseSpectrum[0], 2.0f, false, false); ///< Gradient material for the rainbow spectrum.
29 float positionOffset = 0.0f; ///< Position offset for animating the gradient.
30
31public:
32 /**
33 * @brief Default constructor for HorizontalRainbow.
34 */
36
37 /**
38 * @brief Updates the gradient animation based on the provided time ratio.
39 *
40 * @param ratio The time ratio for animation updates.
41 */
42 void Update(float ratio);
43
44 /**
45 * @brief Retrieves the associated material.
46 *
47 * @return Pointer to the Material instance.
48 */
50
51 /**
52 * @brief Computes the color at a given position in the gradient.
53 *
54 * @param position The position in 3D space.
55 * @param normal The surface normal vector.
56 * @param uvw The texture coordinates.
57 * @return The computed color as an RGBColor.
58 */
59 RGBColor GetRGB(const Vector3D& position, const Vector3D& normal, const Vector3D& uvw) override;
60};
Base class for dynamically updating materials.
Creates a customizable gradient material for rendering.
A dynamic horizontal rainbow gradient material.
HorizontalRainbow()
Default constructor for HorizontalRainbow.
GradientMaterial< 6 > gNoiseMat
Gradient material for the rainbow spectrum.
Material * GetMaterial()
Retrieves the associated material.
RGBColor GetRGB(const Vector3D &position, const Vector3D &normal, const Vector3D &uvw) override
Computes the color at a given position in the gradient.
RGBColor noiseSpectrum[6]
Predefined rainbow colors.
void Update(float ratio)
Updates the gradient animation based on the provided time ratio.
float positionOffset
Position offset for animating the gradient.
Abstract base class for rendering materials.
Definition Material.h:27
Represents an RGB color and provides methods for manipulation.
Definition RGBColor.h:23
Represents a 3D vector (X, Y, Z) and provides methods for vector arithmetic.
Definition Vector3D.h:26