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

Renders a real-time clock and date as a material. More...

#include <Clock.h>

Inheritance diagram for Clock:
Collaboration diagram for Clock:

Public Member Functions

 Clock (bool hour24)
 Constructs a Clock instance with a specified time format.
 
void SetMaterial (Material *material)
 Sets the material to be used for rendering the clock.
 
void SetTime (uint8_t hour, uint8_t minute, uint8_t second)
 Sets the current time for the clock.
 
void SetDate (uint8_t day, uint8_t month, uint8_t year, uint8_t wDay)
 Sets the current date for the clock.
 
void SetSize (Vector2D size)
 Sets the size of the clock's rendered area.
 
void SetPosition (Vector2D position)
 Sets the position of the clock in the rendered scene.
 
void SetRotation (float rotation)
 Sets the rotation of the clock in the rendered scene.
 
void Update ()
 Updates the clock's time and date.
 
RGBColor GetRGB (const Vector3D &position, const Vector3D &normal, const Vector3D &uvw) override
 Computes the color at a given position in the clock's material.
 
- Public Member Functions inherited from Material
virtual ~Material ()=default
 Virtual destructor for proper cleanup in derived classes.
 

Private Attributes

TextEngine< 3, 12 > tE = TextEngine<3, 12>(false)
 Text engine for rendering time and date.
 
SimpleMaterial mat = SimpleMaterial(RGBColor(255, 255, 255))
 Default material for the clock.
 
uint8_t hour
 Current hour.
 
uint8_t minute
 Current minute.
 
uint8_t second
 Current second.
 
uint8_t day
 Current day.
 
uint8_t month
 Current month.
 
uint8_t year
 Current year (last two digits).
 
uint8_t wDay
 Current weekday.
 
bool hour24 = false
 Flag for 24-hour format (true) or 12-hour format (false).
 

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...
 

Detailed Description

Renders a real-time clock and date as a material.

The Clock class uses a TextEngine to display formatted time and date, along with a customizable material for rendering.

Definition at line 26 of file Clock.h.

Constructor & Destructor Documentation

◆ Clock()

Clock ( bool  hour24)

Constructs a Clock instance with a specified time format.

Parameters
hour24If true, uses 24-hour format; otherwise, uses 12-hour format.

Definition at line 3 of file Clock.cpp.

References hour24, mat, TextEngine< lineCount, characterWidth >::SetBlinkTime(), TextEngine< lineCount, characterWidth >::SetMaterial(), and tE.

Member Function Documentation

◆ GetRGB()

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

Computes the color at a given position in the clock's material.

This method is used for rendering the clock and applying effects.

Parameters
positionThe position in 3D space.
normalThe surface normal vector.
uvwThe texture coordinates.
Returns
The computed color as an RGBColor.

Implements Material.

Definition at line 80 of file Clock.cpp.

References TextEngine< lineCount, characterWidth >::GetRGB(), and tE.

◆ SetDate()

void SetDate ( uint8_t  day,
uint8_t  month,
uint8_t  year,
uint8_t  wDay 
)

Sets the current date for the clock.

Parameters
dayThe day value (1-31).
monthThe month value (1-12).
yearThe last two digits of the year (e.g., 24 for 2024).
wDayThe weekday value (0-6, where 0 = Sunday).

Definition at line 21 of file Clock.cpp.

References day, month, wDay, and year.

Referenced by ClockAnimation::Update().

◆ SetMaterial()

void SetMaterial ( Material material)

Sets the material to be used for rendering the clock.

Parameters
materialPointer to a custom material.

Definition at line 11 of file Clock.cpp.

References TextEngine< lineCount, characterWidth >::SetMaterial(), and tE.

Referenced by ClockAnimation::ClockAnimation().

◆ SetPosition()

void SetPosition ( Vector2D  position)

Sets the position of the clock in the rendered scene.

Parameters
positionA Vector2D representing the position.

Definition at line 32 of file Clock.cpp.

References TextEngine< lineCount, characterWidth >::SetPositionOffset(), and tE.

Referenced by ClockAnimation::Update().

◆ SetRotation()

void SetRotation ( float  rotation)

Sets the rotation of the clock in the rendered scene.

Parameters
rotationThe rotation angle in degrees.

Definition at line 36 of file Clock.cpp.

References TextEngine< lineCount, characterWidth >::SetRotationAngle(), and tE.

Referenced by ClockAnimation::Update().

◆ SetSize()

void SetSize ( Vector2D  size)

Sets the size of the clock's rendered area.

Parameters
sizeA Vector2D representing the size (width and height).

Definition at line 28 of file Clock.cpp.

References TextEngine< lineCount, characterWidth >::SetSize(), and tE.

Referenced by ClockAnimation::Update().

◆ SetTime()

void SetTime ( uint8_t  hour,
uint8_t  minute,
uint8_t  second 
)

Sets the current time for the clock.

Parameters
hourThe hour value (0-23 for 24-hour format, 0-12 for 12-hour format).
minuteThe minute value (0-59).
secondThe second value (0-59).

Definition at line 15 of file Clock.cpp.

References hour, minute, and second.

Referenced by ClockAnimation::Update().

◆ Update()

void Update ( )

Updates the clock's time and date.

This function is called to refresh the displayed time and date values.

Definition at line 40 of file Clock.cpp.

References day, hour, minute, month, second, TextEngine< lineCount, characterWidth >::SetText(), tE, wDay, and year.

Referenced by ClockAnimation::Update().

Member Data Documentation

◆ day

uint8_t day
private

Current day.

Definition at line 33 of file Clock.h.

Referenced by SetDate(), and Update().

◆ hour

uint8_t hour
private

Current hour.

Definition at line 30 of file Clock.h.

Referenced by SetTime(), and Update().

◆ hour24

bool hour24 = false
private

Flag for 24-hour format (true) or 12-hour format (false).

Definition at line 37 of file Clock.h.

Referenced by Clock().

◆ mat

SimpleMaterial mat = SimpleMaterial(RGBColor(255, 255, 255))
private

Default material for the clock.

Definition at line 29 of file Clock.h.

Referenced by Clock().

◆ minute

uint8_t minute
private

Current minute.

Definition at line 31 of file Clock.h.

Referenced by SetTime(), and Update().

◆ month

uint8_t month
private

Current month.

Definition at line 34 of file Clock.h.

Referenced by SetDate(), and Update().

◆ second

uint8_t second
private

Current second.

Definition at line 32 of file Clock.h.

Referenced by SetTime(), and Update().

◆ tE

TextEngine<3, 12> tE = TextEngine<3, 12>(false)
private

Text engine for rendering time and date.

Definition at line 28 of file Clock.h.

Referenced by Clock(), GetRGB(), SetMaterial(), SetPosition(), SetRotation(), SetSize(), and Update().

◆ wDay

uint8_t wDay
private

Current weekday.

Definition at line 36 of file Clock.h.

Referenced by SetDate(), and Update().

◆ year

uint8_t year
private

Current year (last two digits).

Definition at line 35 of file Clock.h.

Referenced by SetDate(), and Update().


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