-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSpotLight.cpp
49 lines (41 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
#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 xPosition, GLfloat yPosition, GLfloat zPosition,
GLfloat xDirection, GLfloat yDirection, GLfloat zDirection,
GLfloat con, GLfloat lin, GLfloat exp,
GLfloat edg) : PointLight(red, green, blue, aIntensity, dIntensity, xPosition, yPosition, zPosition, con, lin, exp)
{
direction = glm::normalize(glm::vec3(xDirection, yDirection, zDirection));
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);
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;
}
SpotLight::~SpotLight()
{
}