-
Notifications
You must be signed in to change notification settings - Fork 1
/
primitive.h
63 lines (49 loc) · 1.33 KB
/
primitive.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
57
58
59
60
61
62
63
#ifndef _PRIMITIVE_H_
#define _PRIMITIVE_H_
#include <vector>
#include "photon.h"
class Mesh;
class Ray;
class Hit;
class Material;
class ArgParser;
// ====================================================================
// The base class for implicit object representations. These objects
// can be intersected with a ray for ray tracing and also be
// rasterized for OpenGL and for use in radiosity.
class Primitive {
public:
virtual ~Primitive() {}
// accessor
Material* getMaterial() const { return material; }
// for ray tracing
virtual bool intersect(const Ray &r, Hit &h) const = 0;
// for OpenGL rendering & radiosity
virtual void addRasterizedFaces(Mesh *m, ArgParser *args) = 0;
// For photon mapping radio transmission project
void addPhoton(const Photon &p) {
photons.push_back(p);
}
std::vector<Photon> getPhotons() {
return photons;
}
void resetPhotons() {
photons.clear();
}
double getIntensity() { return intensity; }
void setIntensity(double d) {
if (d < 0.0) {
d = 0.0;
}
if (d > 1.0) {
d = 1.0;
}
intensity = d;
}
protected:
// REPRESENTATION
Material *material;
std::vector<Photon> photons;
double intensity;
};
#endif