-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscene.hpp
46 lines (33 loc) · 1.15 KB
/
scene.hpp
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
#pragma once
#include <vector>
#include "vector.hpp"
#include "global.hpp"
#include "object.hpp"
#include "light.hpp"
#include "bvh.hpp"
#include "ray.hpp"
#include "intersection.hpp"
/*
Scene implementation
CORE:
- Ray Tracing (Whitted-style or Path Tracing)
*/
class Scene {
private:
Vector3f backgroundColor = Vector3f(BACKGROUND_R, BACKGROUND_G, BACKGROUND_B);
Vector3f ambientIntensity = Vector3f(AMBIENT_R, AMBIENT_G, AMBIENT_B);
std::vector<Object *> objects;
std::vector<Light *> lights;
BVH *bvh; // only needed by BVH acceleration
public:
Scene(): bvh(nullptr) {}
void add(Object *object) { objects.push_back(object); }
void add(Light *light) { lights.push_back(std::move(light)); }
const std::vector<Object *> &getObjects() const { return objects; }
const std::vector<Light *> &getLights() const { return lights; }
void buildBVH(); // only needed by BVH acceleration
Vector3f castRay(const Ray &ray, int depth) const;
private:
Intersection intersect(const Ray &ray) const;
void sampleLight(Intersection &position, float &pdf) const; // only needed by path tracing
};