#pragma once
#include <vector>
#include <string>
#include <glm/glm.hpp>
#include <glad.h>

struct OBJVertex {
    glm::vec3 position;
    glm::vec3 normal;
    glm::vec2 texCoord;
    glm::vec3 color;
};

struct OBJFace {
    int vertexIndices[3];
    int texCoordIndices[3];
    int normalIndices[3];
};

class OBJLoader {
public:
    std::vector<OBJVertex> vertices;
    std::vector<unsigned int> indices;
    std::string materialFile;
    
    bool LoadOBJ(const std::string& filepath);
    
private:
    std::vector<glm::vec3> temp_vertices;
    std::vector<glm::vec2> temp_texCoords;
    std::vector<glm::vec3> temp_normals;
    std::vector<OBJFace> faces;
    
    void ProcessLine(const std::string& line);
    void ProcessVertex(const std::string& line);
    void ProcessTexCoord(const std::string& line);
    void ProcessNormal(const std::string& line);
    void ProcessFace(const std::string& line);
    void BuildVertexArray();
};
