ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
Project.cpp
Go to the documentation of this file.
1#include "Project.h"
2
3Project::Project(CameraManager* cameras, Controller* controller, uint8_t numObjects)
4 : cameras(cameras), controller(controller), scene(numObjects) {
5
6 previousAnimationTime = micros();
7 previousRenderTime = micros();
8 previousDisplayTime = micros();
9}
10
14
16 renderTime = ((float)(micros() - previousRenderTime)) / 1000000.0f;
17}
18
22
24 return renderTime;
25}
26
28 return displayTime;
29}
30
34
35void Project::Animate(float ratio) {
36 previousAnimationTime = micros();
37
38 Update(ratio);
39
40 animationTime = ((float)(micros() - previousAnimationTime)) / 1000000.0f;
41}
42
44 previousRenderTime = micros();
45
47 //RenderingEngine::DisplayWhite(cameras);
48
49 renderTime = ((float)(micros() - previousRenderTime)) / 1000000.0f;
50}
51
53 previousDisplayTime = micros();
54
56
57 displayTime = ((float)(micros() - previousDisplayTime)) / 1000000.0f;
58}
59
61 #ifdef PRINTINFO
62 #ifdef DEBUG
63 Serial.print("Free memory ");
64 Serial.print(Debug::FreeMem(), 3);
65 Serial.print("Kb, ");
66 #endif
67 Serial.print("FPS: ");
68 Serial.print(GetFrameRate(), 0);
69 Serial.print(", Animated in ");
70 Serial.print(GetAnimationTime(), 4);
71
72 Serial.print("s, Rendered in ");
73 Serial.print(GetRenderTime(), 4);
74
75 Serial.print("s, Displayed in ");
76 Serial.print(GetDisplayTime(), 4);
77 Serial.println("s");
78 #endif
79}
Declares the Project class for managing animations, rendering, and display operations.
Manages multiple CameraBase objects.
Base class for managing brightness and display operations of lighting controllers.
Definition Controller.h:25
virtual void Display()=0
Updates and displays content on the lighting system.
static float FreeMem()
Calculates the available free memory in the system.
Definition Debug.h:32
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
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
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
static void Rasterize(Scene *scene, CameraManager *cameraManager)
Rasterizes the given scene using the cameras managed by the CameraManager.
Definition Engine.cpp:3
float Filter(float value)
Filters the input value using the running average.