-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpotLight.cpp
More file actions
executable file
·62 lines (51 loc) · 1.71 KB
/
SpotLight.cpp
File metadata and controls
executable file
·62 lines (51 loc) · 1.71 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
#include "SpotLight.h"
SpotLight::SpotLight() : PointLight()
{
direction = glm::vec3(0.0f, -1.0f, 0.0f);
edge = 0.0f;
procEdge = cosf(glm::radians(edge));
isOn = true;
}
SpotLight::SpotLight(GLfloat shadowWidth, GLfloat shadowHeight,
GLfloat near, GLfloat far,
GLfloat red, GLfloat green, GLfloat blue,
GLfloat aIntensity, GLfloat dIntensity,
GLfloat xPos, GLfloat yPos, GLfloat zPos,
GLfloat xDir, GLfloat yDir, GLfloat zDir,
GLfloat con, GLfloat lin, GLfloat exp,
GLfloat edg) : PointLight(shadowWidth, shadowHeight, near, far, red, green, blue, aIntensity, dIntensity, xPos, yPos, zPos, con, lin, exp)
{
direction = glm::normalize(glm::vec3(xDir, yDir, zDir));
edge = edg;
procEdge = cosf(glm::radians(edge));
}
void SpotLight::UseLight(GLuint ambientIntensityLocation, GLuint ambientColourLocation,
GLuint diffuseIntensityLocation, GLuint positionLocation, GLuint directionLocation,
GLuint constantLocation, GLuint linearLocation, GLuint exponentLocation,
GLuint edgeLocation)
{
glUniform3f(ambientColourLocation, colour.x, colour.y, colour.z);
if (isOn)
{
glUniform1f(ambientIntensityLocation, ambientIntensity);
glUniform1f(diffuseIntensityLocation, diffuseIntensity);
}
else {
glUniform1f(ambientIntensityLocation, 0.0f);
glUniform1f(diffuseIntensityLocation, 0.0f);
}
glUniform3f(positionLocation, position.x, position.y, position.z);
glUniform1f(constantLocation, constant);
glUniform1f(linearLocation, linear);
glUniform1f(exponentLocation, exponent);
glUniform3f(directionLocation, direction.x, direction.y, direction.z);
glUniform1f(edgeLocation, procEdge);
}
void SpotLight::SetFlash(glm::vec3 pos, glm::vec3 dir)
{
position = pos;
direction = dir;
}
SpotLight::~SpotLight()
{
}