#ifndef MODEL_H_ #define MODEL_H_ #include #include #include #include #include #include #include "shader.h" #include "texture.h" #include "renderer/material.h" #include "renderer/basics.h" #include "renderer/mesh.h" enum ObjElement { OHASH, MTLLIB, USEMTL, O, V, VN, VT, F, OUNKNOWN }; enum MtlElement { MHASH, NEWMTL, NS, KA, KS, KD, NI, D, ILLUM, MAP_KD, MAP_KA, MUNKNOWN }; class Object { private: std::string m_name; std::vector m_vertices; std::vector m_normals; std::vector m_texCoords; std::vector m_meshes; std::unordered_map> m_materials; private: static inline int NormalizeIndex(int idx, int baseCount); private: Object(); public: static Object LoadFile(const std::string& filename); private: void LoadMaterials(const std::filesystem::path& filename); private: void AddMaterial(std::string name, std::shared_ptr material); std::shared_ptr GetMaterial(std::string name); private: Mesh& GetLastMesh(); void CreateNewMesh(const std::string& materialName); public: void Render(Shader& shader); }; #endif // MODEL_H_