ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
Scene.cpp
Go to the documentation of this file.
1#include "Scene.h"
2
3Scene::Scene(unsigned int maxObjects) : maxObjects(maxObjects) {
5}
6
8 delete[] objects;
9}
10
12 return doesUseEffect;
13}
14
16 doesUseEffect = true;
17}
18
20 doesUseEffect = false;
21}
22
24 return effect;
25}
26
27void Scene::SetEffect(Effect* effect) {
28 this->effect = effect;
29}
30
32 objects[numObjects] = object;
33 numObjects++;
34}
35
36void Scene::RemoveElement(unsigned int element) {
37 for (unsigned int i = element; i < numObjects - 1; i++) {
38 objects[i] = objects[i + 1];
39 }
40}
41
42void Scene::RemoveObject(unsigned int i) {
43 if (i < numObjects && i >= 0) {
45 numObjects--;
46 }
47}
48
50 for (unsigned int i = 0; i < numObjects; i++) {
51 if (objects[i] == object) {
53 break;
54 }
55 }
56}
57
59 return objects;
60}
61
63 return numObjects;
64}
Defines the Scene class for managing objects and effects in a 3D environment.
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
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
Scene(unsigned int maxObjects)
Constructs a Scene instance.
Definition Scene.cpp:3
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