Files
Seele/src/Engine/Component/Camera.h
T

33 lines
1.2 KiB
C++
Raw Normal View History

#pragma once
#include "Component.h"
#include "Math/Matrix.h"
#include "Transform.h"
#include <glm/trigonometric.hpp>
2024-06-09 12:20:04 +02:00
namespace Seele {
namespace Component {
struct Camera {
float fieldOfView = glm::radians(70.0f);
float aspectRatio = 16.0f / 9.0f;
2025-05-10 22:52:46 +02:00
float nearPlane = 0.1f;
float farPlane = 1000.0f;
2025-04-11 23:13:19 +02:00
bool mainCamera = false;
constexpr Matrix4 getProjectionMatrix() const {
if(fieldOfView > 0.0f) {
return perspectiveProjection(fieldOfView, aspectRatio, nearPlane, farPlane);
} else {
float orthoHeight = 10.0f;
float orthoWidth = orthoHeight * aspectRatio;
return orthographicProjection(-orthoWidth / 2.0f, orthoWidth / 2.0f, -orthoHeight / 2.0f, orthoHeight / 2.0f, nearPlane, farPlane);
}
}
constexpr Matrix4 getPerspectiveMatrix() const {
return perspectiveProjection(fieldOfView, aspectRatio, nearPlane, farPlane);
}
constexpr Matrix4 getOrthographicMatrix(float left, float right, float bottom, float top) const {
return orthographicProjection(left, right, bottom, top, nearPlane, farPlane);
}
};
} // namespace Component
} // namespace Seele