Add Directional Light to world class
This commit is contained in:
32
src/Light.h
32
src/Light.h
@@ -12,11 +12,15 @@ public:
|
||||
|
||||
virtual void update() = 0;
|
||||
|
||||
void setActive(bool active) { isActive = active; }
|
||||
void setActive(bool active) {
|
||||
isActive = active;
|
||||
update();
|
||||
}
|
||||
void setColor(glm::vec3 color) {
|
||||
lightColor = color;
|
||||
update();
|
||||
}
|
||||
|
||||
void setShaderProgram(ShaderProgram *shaderProgram) {
|
||||
this->shaderProgram = shaderProgram;
|
||||
update();
|
||||
@@ -50,12 +54,14 @@ public:
|
||||
this->position = position;
|
||||
update();
|
||||
}
|
||||
|
||||
void setId(unsigned int id) { lightId = id; }
|
||||
|
||||
void update();
|
||||
|
||||
private:
|
||||
|
||||
void update() override;
|
||||
std::string _getStructMemberName();
|
||||
unsigned int lightId;
|
||||
|
||||
glm::vec3 position = glm::vec3(0.0f, 0.0f, 0.0f);
|
||||
@@ -64,3 +70,25 @@ private:
|
||||
float K_q = 0.032f;
|
||||
|
||||
};
|
||||
|
||||
class DirectionalLight : public Light {
|
||||
|
||||
public:
|
||||
|
||||
DirectionalLight() = default;
|
||||
DirectionalLight(ShaderProgram *shaderProgram);
|
||||
|
||||
void setDirection(glm::vec3 direction) {
|
||||
this->direction = direction;
|
||||
update();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void update() override;
|
||||
|
||||
bool isActive = true;
|
||||
|
||||
glm::vec3 direction = glm::vec3(-0.2f, -1.0f, -0.3f);
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user