-
Notifications
You must be signed in to change notification settings - Fork 1
/
Scene.h
56 lines (40 loc) · 1.41 KB
/
Scene.h
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
//
// Created by federico on 11/04/2020.
//
#ifndef CPP_GRAPHICS_SCENE_H
#define CPP_GRAPHICS_SCENE_H
#include <set>
#include "Object/Object.h"
#include "Light/Light.h"
#include "Utils/Geometry/Line.h"
#include "Aspect/Color.h"
#include "Object/Object.h"
#include "Utils/BaseGeometry/Values.h"
/// Class representing the scene
/// Holds all the entities in the scene (objects, cameras, lights...)
class Scene {
public:
void add(Object *object) {
objects.insert(object);
}
void add(Light *light) {
lights.insert(light);
}
/// Casts a ray in the scene, and returns the resulting color
[[nodiscard]] Color cast_ray(const Line& ray, int reflections, float time) const;
private:
Color ambient_intensity = Color(0.05, 0.05, 0.05);
std::set<Object*> objects;
std::set<Light*> lights;
class IntersectionData {
public:
float distance;
Surface * surface;
Object * object;
IntersectionData() : distance(Values::inf), surface(nullptr), object(nullptr) {}
IntersectionData(float distance, Surface *surface, Object *object) : distance(distance), surface(surface), object(object) {}
};
[[nodiscard]] IntersectionData ray_intersection(const Line& ray, float time) const;
[[nodiscard]] Color surface_color(IntersectionData intersection_data, const Line& ray, int reflections, float time) const;
};
#endif //CPP_GRAPHICS_SCENE_H