#include "Camera.h"

Camera::Camera()
    : position(0.0f, 0.0f, 5.0f),
      yaw(-90.0f),
      pitch(0.0f),
      fov(45.0f),
      aspect(4.0f / 3.0f),
      nearPlane(0.1f),
      farPlane(100.0f)
{
}

Camera::~Camera() {
}

void Camera::Update(float deltaTime) {
    // For now, we do not modify the camera over time.
    // Input or smoothing could be handled here.
}

void Camera::SetPosition(const glm::vec3& pos) {
    position = pos;
}

void Camera::SetRotation(float newYaw, float newPitch) {
    yaw = newYaw;
    pitch = newPitch;
}

glm::mat4 Camera::GetViewMatrix() const {
    // Compute the forward vector from yaw and pitch.
    glm::vec3 front;
    front.x = cos(glm::radians(yaw)) * cos(glm::radians(pitch));
    front.y = sin(glm::radians(pitch));
    front.z = sin(glm::radians(yaw)) * cos(glm::radians(pitch));
    front = glm::normalize(front);
    return glm::lookAt(position, position + front, glm::vec3(0, 1, 0));
}

glm::mat4 Camera::GetProjectionMatrix() const {
    return glm::perspective(glm::radians(fov), aspect, nearPlane, farPlane);
}

void Camera::SetPerspective(float fov, float aspect, float nearPlane, float farPlane) {
    this->fov = fov;
    this->aspect = aspect;
    this->nearPlane = nearPlane;
    this->farPlane = farPlane;
}

glm::vec3 Camera::GetPosition() const {
    return position;
}

float Camera::GetYaw() const {
    return yaw;
}

float Camera::GetPitch() const {
    return pitch;
}
