-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMaterial_components.h
85 lines (67 loc) · 1.95 KB
/
Material_components.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
#pragma once
class Material_components {
public:
Material_components(){}
Material_components(float sr, float sg, float sb, float sa, float dr, float dg, float db, float da, float ar, float ag, float ab, float aa, float s) {
this->specular[0]=old_specular[0] = sr;
this->specular[1]=old_specular[1] = sg;
this->specular[2]=old_specular[2] = sb;
this->specular[3]=old_specular[3] = sa;
this->diffuse[0]=old_diffuse[0] = dr;
this->diffuse[1]=old_diffuse[1] = dg;
this->diffuse[2]=old_diffuse[2] = db;
this->diffuse[3]=old_diffuse[3] = da;
this->ambient[0]=old_ambient[0] = ar;
this->ambient[1]=old_ambient[1] = ag;
this->ambient[2]=old_ambient[2] = ab;
this->ambient[3]=old_ambient[3] = aa;
this->shininess[0] = s;
for(int i=0; i<4; ++i) emission[i]=old_emission[i]=0;
}
void act(){
glMaterialfv(GL_FRONT, GL_SHININESS, shininess);
glMaterialfv(GL_FRONT, GL_SPECULAR, specular);
glMaterialfv(GL_FRONT, GL_DIFFUSE, diffuse);
glMaterialfv(GL_FRONT, GL_AMBIENT, ambient);
glMaterialfv(GL_FRONT, GL_EMISSION, emission);
}
void set_opac(float a)
{
specular[3]=diffuse[3]=ambient[3]=a;
}
void set_emission(float r,float g,float b)
{
emission[0]=r;
emission[1]=g;
emission[2]=b;
}
void set_diffuse(float r,float g,float b)
{
diffuse[0]=r;
diffuse[1]=g;
diffuse[2]=b;
}
void set_specular(float r,float g,float b)
{
specular[0]=r;
specular[1]=g;
specular[2]=b;
}
void set_ambient(float r,float g,float b)
{
ambient[0]=r;
ambient[1]=g;
ambient[2]=b;
}
void reset(){
for(int i=0; i< 3; ++i){
specular[i]=old_specular[i];
diffuse[i]=old_diffuse[i];
ambient[i]=old_ambient[i];
emission[i]=old_emission[i];
}
}
private:
float specular[4], diffuse[4], ambient[4], shininess[1], emission[4];
float old_specular[4], old_diffuse[4], old_ambient[4], old_shininess[1], old_emission[4];
};