-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlight.hpp
53 lines (38 loc) · 891 Bytes
/
light.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
47
48
49
50
51
52
#ifndef LIGHT_HPP
#define LIGHT_HPP
#include "mesh/object.hpp"
#include "node.hpp"
class Light {
public:
virtual glm::vec3 color() const = 0;
virtual glm::vec3 pos() const = 0;
};
class PointLight : public Light {
public:
PointLight(const LightConf& conf) : conf(conf) {}
virtual glm::vec3 color() const {
return conf.color;
}
virtual glm::vec3 pos() const {
return conf.pos;
}
protected:
LightConf conf;
};
class SolidLight : public Light {
public:
SolidLight(const Node* node) : node(node) {}
virtual glm::vec3 color() const {
Intersection ix;
node->sample(ix);
return ix.mat->diffCol;
}
virtual glm::vec3 pos() const {
Intersection ix;
node->sample(ix);
return ix.pos;
}
protected:
const Node* node;
};
#endif /* LIGHT_HPP */