-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrtchecktexture.cpp
98 lines (69 loc) · 1.81 KB
/
rtchecktexture.cpp
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
#include "rtchecktexture.h"
#include<cmath>
double RTCheckTexture::getSize() const
{
return size;
}
void RTCheckTexture::setSize(double value)
{
size = value;
}
double RTCheckTexture::getRefracIndex() const
{
return 0;
}
RTCheckTexture::RTCheckTexture(){
}
RTCheckTexture::RTCheckTexture(double ka, double kd, double ks, double kr,int n, int surfaceType, int material,
RTColor colorCheck1, RTColor colorCheck2, double size):RTBRDF(ka,kd,ks,kr,n,surfaceType,material)
{
this->colorCheck1=colorCheck1;
this->colorCheck2=colorCheck2;
this->size=size;
}
RTCheckTexture::RTCheckTexture(RTCheckTexture &cpy)
{
this->ka=cpy.getKa();
this->kd = cpy.getKd();
this->ks = cpy.getKs();
this->ka = cpy.getKa();
this->kr = cpy.getKr();
this->n= cpy.getN();
this->surfaceType=cpy.getSurfaceType();
RTVector v;
this->color = cpy.getColor(v);
this->refracIndex=cpy.getRefracIndex();
this->material=cpy.getMaterial();
this->colorCheck1=cpy.getColorCheck1();
this->colorCheck2=cpy.getColorCheck2();
this->size=cpy.getSize();
}
RTColor RTCheckTexture::getColor(RTVector hitPoint) const
{
double eps=-0.000187453738;
double x= hitPoint.getX()+eps;
double y= hitPoint.getY()+eps;
double z = hitPoint.getZ()+eps;
bool colorChek = (((int) floor(x/size)+(int)floor(y/size)+(int)floor(z/size))%2==0);
if(colorChek)
return colorCheck1;
else {
return colorCheck2;
}
}
RTColor RTCheckTexture::getColorCheck1() const
{
return colorCheck1;
}
void RTCheckTexture::setColorCheck1(const RTColor &value)
{
colorCheck1 = value;
}
RTColor RTCheckTexture::getColorCheck2() const
{
return colorCheck2;
}
void RTCheckTexture::setColorCheck2(const RTColor &value)
{
colorCheck2 = value;
}