//
// Created by sebastian on 30.07.26.
//

#ifndef COLORRACE_MODEL_H
#define COLORRACE_MODEL_H
#include <memory>

#include "AABB.h"
#include "MeshSection.h"
#include "utils/openglWrapper/openglObjects/Vao.h"


namespace engine {
    class Model {
    public:
        Model(std::unique_ptr<Vao> vao, int vertexCount, bool isIndexed);
        Model(std::unique_ptr<Vao> vao, int vertexCount);
        Model(std::unique_ptr<Vao> vao, int vertexCount, std::vector<MeshSection> sections); // neu
        Model(std::unique_ptr<Vao> vao, int vertexCount, std::vector<MeshSection> sections, AABB aabb); // neu

        void bind() const;
        void unbind() const;
        void draw() const;
        void drawSection(const std::string& name) const;
        void drawSectionRange(unsigned int indexOffset, unsigned int indexCount) const;

        [[nodiscard]] int getVertexCount() const { return m_vertexCount; }
        [[nodiscard]] bool isIndexed() const { return m_isIndexed; }
        [[nodiscard]] bool hasSections() const { return !m_sections.empty(); }
        [[nodiscard]] const std::vector<MeshSection>& getSections() const { return m_sections; }
        [[nodiscard]] const AABB& getAABB() const { return m_aabb; }


    private:
        AABB m_aabb;
        std::unique_ptr<Vao> m_vao;
        int m_vertexCount;
        bool m_isIndexed;
        std::vector<MeshSection> m_sections; // leer bei den alten Konstruktoren
    };
}

#endif //COLORRACE_MODEL_H
