-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscene.h
52 lines (38 loc) · 1.09 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
#ifndef SCENE_H_
#define SCENE_H_
#include <vector>
#include <limits>
#include <memory>
#include <cmath>
#include <iostream>
#include <algorithm>
#include "util.h"
#include "geometry.h"
#include "linalg/linalg.h"
#include "sphere.h"
class Scene {
private:
std::vector<std::unique_ptr<Geometry>> objects;
std::vector<vec> lights;
vec cameraPos;
vec screenPos;
int width;
int height;
const std::unique_ptr<Geometry>& getClosestGeom(Ray ray) const;
double smallestDistanceToObjectInRay(Ray ray) const;
public:
const Ray getRay(int x, int y);
std::vector<vec> lightsHit(const vec& point);
Color traceRay(Ray ray, int depth);
Scene(vec cameraPos, vec screenPos, int width, int height):
cameraPos(cameraPos), screenPos(screenPos), width(width), height(height) {}
Scene(int width, int height):
Scene(vec(0.0f,0.0f,0.0f), vec(0.0f, 0.0f, 1.0f), width, height) {}
void addLight(vec light) {
lights.push_back(light);
}
void addToScene(std::unique_ptr<Geometry> g) {
objects.push_back(std::move(g));
}
};
#endif