46 lines
1.3 KiB
C++
46 lines
1.3 KiB
C++
#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.
|
|
// m_ViewMatrix = dae::Matrix::CreateLookAtLH(m_Position, m_Target, m_Up);
|
|
// m_ProjectionMatrix = dae::Matrix::CreateOrthographic(size, size, nearPlane, farPlane);
|
|
}
|
|
|
|
dae::Vector3 Light::GetTarget() {
|
|
return m_Target;
|
|
}
|
|
|
|
dae::Vector3 Light::GetPosition() {
|
|
return m_Position;
|
|
}
|