#ifndef GP1_DIRECTX_CAMERA_H
#define GP1_DIRECTX_CAMERA_H

#include <cassert>
#include <SDL_keyboard.h>
#include <SDL_mouse.h>

#include "Timer.h"
#include "Math/Vector3.h"
#include "Math/MathHelpers.h"
#include "Math/Matrix.h"

namespace dae {
    class Camera {
    public:
        Camera() = default;

        Camera(const Vector3 &_origin, float _fovAngle);

        void Initialize(float _fovAngle = 90.f, Vector3 _origin = {0.f, 0.f, 0.f}, float _aspect = 1.f);

        void SetFOV(float _fovAngle);

        void CalculateViewMatrix();

        void CalculateProjectionMatrix();

        void Update(const Timer *pTimer);

        Matrix GetViewProjectionMatrix() const;

        const Vector3 &GetPosition();

    private:
        Vector3 origin{};
        float fovAngle{90.f};
        float fov{tanf((fovAngle * TO_RADIANS) / 2.f)};

        Vector3 forward{Vector3::UnitZ};
        Vector3 up{Vector3::UnitY};
        Vector3 right{Vector3::UnitX};

        float totalPitch{};
        float totalYaw{};

        Matrix invViewMatrix{};
        Matrix viewMatrix{};

        Matrix ProjectionMatrix{};

        float aspect{};
        float cameraSpeed{4.f};
        float mouseSens{0.3f};
        float zNear{.1f};
        float zFar{100.f};
    };
}

#endif //GP1_DIRECTX_CAMERA_H
