ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
Project.h
Go to the documentation of this file.
1/**
2 * @file Project.h
3 * @brief Declares the Project class for managing animations, rendering, and display operations.
4 *
5 * This file defines the Project class, which integrates camera management, scene rendering,
6 * and display updates while maintaining performance statistics.
7 *
8 * @date 22/12/2024
9 * @author Coela Can't
10 */
11
12#pragma once
13
14#include <Arduino.h> // Include for Arduino compatibility.
15#include "../../Engine/Engine.h" // Include for rendering engine.
16#include "../../Scene/Scene.h" // Include for scene management.
17#include "../../Camera/CameraManager/CameraManager.h" // Include for camera management.
18#include "../../Controller/Controller.h" // Include for controller operations.
19#include "../../Utils/Filter/RunningAverageFilter.h" // Include for filtering utilities.
20#include "Utils/Debug.h" // Include for debugging utilities.
21#include "../UserConfiguration.h" // Include for user-specific configuration.
22
23/**
24 * @class Project
25 * @brief Manages animations, rendering, and display operations.
26 *
27 * The Project class integrates various subsystems including camera management, scene rendering,
28 * and display updates. It also tracks and reports performance metrics such as frame rate and
29 * individual operation times.
30 */
31class Project {
32protected:
33 CameraManager* cameras; ///< Pointer to the CameraManager for managing cameras.
34 Controller* controller; ///< Pointer to the Controller for controlling the display.
35 Scene scene; ///< The Scene object representing the rendered environment.
36
37 RunningAverageFilter<50> avgFPS = RunningAverageFilter<50>(0.05f); ///< Running average filter for frame rate calculation.
38
39 long previousAnimationTime = 0; ///< Time of the previous animation frame in microseconds.
40 long previousRenderTime = 0; ///< Time of the previous render frame in microseconds.
41 long previousDisplayTime = 0; ///< Time of the previous display frame in microseconds.
42 float fade = 0.0f; ///< Fade parameter for animations.
43 float animationTime = 0.0f; ///< Time spent on animation in milliseconds.
44 float renderTime = 0.0f; ///< Time spent on rendering in milliseconds.
45 float displayTime = 0.0f; ///< Time spent on display in milliseconds.
46
47 /**
48 * @brief Updates the project state based on the given ratio.
49 *
50 * This method is intended to be overridden by derived classes to define
51 * specific update logic for animations or state transitions.
52 *
53 * @param ratio A float representing the interpolation ratio for updates.
54 */
55 virtual void Update(float ratio) = 0;
56
57 /**
58 * @brief Starts the render timer for measuring render performance.
59 */
60 void RenderStartTimer();
61
62 /**
63 * @brief Stops the render timer and records the elapsed time.
64 */
65 void RenderEndTimer();
66
67public:
68 /**
69 * @brief Constructs a Project with specified camera manager and controller.
70 *
71 * @param cameras Pointer to the CameraManager managing the cameras.
72 * @param controller Pointer to the Controller managing the display.
73 * @param numObjects Number of objects to initialize in the scene.
74 */
75 Project(CameraManager* cameras, Controller* controller, uint8_t numObjects);
76
77 /**
78 * @brief Retrieves the time spent on animations.
79 *
80 * @return The animation time in milliseconds.
81 */
82 float GetAnimationTime();
83
84 /**
85 * @brief Retrieves the time spent on rendering.
86 *
87 * @return The render time in milliseconds.
88 */
89 float GetRenderTime();
90
91 /**
92 * @brief Retrieves the time spent on display operations.
93 *
94 * @return The display time in milliseconds.
95 */
96 float GetDisplayTime();
97
98 /**
99 * @brief Retrieves the current frame rate.
100 *
101 * @return The frame rate in frames per second (FPS).
102 */
103 float GetFrameRate();
104
105 /**
106 * @brief Initializes the project.
107 *
108 * This method is intended to be overridden by derived classes to define
109 * specific initialization logic for the project.
110 */
111 virtual void Initialize() = 0;
112
113 /**
114 * @brief Animates the project state based on the given ratio.
115 *
116 * @param ratio A float representing the interpolation ratio for animations.
117 */
118 void Animate(float ratio);
119
120 /**
121 * @brief Renders the scene.
122 */
123 void Render();
124
125 /**
126 * @brief Updates the display with the rendered content.
127 */
128 void Display();
129
130 /**
131 * @brief Prints performance statistics such as frame rate and operation times.
132 */
133 void PrintStats();
134};
Declares the CameraManager class for managing multiple camera instances.
Declares the Controller base class for managing lighting controllers.
Utility class for debugging and monitoring system memory.
Declares the RenderingEngine class for rendering and display operations.
Implements a running average filter for smoothing data.
Defines the Scene class for managing objects and effects in a 3D environment.
User-configurable settings for the project.
Manages multiple CameraBase objects.
Base class for managing brightness and display operations of lighting controllers.
Definition Controller.h:25
void RenderEndTimer()
Stops the render timer and records the elapsed time.
Definition Project.cpp:15
float GetAnimationTime()
Retrieves the time spent on animations.
Definition Project.cpp:19
void Animate(float ratio)
Animates the project state based on the given ratio.
Definition Project.cpp:35
Project(CameraManager *cameras, Controller *controller, uint8_t numObjects)
Constructs a Project with specified camera manager and controller.
Definition Project.cpp:3
Scene scene
The Scene object representing the rendered environment.
Definition Project.h:35
float GetRenderTime()
Retrieves the time spent on rendering.
Definition Project.cpp:23
void Render()
Renders the scene.
Definition Project.cpp:43
long previousDisplayTime
Time of the previous display frame in microseconds.
Definition Project.h:41
long previousRenderTime
Time of the previous render frame in microseconds.
Definition Project.h:40
float fade
Fade parameter for animations.
Definition Project.h:42
void Display()
Updates the display with the rendered content.
Definition Project.cpp:52
void PrintStats()
Prints performance statistics such as frame rate and operation times.
Definition Project.cpp:60
void RenderStartTimer()
Starts the render timer for measuring render performance.
Definition Project.cpp:11
long previousAnimationTime
Time of the previous animation frame in microseconds.
Definition Project.h:39
virtual void Initialize()=0
Initializes the project.
float GetFrameRate()
Retrieves the current frame rate.
Definition Project.cpp:31
CameraManager * cameras
Pointer to the CameraManager for managing cameras.
Definition Project.h:33
Controller * controller
Pointer to the Controller for controlling the display.
Definition Project.h:34
virtual void Update(float ratio)=0
Updates the project state based on the given ratio.
float animationTime
Time spent on animation in milliseconds.
Definition Project.h:43
float renderTime
Time spent on rendering in milliseconds.
Definition Project.h:44
float GetDisplayTime()
Retrieves the time spent on display operations.
Definition Project.cpp:27
float displayTime
Time spent on display in milliseconds.
Definition Project.h:45
RunningAverageFilter< 50 > avgFPS
Running average filter for frame rate calculation.
Definition Project.h:37
Smooths data values using a weighted running average.
Manages a collection of 3D objects and applies optional screen-space effects.
Definition Scene.h:25