-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSpotLight.cpp
56 lines (45 loc) · 1.52 KB
/
SpotLight.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
#include "SpotLight.h"
SpotLight::SpotLight() : PointLight()
{
direction = glm::vec3(0.0f, -1.0f, 0.0f);
edge = 0.0f;
procEdge = cosf(glm::radians(edge));
}
SpotLight::SpotLight(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(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, color.x, color.y, color.z);
glUniform1f(ambientIntensityLocation, ambientIntensity);
glUniform1f(diffuseIntensityLocation, diffuseIntensity);
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;
}
void SpotLight::SetPos(glm::vec3 pos)
{
position = pos;
}
SpotLight::~SpotLight()
{
}