Loading [MathJax]/extensions/tex2jax.js
ProtoTracer  1.0
Real-time 3D rendering and animation engine
All Classes Namespaces Files Functions Variables Enumerations Enumerator Friends Macros Pages
UVMap.h
Go to the documentation of this file.
1/**
2 * @file UVMap.h
3 * @brief A material class for mapping UV texture coordinates to RGB colors.
4 *
5 * The `UVMap` class extends the `Image` class and provides functionality
6 * for mapping UV coordinates to pixel colors in an image, enabling texture
7 * mapping in 3D rendering.
8 *
9 * @date 22/12/2024
10 * @author Coela Can't
11 */
12
13#pragma once
14
15#include "Image.h"
16#include "../../../Utils/Math/Mathematics.h"
17
18/**
19 * @class UVMap
20 * @brief A material for mapping UV texture coordinates to image colors.
21 *
22 * The `UVMap` class uses UV coordinates to sample colors from a specified
23 * image, providing a way to texture surfaces in 3D space.
24 */
25class UVMap : public Image {
26public:
27 /**
28 * @brief Constructs a UVMap with the given image data and color palette.
29 *
30 * @param data Pointer to the image data (pixel indices).
31 * @param rgbColors Pointer to the RGB color palette.
32 * @param xPixels Width of the image in pixels.
33 * @param yPixels Height of the image in pixels.
34 * @param colors Number of colors in the palette.
35 */
36 UVMap(const uint8_t* data, const uint8_t* rgbColors, uint16_t xPixels, uint16_t yPixels, uint8_t colors);
37
38 /**
39 * @brief Retrieves the RGB color at a given 3D position using UV mapping.
40 *
41 * @param position 3D position in the scene.
42 * @param normal Normal vector at the position (not used in UV mapping).
43 * @param uvw UV texture coordinates at the position.
44 * @return The RGB color sampled from the image at the given UV coordinates.
45 */
46 RGBColor GetRGB(const Vector3D& position, const Vector3D& normal, const Vector3D& uvw) override;
47};
Defines an Image material for rendering images as textures in 3D rendering.
Represents an image-based material with support for transformations and palette adjustments.
Definition Image.h:23
unsigned int xPixels
The width of the image in pixels.
Definition Image.h:29
const uint8_t * data
Pointer to the image data.
Definition Image.h:31
unsigned int yPixels
The height of the image in pixels.
Definition Image.h:30
const uint8_t * rgbColors
Pointer to the color palette.
Definition Image.h:32
uint8_t colors
The number of colors in the palette.
Definition Image.h:33
Represents an RGB color and provides methods for manipulation.
Definition RGBColor.h:23
A material for mapping UV texture coordinates to image colors.
Definition UVMap.h:25
RGBColor GetRGB(const Vector3D &position, const Vector3D &normal, const Vector3D &uvw) override
Retrieves the RGB color at a given 3D position using UV mapping.
Definition UVMap.cpp:8
Represents a 3D vector (X, Y, Z) and provides methods for vector arithmetic.
Definition Vector3D.h:26