small fix

This commit is contained in:
Lendemor 2018-05-30 21:06:57 +02:00
parent 4b82c32cb3
commit 5a2e309b41
2 changed files with 25 additions and 17 deletions

View File

@ -34,29 +34,17 @@ void NewResourcePack::gui()
tmp.m_resources = this->m_resources;
output(tmp);
}catch(cereal::Exception e){
std::cerr << "WUT : " << e.what() << std::endl;
std::cerr << "Error while saving resource pack : " << e.what() << std::endl;
}
}
if(ImGui::Button("Load resource pack"))
{
// std::fstream file;
// file.open("data/" + m_name + ".pack", std::ios_base::in);
// ObjectLoader loader;
// loader.loadAscii(file);
// file.close();
// const std::vector<ResourcePack*>& packVec = loader.getObjects<ResourcePack>();
// for(ResourceInterface* res : m_resources)
// delete res;
// m_resources = packVec[0]->m_resources;
// delete packVec[0];
std::ifstream inputStream("data/"+m_name+".pack");
cereal::JSONInputArchive input(inputStream);
NewResourcePack tmp = NewResourcePack();
input(tmp);
this->m_name = tmp.m_name;
this->m_resources = tmp.m_resources;
inputStream.close();
}
if(ImGui::Button("Add a texture"))
@ -149,6 +137,7 @@ void TextureResource::destroy()
void TextureResource::gui()
{
char buf[1024] = {0};
// m_name = ResourceInterface::m_name;
strcpy(buf, m_path.c_str());
if(ImGui::InputText("Image file", buf, 1024))
m_path = buf;

View File

@ -82,6 +82,9 @@ public:
void gui();
};
CEREAL_REGISTER_TYPE(TextureResource)
CEREAL_REGISTER_POLYMORPHIC_RELATION(ResourceInterface,TextureResource)
class MaterialResource : public ResourceInterface
{
glm::vec3 m_albedo;
@ -126,9 +129,25 @@ public:
void gui();
};
CEREAL_REGISTER_TYPE(TextureResource)
CEREAL_REGISTER_POLYMORPHIC_RELATION(ResourceInterface,TextureResource)
//CEREAL_REGISTER_TYPE(MaterialResource)
//CEREAL_REGISTER_POLYMORPHIC_RELATION(ResourceInterface,MaterialResource)
template<class Archive>
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