-
Notifications
You must be signed in to change notification settings - Fork 0
/
Light.cpp
executable file
·44 lines (34 loc) · 1.21 KB
/
Light.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
#include "Light.h"
Light::Light()
{
colour = glm::vec3(1.0f, 1.0f, 1.0f);
ambientIntensity = 1.0f;
direction = glm::vec3(0.0f, -1.0f, 0.0f);
diffuseIntensity = 0.0f;
}
Light::Light(GLuint shadowWidth, GLuint shadowHeight, GLfloat red, GLfloat green, GLfloat blue, GLfloat aIntensity,
GLfloat xDir, GLfloat yDir, GLfloat zDir, GLfloat dIntensity)
{
colour = glm::vec3(red, green, blue);
ambientIntensity = aIntensity;
direction = glm::vec3(xDir, yDir, zDir);
diffuseIntensity = dIntensity;
shadowMap = new ShadowMap();
shadowMap->Init(shadowWidth, shadowHeight);
lightProj = glm::ortho(-300.0f, 300.0f, -400.0f, 400.0f, 0.1f, 1000.0f);
}
void Light::UseLight(GLfloat ambientIntensityLocation, GLfloat ambientColourLocation,
GLfloat diffuseIntensityLocation, GLfloat directionLocation)
{
glUniform3f(ambientColourLocation, colour.x, colour.y, colour.z);
glUniform1f(ambientIntensityLocation, ambientIntensity);
glUniform3f(directionLocation, direction.x, direction.y, direction.z);
glUniform1f(diffuseIntensityLocation, diffuseIntensity);
}
glm::mat4 Light::CalculateLightTransform()
{
return lightProj * glm::lookAt(-direction, glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f));
}
Light::~Light()
{
}