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

A material for mapping UV texture coordinates to image colors. More...

#include <UVMap.h>

Inheritance diagram for UVMap:
Collaboration diagram for UVMap:

Public Member Functions

 UVMap (const uint8_t *data, const uint8_t *rgbColors, uint16_t xPixels, uint16_t yPixels, uint8_t colors)
 Constructs a UVMap with the given image data and color palette.
 
RGBColor GetRGB (const Vector3D &position, const Vector3D &normal, const Vector3D &uvw) override
 Retrieves the RGB color at a given 3D position using UV mapping.
 
- Public Member Functions inherited from Image
 Image (const uint8_t *data, const uint8_t *rgbColors, unsigned int xPixels, unsigned int yPixels, uint8_t colors)
 Constructs an Image material.
 
 ~Image ()
 Destructor for Image.
 
void SetData (const uint8_t *data)
 Sets the image data.
 
void SetColorPalette (const uint8_t *rgbColors)
 Sets the color palette.
 
void SetSize (Vector2D size)
 Sets the size of the image.
 
void SetPosition (Vector2D offset)
 Sets the position offset of the image.
 
void SetRotation (float angle)
 Sets the rotation angle of the image.
 
void SetHueAngle (float hueAngle)
 Sets the hue adjustment angle of the image.
 
- Public Member Functions inherited from Material
virtual ~Material ()=default
 Virtual destructor for proper cleanup in derived classes.
 

Additional Inherited Members

- Public Types inherited from Material
enum  Method {
  Base , Add , Subtract , Multiply ,
  Divide , Darken , Lighten , Screen ,
  Overlay , SoftLight , Replace , EfficientMask ,
  Bypass
}
 Defines blending methods for combining colors. More...
 
- Public Attributes inherited from Image
Vector2D size
 The size of the image.
 
Vector2D offset
 The offset position of the image.
 
float angle = 0.0f
 The rotation angle of the image in degrees.
 
float hueAngle = 0.0f
 The hue adjustment angle of the image.
 
unsigned int xPixels = 0
 The width of the image in pixels.
 
unsigned int yPixels = 0
 The height of the image in pixels.
 
const uint8_tdata
 Pointer to the image data.
 
const uint8_trgbColors
 Pointer to the color palette.
 
uint8_t colors
 The number of colors in the palette.
 

Detailed Description

A material for mapping UV texture coordinates to image colors.

The UVMap class uses UV coordinates to sample colors from a specified image, providing a way to texture surfaces in 3D space.

Definition at line 25 of file UVMap.h.

Constructor & Destructor Documentation

◆ UVMap()

UVMap ( const uint8_t data,
const uint8_t rgbColors,
uint16_t  xPixels,
uint16_t  yPixels,
uint8_t  colors 
)

Constructs a UVMap with the given image data and color palette.

Parameters
dataPointer to the image data (pixel indices).
rgbColorsPointer to the RGB color palette.
xPixelsWidth of the image in pixels.
yPixelsHeight of the image in pixels.
colorsNumber of colors in the palette.

Definition at line 3 of file UVMap.cpp.

References Image::size.

Member Function Documentation

◆ GetRGB()

RGBColor GetRGB ( const Vector3D position,
const Vector3D normal,
const Vector3D uvw 
)
overridevirtual

Retrieves the RGB color at a given 3D position using UV mapping.

Parameters
position3D position in the scene.
normalNormal vector at the position (not used in UV mapping).
uvwUV texture coordinates at the position.
Returns
The RGB color sampled from the image at the given UV coordinates.

Reimplemented from Image.

Definition at line 8 of file UVMap.cpp.

References Image::colors, Image::data, Image::hueAngle, RGBColor::HueShift(), Mathematics::Map(), Image::rgbColors, Image::size, Vector2D::X, Vector3D::X, Image::xPixels, Vector2D::Y, Vector3D::Y, and Image::yPixels.


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