//
// Created by sebastian on 29.07.26.
//

#ifndef COLORRACE_CAMERA_H
#define COLORRACE_CAMERA_H
#pragma once
#include <glm/glm.hpp>
namespace engine {
    class Camera {
    private:
        glm::vec3 m_position{0.0f, 5.0f, 0.0f};
        float m_pitch = 0.0f;
        float m_yaw = 0.0f;
        float m_roll = 0.0f;

        float m_fovY = glm::radians(60.0f);
        float m_aspect = 16.0f / 9.0f;
        float m_near = 0.1f;
        float m_far = 1000.0f;


    public:
        Camera() = default;

        // Bewegung relativ zur aktuellen Blickrichtung der Kamera (z.B. aus WASD-Input).
        // direction.x = rechts/links, direction.y = hoch/runter, direction.z = vorwärts/rückwärts
        void moveRelative(const glm::vec3& direction, float speed, float deltaTime);

        // Direkte Bewegung im World-Space (z.B. für Cutscenes, Freikamera per Maus-Drag)
        void moveWorld(const glm::vec3& offset);

        void setPosition(const glm::vec3& position) { m_position = position; }
        [[nodiscard]] const glm::vec3& getPosition() const { return m_position; }

        void setPitch(float pitch) { m_pitch = pitch; }
        void setYaw(float yaw) { m_yaw = yaw; }
        void setRoll(float roll) { m_roll = roll; }
        [[nodiscard]] float getPitch() const { return m_pitch; }
        [[nodiscard]] float getYaw() const { return m_yaw; }
        [[nodiscard]] float getRoll() const { return m_roll; }

        [[nodiscard]] glm::vec3 getForward() const;
        [[nodiscard]] glm::vec3 getRight() const;
        [[nodiscard]] glm::vec3 getUp() const;

        [[nodiscard]] glm::mat4 getViewMatrix() const;

        void setFovY(float fovYRadians) { m_fovY = fovYRadians; }
        void setAspectRatio(float aspect) { m_aspect = aspect; }
        void setNearFar(float near, float far) { m_near = near; m_far = far; }

        [[nodiscard]] float getFovY() const { return m_fovY; }
        [[nodiscard]] float getAspectRatio() const { return m_aspect; }
        [[nodiscard]] float getNear() const { return m_near; }
        [[nodiscard]] float getFar() const { return m_far; }

        [[nodiscard]] glm::mat4 getProjectionMatrix() const;
    };
}


#endif //COLORRACE_CAMERA_H
