-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLight.h
More file actions
97 lines (78 loc) · 1.9 KB
/
Light.h
File metadata and controls
97 lines (78 loc) · 1.9 KB
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
#pragma once
#include"libs.h"
using namespace std;
class Light
{
protected:
float intensity;
glm::vec3 color;
public:
Light(float intensity, glm::vec3 color)
{
this->intensity = intensity;
this->color = color;
}
~Light()
{
}
//Functions
virtual void sendToShader(Shader& program) = 0;
};
class PointLight : public Light
{
protected:
glm::vec3 position;
float constant;
float linear;
float quadratic;
float bright = 120; ///////////////////////////// CMDFPHONG
float dim = 15;
public:
PointLight(glm::vec3 position, float intensity = 1.f, glm::vec3 color = glm::vec3(1.f, 1.f, 1.f),
float constant = 0.15f, float linear = .0002f, float quadratic = .02f)
: Light(intensity, color)
{
this->position = position;
this->constant = constant;
this->linear = linear;
this->quadratic = quadratic;
this->constant = dim;
}
~PointLight()
{
}
glm::vec3 getPosition()
{
return this->position;
}
void setPosition(const glm::vec3 position)
{
this->position = position;
}
void changeIntensity()
{
if (this->constant == dim)
{
this->constant = bright;
}
else
{
this->constant = dim;
}
}
void sendToShader(Shader& program)
{/*
cout << "this->position: " << to_string(this->position) << "\n";
cout << "this->intensity: " << to_string(this->intensity) << "\n";
cout << "this->color: " << to_string(this->color) << "\n";
cout << "this->constant: " << to_string(this->constant) << "\n";
cout << "this->linear: " << to_string(this->linear) << "\n";
cout << "this->quadratic: " << to_string(this->quadratic) << "\n\n";*/
program.setVec3f(this->position, "pointLight.position");
program.set1f(this->intensity, "pointLight.intensity");
program.setVec3f(this->color, "pointLight.color");
program.set1f(this->constant, "pointLight.constant");
program.set1f(this->linear, "pointLight.linear");
program.set1f(this->quadratic, "pointLight.quadratic");
}
};