-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpointLight.h
More file actions
104 lines (88 loc) · 2.36 KB
/
Copy pathpointLight.h
File metadata and controls
104 lines (88 loc) · 2.36 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
98
99
100
101
102
103
104
#pragma once
//
// pointLight.h
// test
//
// Created by Nazirul Hasan on 22/9/23.
//
#ifndef pointLight_h
#define pointLight_h
#include <glad/glad.h>
#include <glm/glm.hpp>
#include <string>
#include "shader.h"
using namespace std;
class PointLight {
public:
glm::vec3 position;
glm::vec3 ambient;
glm::vec3 diffuse;
glm::vec3 specular;
float k_c;
float k_l;
float k_q;
int Number;
PointLight(float posX, float posY, float posZ, float ambR, float ambG, float ambB, float diffR, float diffG, float diffB, float specR, float specG, float specB, float constant, float linear, float quadratic, int num) {
position = glm::vec3(posX, posY, posZ);
ambient = glm::vec3(ambR, ambG, ambB);
diffuse = glm::vec3(diffR, diffG, diffB);
specular = glm::vec3(specR, specG, specB);
k_c = constant;
k_l = linear;
k_q = quadratic;
Number = num - 1;
}
void setUpPointLight(Shader& lightingShader)
{
lightingShader.use();
string lightNumber = to_string(Number);
lightingShader.setVec3("pointLights[" + lightNumber + "].position", position);
lightingShader.setVec3("pointLights[" + lightNumber + "].ambient", ambient * ambientOn);
lightingShader.setVec3("pointLights[" + lightNumber + "].diffuse", diffuse * diffuseOn);
lightingShader.setVec3("pointLights[" + lightNumber + "].specular", specular * specularOn);
lightingShader.setFloat("pointLights[" + lightNumber + "].k_c", k_c);
lightingShader.setFloat("pointLights[" + lightNumber + "].k_l", k_l);
lightingShader.setFloat("pointLights[" + lightNumber + "].k_q", k_q);
}
void turnOff()
{
ambientOn = 0.0;
diffuseOn = 0.0;
specularOn = 0.0;
}
void turnOn()
{
ambientOn = 1.0;
diffuseOn = 1.0;
specularOn = 1.0;
}
void turnAmbientOn()
{
ambientOn = 1.0;
}
void turnAmbientOff()
{
ambientOn = 0.0;
}
void turnDiffuseOn()
{
diffuseOn = 1.0;
}
void turnDiffuseOff()
{
diffuseOn = 0.0;
}
void turnSpecularOn()
{
specularOn = 1.0;
}
void turnSpecularOff()
{
specularOn = 0.0;
}
private:
float ambientOn = 1.0;
float diffuseOn = 1.0;
float specularOn = 1.0;
};
#endif /* pointLight_h */