-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmaterial.cpp
114 lines (100 loc) · 2.39 KB
/
material.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
//
// Created by Anca Negulescu on 30/11/18.
//
#include "precomp.h"
Material::Material(MaterialType mt){
this->mt = mt;
specularity = 0;
refractiveIndex = 0;
if(mt == textured){
this->textureIndex = 0;
}
if(mt == snell || mt == fresnel){
this->refractiveIndex = 1.52f;
}
if(mt == reflective){
specularity = 1;
}
if (mt == light) {
emission = 25.0f;
}
}
void Material::setEmission(float e) {
if (mt == light) {
emission = e;
}
}
void Material::setPhongFactor(int p) {
if (mt == phong) {
phongFactor = p;
}
}
Material::Material(MaterialType mt, int texture){
this->mt = mt;
specularity = 0;
refractiveIndex = 0;
if(mt == textured){
this->textureIndex = texture;
}
if(mt == snell || mt == fresnel){
this->refractiveIndex = 1.52f;
}
if(mt == reflective){
specularity = 1;
}
}
Material::Material(MaterialType mt, float v){
this->mt = mt;
specularity = 0;
refractiveIndex = 0;
if(mt == textured){
this->textureIndex = 0;
}
if(mt == snell || fresnel){
this->refractiveIndex = v;
}
if(mt == reflective){
specularity = v;
}
}
Material::Material(MaterialType mt, float v, vec3 a){
this->mt = mt;
specularity = 0;
refractiveIndex = 0;
if(mt == textured){
this->textureIndex = 0;
}
if(mt == snell || fresnel || beer){
this->refractiveIndex = v;
}
if(mt == reflective){
specularity = v;
}
this->absorbtion = a;
}
Material::Material(MaterialType mt, bool tri){
this->mt = mt;
specularity = 0;
refractiveIndex = 0;
if(mt == textured){
this->textureIndex = 0;
}
if(mt == snell || mt == fresnel){
this->refractiveIndex = 1.52f;
}
if(mt == reflective){
specularity = 1;
}
if (mt == light) {
emission = 8;
}
isTriangle = true;
}
float Material::getIndex() { return refractiveIndex; }
void Material::setIndex(float index) { this->refractiveIndex = index ;}
float Material::getSpecularity() { return specularity; }
void Material::setSpecularity(float sp){ this->specularity = sp; }
vec3 Material::getAbsorbtion() { return absorbtion; }
void Material::setAbsorbtion(vec3 a){ this->absorbtion = a; }
int Material::getTexture() { return textureIndex; }
void Material::setTexture(int index) { this->textureIndex = index ;}