ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
Image.h
Go to the documentation of this file.
1/**
2 * @file Image.h
3 * @brief Defines an `Image` material for rendering images as textures in 3D rendering.
4 *
5 * The `Image` class is used to represent and manipulate image-based materials,
6 * allowing for dynamic transformations such as resizing, positioning, and rotating
7 * an image, as well as applying hue shifts.
8 *
9 * @date 22/12/2024
10 * @author Coela Can't
11 */
12
13#pragma once
14
15#include "../Material.h" // Base class for materials.
16#include "../../../Utils/Math/Vector2D.h" // 2D vector operations.
17#include "../../../Utils/Math/Mathematics.h" // Mathematical utilities.
18
19/**
20 * @class Image
21 * @brief Represents an image-based material with support for transformations and palette adjustments.
22 */
23class Image : public Material {
24public:
25 Vector2D size; ///< The size of the image.
26 Vector2D offset; ///< The offset position of the image.
27 float angle = 0.0f; ///< The rotation angle of the image in degrees.
28 float hueAngle = 0.0f; ///< The hue adjustment angle of the image.
29 unsigned int xPixels = 0; ///< The width of the image in pixels.
30 unsigned int yPixels = 0; ///< The height of the image in pixels.
31 const uint8_t* data; ///< Pointer to the image data.
32 const uint8_t* rgbColors; ///< Pointer to the color palette.
33 uint8_t colors; ///< The number of colors in the palette.
34
35 /**
36 * @brief Constructs an `Image` material.
37 *
38 * @param data Pointer to the image data.
39 * @param rgbColors Pointer to the color palette.
40 * @param xPixels Width of the image in pixels.
41 * @param yPixels Height of the image in pixels.
42 * @param colors Number of colors in the palette.
43 */
44 Image(const uint8_t* data, const uint8_t* rgbColors, unsigned int xPixels, unsigned int yPixels, uint8_t colors);
45
46 /**
47 * @brief Destructor for `Image`.
48 */
49 ~Image() {}
50
51 /**
52 * @brief Sets the image data.
53 *
54 * @param data Pointer to the new image data.
55 */
56 void SetData(const uint8_t* data);
57
58 /**
59 * @brief Sets the color palette.
60 *
61 * @param rgbColors Pointer to the new color palette.
62 */
63 void SetColorPalette(const uint8_t* rgbColors);
64
65 /**
66 * @brief Sets the size of the image.
67 *
68 * @param size The new size as a `Vector2D`.
69 */
70 void SetSize(Vector2D size);
71
72 /**
73 * @brief Sets the position offset of the image.
74 *
75 * @param offset The new offset as a `Vector2D`.
76 */
78
79 /**
80 * @brief Sets the rotation angle of the image.
81 *
82 * @param angle The new rotation angle in degrees.
83 */
84 void SetRotation(float angle);
85
86 /**
87 * @brief Sets the hue adjustment angle of the image.
88 *
89 * @param hueAngle The new hue adjustment angle in degrees.
90 */
91 void SetHueAngle(float hueAngle);
92
93 /**
94 * @brief Calculates the RGB color at a specific position.
95 *
96 * @param position 3D position in the image.
97 * @param normal Normal vector at the position.
98 * @param uvw Texture coordinates at the position.
99 * @return The calculated RGB color.
100 */
101 RGBColor GetRGB(const Vector3D& position, const Vector3D& normal, const Vector3D& uvw) override;
102};
Represents an image-based material with support for transformations and palette adjustments.
Definition Image.h:23
void SetColorPalette(const uint8_t *rgbColors)
Sets the color palette.
Definition Image.cpp:15
unsigned int xPixels
The width of the image in pixels.
Definition Image.h:29
void SetPosition(Vector2D offset)
Sets the position offset of the image.
Definition Image.cpp:23
const uint8_t * data
Pointer to the image data.
Definition Image.h:31
float hueAngle
The hue adjustment angle of the image.
Definition Image.h:28
~Image()
Destructor for Image.
Definition Image.h:49
unsigned int yPixels
The height of the image in pixels.
Definition Image.h:30
RGBColor GetRGB(const Vector3D &position, const Vector3D &normal, const Vector3D &uvw) override
Calculates the RGB color at a specific position.
Definition Image.cpp:35
const uint8_t * rgbColors
Pointer to the color palette.
Definition Image.h:32
void SetSize(Vector2D size)
Sets the size of the image.
Definition Image.cpp:19
void SetData(const uint8_t *data)
Sets the image data.
Definition Image.cpp:11
Vector2D offset
The offset position of the image.
Definition Image.h:26
float angle
The rotation angle of the image in degrees.
Definition Image.h:27
uint8_t colors
The number of colors in the palette.
Definition Image.h:33
void SetRotation(float angle)
Sets the rotation angle of the image.
Definition Image.cpp:27
void SetHueAngle(float hueAngle)
Sets the hue adjustment angle of the image.
Definition Image.cpp:31
Vector2D size
The size of the image.
Definition Image.h:25
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 2D vector (X, Y) and provides methods for vector arithmetic.
Definition Vector2D.h:27
Represents a 3D vector (X, Y, Z) and provides methods for vector arithmetic.
Definition Vector3D.h:26