#ifndef NEWRESOURCEPACK_H #define NEWRESOURCEPACK_H #include #include #include #include #include class Texture; class PBRMaterial; /** * @brief The ResourceInterface struct holds a resource, it handles its loading and its destruction */ struct ResourceInterface { std::string m_name; template void serialize(Archive & archive){ archive(CEREAL_NVP(m_name)); } virtual void loadResource(float & progress) = 0; virtual void destroy() = 0; virtual void gui() = 0; }; /** * @brief The ResourcePack class is just a container of LoadTask, it only exists for serialization purposes */ struct NewResourcePack { std::string m_name; std::vector> m_resources; NewResourcePack() {} void gui(); template void serialize(Archive & archive){ archive(cereal::make_nvp("ResourcePack",m_name),CEREAL_NVP(m_resources)); } }; /* * Some LoadTask implementations */ class TextureResource : public ResourceInterface { // std::string m_name; std::string m_path; int m_bitsPerPixel; bool m_isVerticallyReversed; bool m_needsMipMaps; Texture* m_texture; public: TextureResource(); virtual ~TextureResource(); template void serialize(Archive & archive) { archive(CEREAL_NVP(m_name), CEREAL_NVP(m_path), CEREAL_NVP(m_bitsPerPixel), CEREAL_NVP(m_isVerticallyReversed), CEREAL_NVP(m_needsMipMaps)); } void loadResource(float & progress); void destroy(); void gui(); }; CEREAL_REGISTER_TYPE(TextureResource) CEREAL_REGISTER_POLYMORPHIC_RELATION(ResourceInterface,TextureResource) class MaterialResource : public ResourceInterface { glm::vec3 m_albedo; float m_metallic; float m_roughness; glm::vec3 m_emission; float m_opacity; std::string m_albedoTexture; std::string m_metallicTexture; std::string m_roughnessTexture; std::string m_emissionTexture; std::string m_normalTexture; std::string m_alphaMaskTexture; PBRMaterial* m_material; public: MaterialResource(); virtual ~MaterialResource(); template void serialize(Archive & archive) { archive(CEREAL_NVP(m_name), CEREAL_NVP(m_albedo), CEREAL_NVP(m_metallic), CEREAL_NVP(m_roughness), CEREAL_NVP(m_emission), CEREAL_NVP(m_opacity), CEREAL_NVP(m_albedoTexture), CEREAL_NVP(m_metallicTexture), CEREAL_NVP(m_roughnessTexture), CEREAL_NVP(m_emissionTexture), CEREAL_NVP(m_normalTexture), CEREAL_NVP(m_alphaMaskTexture)); } void loadResource(float & progress); void destroy(); void gui(); }; template void serialize(Archive & archive,MaterialResource mat) { archive(CEREAL_NVP(mat.m_name), CEREAL_NVP(mat.m_albedo), CEREAL_NVP(mat.m_metallic), CEREAL_NVP(mat.m_roughness), CEREAL_NVP(mat.m_emission), CEREAL_NVP(mat.m_opacity), CEREAL_NVP(mat.m_albedoTexture), CEREAL_NVP(mat.m_metallicTexture), CEREAL_NVP(mat.m_roughnessTexture), CEREAL_NVP(mat.m_emissionTexture), CEREAL_NVP(mat.m_normalTexture), CEREAL_NVP(mat.m_alphaMaskTexture)); } CEREAL_REGISTER_TYPE(MaterialResource) CEREAL_REGISTER_POLYMORPHIC_RELATION(ResourceInterface,MaterialResource) #endif // NEWRESOURCEPACK_H