-
Notifications
You must be signed in to change notification settings - Fork 1
/
Scene.cpp
77 lines (62 loc) · 1.73 KB
/
Scene.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//
// Created by Jackson Hall on 4/27/2020.
//
#include "Scene.h"
#include "Object3D.h"
#include "graphics.h"
#include <utility>
/** ========== Static Fields ========== */
const int Scene::DEFAULT_WINDOW_WIDTH = 960;
const int Scene::DEFAULT_WINDOW_HEIGHT = 540;
const double Scene::DEFAULT_OBJECT_COLOR_RGB[3] = {0.0, 0.0, 0.0};
/** ========== Constructors ========== */
Scene::Scene() :
Scene(std::vector<Object3D>(), std::vector<Object4D>()) {
}
Scene::Scene(const std::vector<Object3D>& object3ds,
const std::vector<Object4D>& object4ds) :
camera3d(Camera3D()), camera4d(Camera4D()), activeCamera(true){
}
Scene::Scene(
const Camera3D& camera3d,
const Camera4D& camera4d,
const std::vector<Object3D>& object3ds,
const std::vector<Object4D>& object4ds) : activeCamera(true) {
this->camera3d = camera3d;
this->camera4d = camera4d;
this->camera4d.setNormal();
this->camera3d.setNormal();
}
/** ========== Getters ========== */
Camera3D& Scene::getCamera3D() {
return camera3d;
}
Camera4D& Scene::getCamera4D() {
return camera4d;
}
bool Scene::getActiveCamera() const {
return activeCamera;
}
std::vector<Object3D> const& Scene::getObjects3d() const {
return objects3d;
}
std::vector<Object4D> const& Scene::getObjects4d() const {
return objects4d;
}
void Scene::addObject(const Object3D& obj) {
objects3d.push_back(obj);
}
void Scene::addObject(const Object4D& obj) {
objects4d.push_back(obj);
}
void Scene::toggleActiveCamera() {
activeCamera = !activeCamera;
}
void Scene::draw() const {
for (auto & obj : objects3d){
obj.draw(camera3d, camera4d);
}
for (auto & obj : objects4d){
obj.draw(camera3d, camera4d);
}
}