33 lines
1.2 KiB
C++
33 lines
1.2 KiB
C++
#pragma once
|
|
#include "Component.h"
|
|
#include "Math/Matrix.h"
|
|
#include "Transform.h"
|
|
#include <glm/trigonometric.hpp>
|
|
|
|
namespace Seele {
|
|
namespace Component {
|
|
struct Camera {
|
|
float fieldOfView = glm::radians(70.0f);
|
|
float aspectRatio = 16.0f / 9.0f;
|
|
float nearPlane = 0.1f;
|
|
float farPlane = 1000.0f;
|
|
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
|