-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrtobject.h
159 lines (100 loc) · 2.96 KB
/
rtobject.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#ifndef RTOBJECT_H
#define RTOBJECT_H
#include "rtray.h"
#include "rtbrdf.h"
#include "rtvector.h"
#include <vector>
/**
* @brief The RTObject class Generic class for objects
*/
class RTObject
{
public:
/**
* @brief RTObject Default constructor
*/
RTObject() {}
RTObject(RTBRDF* brdfAux){
double kd = brdfAux->getKa();
double ks = brdfAux->getKs();
double ka = brdfAux->getKa();
double kr= brdfAux->getKr();
double refracIndex=brdfAux->getRefracIndex();
int n = brdfAux->getN();
RTColor color = brdfAux->getColor();
int surfaceType=brdfAux->getSurfaceType();
int material=brdfAux->getMaterial();
RTBRDF *cpyBrdf= new RTBRDF(ka,kd,ks,kr,refracIndex,n,surfaceType,material,color);
this->brdf=cpyBrdf;
}
RTObject(const RTObject &cpy) {
this->objTag=cpy.getObjTag();
RTBRDF *brdfAux=cpy.getBrdf();
double kd = brdfAux->getKa();
double ks = brdfAux->getKs();
double ka = brdfAux->getKa();
double kr= brdfAux->getKr();
double refracIndex=brdfAux->getRefracIndex();
int n = brdfAux->getN();
RTVector v;
RTColor color = brdfAux->getColor();
int surfaceType=brdfAux->getSurfaceType();
int material=brdfAux->getMaterial();
RTBRDF *cpyBrdf= new RTBRDF(ka,kd,ks,kr,refracIndex,n,surfaceType,material,color);
this->brdf=cpyBrdf;
}
RTObject & operator=(const RTObject &other){
this->objTag=other.getObjTag();
RTBRDF *brdfAux=other.getBrdf();
double kd = brdfAux->getKa();
double ks = brdfAux->getKs();
double ka = brdfAux->getKa();
double kr= brdfAux->getKr();
double refracIndex=brdfAux->getRefracIndex();
int n = brdfAux->getN();
RTVector v;
RTColor color = brdfAux->getColor();
int surfaceType=brdfAux->getSurfaceType();
int material=brdfAux->getMaterial();
delete brdf;
RTBRDF *cpyBrdf= new RTBRDF(ka,kd,ks,kr,refracIndex,n,surfaceType,material,color);
this->brdf=cpyBrdf;
}
virtual ~RTObject(){
// delete brdf;
}
/**
* @brief intersect Check if the ray intersect the object and return the hit point.
* @param ray The ray to check.
* @param hitPoint The point where the ray touched.
* @return True if an intersect was found, false otherwise.
*/
virtual bool intersect( RTRay &ray,double &t){
return false;
}
virtual RTVector normalOfHitPoint(RTVector hit){
return RTVector(0,0,0);
}
int getObjTag() const
{
return objTag;
}
void setObjTag(int value)
{
objTag = value;
}
RTBRDF *getBrdf() const
{
return brdf;
}
void setBrdf(RTBRDF *value)
{
brdf = value;
}
private:
RTBRDF *brdf;
protected:
int objTag;
};
enum {PLANE=1,SPHERE,TRIANGLES,TORUS};
#endif // RTOBJECT_H