This commit is contained in:
2025-01-14 02:26:26 +01:00
parent 0d556f12b4
commit 9805c7a2c1
26 changed files with 4868 additions and 4 deletions

37
project/src/Light.cpp Normal file
View File

@@ -0,0 +1,37 @@
#include "Light.h"
#include <cmath>
Light::Light()
: m_Position(0.0f, 10.0f, 0.0f),
m_Target(0.0f, 0.0f, 0.0f),
m_Up(0.0f, 1.0f, 0.0f),
m_ViewMatrix(dae::Matrix()),
m_ProjectionMatrix(dae::Matrix()) {}
void Light::SetPosition(const dae::Vector3 &position) {
m_Position = position;
}
void Light::SetTarget(const dae::Vector3 &target) {
m_Target = target;
}
void Light::SetUp(const dae::Vector3 &up) {
m_Up = up;
}
dae::Matrix Light::GetViewMatrix() const {
return dae::Matrix::CreateLookAtLH(m_Position, m_Target, m_Up);
}
dae::Matrix Light::GetProjectionMatrix(float nearPlane, float farPlane, float size) const {
return dae::Matrix::CreateOrthographic(size, size, nearPlane, farPlane);
}
dae::Matrix Light::GetViewProjectionMatrix(float nearPlane, float farPlane, float size) const {
return GetViewMatrix() * GetProjectionMatrix(nearPlane, farPlane, size);
}
void Light::Update() {
// If the light position or target changes dynamically, this is where updates would be managed.
}