This commit is contained in:
2025-07-16 00:32:40 +02:00
parent d1690192db
commit aaf76a3ff0
41 changed files with 2963 additions and 599 deletions

26
src/td/render/Camera.cpp Normal file
View File

@@ -0,0 +1,26 @@
#include <td/render/Camera.h>
#include <cmath>
namespace td {
namespace render {
void Camera::UpdatePerspective(float a_AspectRatio) {
m_ProjectionMatrix = maths::Perspective(80.0f / 180.0f * PI, a_AspectRatio, 0.1f, 160.0f);
m_InvProjectionMatrix = maths::Inverse(m_ProjectionMatrix);
}
void Camera::SetCamPos(const Vec3f& a_NewPos) {
Vec3f front = {
std::cos(m_Yaw) * std::cos(m_Pitch),
std::sin(m_Pitch),
std::sin(m_Yaw) * std::cos(m_Pitch)
};
m_CamPos = a_NewPos;
m_ViewMatrix = maths::Look(m_CamPos, front, { 0, 1, 0 });
m_InvViewMatrix = maths::Transpose(maths::Inverse(m_ViewMatrix)); // why transpose ? I don't know
}
} // namespace render
} // namespace td