ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
Scene.h
Go to the documentation of this file.
1/**
2 * @file Scene.h
3 * @brief Defines the `Scene` class for managing objects and effects in a 3D environment.
4 *
5 * The `Scene` class serves as a container for 3D objects and optional screen-space effects.
6 * It provides methods to manage objects and apply visual effects to the entire scene.
7 *
8 * @date 22/12/2024
9 * @version 1.0
10 * @author Coela Can't
11 */
12
13#pragma once
14
15#include "Screenspace/Effect.h"
16#include "Objects/Object3D.h"
17
18/**
19 * @class Scene
20 * @brief Manages a collection of 3D objects and applies optional screen-space effects.
21 *
22 * The `Scene` class allows for the addition, removal, and management of 3D objects.
23 * It also supports applying screen-space effects to modify the appearance of the entire scene.
24 */
25class Scene {
26private:
27
28 const int maxObjects; ///< Maximum number of objects allowed in the scene.
29 Object3D** objects; ///< Array of pointers to the `Object3D` instances in the scene.
30 unsigned int numObjects = 0; ///< Current number of objects in the scene.
31 Effect* effect; ///< Pointer to the screen-space `Effect` applied to the scene.
32 bool doesUseEffect = false; ///< Flag indicating whether the effect is enabled.
33
34 /**
35 * @brief Removes an object from the scene by its index.
36 *
37 * This method adjusts the internal array to maintain order.
38 *
39 * @param element Index of the object to remove.
40 */
41 void RemoveElement(unsigned int element);
42
43public:
44 /**
45 * @brief Constructs a `Scene` instance.
46 *
47 * @param maxObjects Maximum number of objects the scene can hold.
48 */
49 Scene(unsigned int maxObjects);
50
51 /**
52 * @brief Destructor for `Scene`, freeing allocated resources.
53 */
54 ~Scene();
55
56 /**
57 * @brief Checks if an effect is enabled for the scene.
58 *
59 * @return `true` if an effect is enabled, otherwise `false`.
60 */
61 bool UseEffect();
62
63 /**
64 * @brief Enables the screen-space effect for the scene.
65 */
66 void EnableEffect();
67
68 /**
69 * @brief Disables the screen-space effect for the scene.
70 */
71 void DisableEffect();
72
73 /**
74 * @brief Retrieves the current screen-space effect.
75 *
76 * @return Pointer to the current `Effect`, or `nullptr` if no effect is set.
77 */
79
80 /**
81 * @brief Sets the screen-space effect for the scene.
82 *
83 * @param effect Pointer to the `Effect` to apply.
84 */
85 void SetEffect(Effect* effect);
86
87 /**
88 * @brief Adds a 3D object to the scene.
89 *
90 * @param object Pointer to the `Object3D` to add.
91 */
92 void AddObject(Object3D* object);
93
94 /**
95 * @brief Removes a 3D object from the scene by its index.
96 *
97 * @param i Index of the object to remove.
98 */
99 void RemoveObject(unsigned int i);
100
101 /**
102 * @brief Removes a specific 3D object from the scene.
103 *
104 * @param object Pointer to the `Object3D` to remove.
105 */
106 void RemoveObject(Object3D* object);
107
108 /**
109 * @brief Retrieves all objects in the scene.
110 *
111 * @return Pointer to the array of `Object3D` pointers.
112 */
114
115 /**
116 * @brief Retrieves the current number of objects in the scene.
117 *
118 * @return Number of objects in the scene.
119 */
120 uint8_t GetObjectCount();
121};
Defines the base Effect class for applying transformations or effects to pixel groups.
Defines the Object3D class, representing a 3D object with geometry, material, and transformation data...
Abstract base class for applying visual effects to pixel groups.
Definition Effect.h:26
Represents a 3D object with geometry, material, and transformation data.
Definition Object3D.h:28
Manages a collection of 3D objects and applies optional screen-space effects.
Definition Scene.h:25
void SetEffect(Effect *effect)
Sets the screen-space effect for the scene.
Definition Scene.cpp:27
Object3D ** objects
Array of pointers to the Object3D instances in the scene.
Definition Scene.h:29
~Scene()
Destructor for Scene, freeing allocated resources.
Definition Scene.cpp:7
bool doesUseEffect
Flag indicating whether the effect is enabled.
Definition Scene.h:32
void RemoveObject(unsigned int i)
Removes a 3D object from the scene by its index.
Definition Scene.cpp:42
void AddObject(Object3D *object)
Adds a 3D object to the scene.
Definition Scene.cpp:31
bool UseEffect()
Checks if an effect is enabled for the scene.
Definition Scene.cpp:11
void DisableEffect()
Disables the screen-space effect for the scene.
Definition Scene.cpp:19
const int maxObjects
Maximum number of objects allowed in the scene.
Definition Scene.h:28
void RemoveElement(unsigned int element)
Removes an object from the scene by its index.
Definition Scene.cpp:36
uint8_t GetObjectCount()
Retrieves the current number of objects in the scene.
Definition Scene.cpp:62
Object3D ** GetObjects()
Retrieves all objects in the scene.
Definition Scene.cpp:58
Effect * effect
Pointer to the screen-space Effect applied to the scene.
Definition Scene.h:31
unsigned int numObjects
Current number of objects in the scene.
Definition Scene.h:30
Effect * GetEffect()
Retrieves the current screen-space effect.
Definition Scene.cpp:23
void EnableEffect()
Enables the screen-space effect for the scene.
Definition Scene.cpp:15