finished gui for MaterialResource
This commit is contained in:
parent
7b37039fed
commit
bcc0cade80
16
src/tools/glm_serialize_functions.h
Normal file
16
src/tools/glm_serialize_functions.h
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef GLM_SERIALIZE_FUNCTIONS_H
|
||||
#define GLM_SERIALIZE_FUNCTIONS_H
|
||||
|
||||
#include "glm/vec3.hpp"
|
||||
|
||||
namespace glm
|
||||
{
|
||||
template <class Archive>
|
||||
void serialize(Archive & archive,glm::vec3& v3){
|
||||
archive(cereal::make_nvp("x",v3.x),
|
||||
cereal::make_nvp("y",v3.y),
|
||||
cereal::make_nvp("z",v3.z));
|
||||
}
|
||||
}
|
||||
|
||||
#endif // GLM_SERIALIZE_FUNCTIONS_H
|
@ -8,6 +8,7 @@
|
||||
#include <SparrowRenderer/texture.h>
|
||||
#include <SparrowRenderer/image.h>
|
||||
#include <SparrowRenderer/pbrmaterial.h>
|
||||
#include <SparrowRenderer/mesh.h>
|
||||
|
||||
#include <imgui/imgui.h>
|
||||
|
||||
@ -53,7 +54,6 @@ void ResourcePack::gui()
|
||||
if(ImGui::Button("Add a material"))
|
||||
{
|
||||
std::shared_ptr<ResourceInterface> resource(new MaterialResource());
|
||||
// MaterialResource* resource = new MaterialResource();
|
||||
m_resources.push_back(resource);
|
||||
}
|
||||
|
||||
@ -152,6 +152,7 @@ void TextureResource::gui()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MaterialResource::MaterialResource() :
|
||||
m_material(nullptr)
|
||||
{
|
||||
@ -196,7 +197,60 @@ void MaterialResource::destroy()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MaterialResource::gui()
|
||||
{
|
||||
ImGui::Text("TODO");
|
||||
ImGui::Text("WIP");
|
||||
|
||||
ImGui::ColorEdit3("Albedo", &m_albedo.r);
|
||||
ImGui::SliderFloat("Metallic", &m_metallic,0,1);
|
||||
ImGui::SliderFloat("Roughness", &m_roughness,0,1);
|
||||
ImGui::ColorEdit3("Emission",&m_emission.r);
|
||||
ImGui::SliderFloat("Opacity",&m_opacity,0,1);
|
||||
char buf_albedo[1024] = {0};
|
||||
char buf_metallic[1024] = {0};
|
||||
char buf_roughness[1024] = {0};
|
||||
char buf_emission[1024] = {0};
|
||||
char buf_normal[1024] = {0};
|
||||
char buf_alphamask[1024] = {0};
|
||||
strcpy(buf_albedo, m_albedoTexture.c_str());
|
||||
strcpy(buf_metallic, m_metallicTexture.c_str());
|
||||
strcpy(buf_roughness, m_roughnessTexture.c_str());
|
||||
strcpy(buf_emission, m_emissionTexture.c_str());
|
||||
strcpy(buf_normal, m_normalTexture.c_str());
|
||||
strcpy(buf_alphamask, m_alphaMaskTexture.c_str());
|
||||
|
||||
if(ImGui::InputText("Albedo texture :",buf_albedo,1024))
|
||||
m_albedoTexture = buf_albedo;
|
||||
if(ImGui::InputText("Metallic texture :",buf_metallic,1024))
|
||||
m_metallicTexture = buf_metallic;
|
||||
if(ImGui::InputText("Roughness texture :",buf_roughness,1024))
|
||||
m_roughnessTexture = buf_roughness;
|
||||
if(ImGui::InputText("Emission texture :",buf_emission,1024))
|
||||
m_emissionTexture = buf_emission;
|
||||
if(ImGui::InputText("Normal texture :",buf_normal,1024))
|
||||
m_normalTexture = buf_normal;
|
||||
if(ImGui::InputText("AlphaMask texture :",buf_alphamask,1024))
|
||||
m_alphaMaskTexture = buf_alphamask;
|
||||
|
||||
ImGui::Text(m_material == nullptr ? "Material not loaded" : "Material loaded");
|
||||
if(ImGui::Button(m_material == nullptr ? "Load":"Destroy"))
|
||||
{
|
||||
float temp;
|
||||
if(m_material == nullptr)
|
||||
loadResource(temp);
|
||||
else
|
||||
destroy();
|
||||
}
|
||||
}
|
||||
|
||||
MeshResource::MeshResource():
|
||||
m_mesh(nullptr)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
MeshResource::~MeshResource(){
|
||||
destroy();
|
||||
}
|
||||
|
@ -5,10 +5,12 @@
|
||||
#include <glm/vec3.hpp>
|
||||
|
||||
#include <cereal/archives/json.hpp>
|
||||
#include <cereal/types/array.hpp>
|
||||
//#include <cereal/types/array.hpp>
|
||||
#include <cereal/types/memory.hpp>
|
||||
#include <cereal/types/vector.hpp>
|
||||
|
||||
#include "glm_serialize_functions.h"
|
||||
|
||||
class Texture;
|
||||
class PBRMaterial;
|
||||
class Mesh;
|
||||
@ -56,7 +58,6 @@ struct ResourcePack
|
||||
|
||||
class TextureResource : public ResourceInterface
|
||||
{
|
||||
// std::string m_name;
|
||||
std::string m_path;
|
||||
int m_bitsPerPixel;
|
||||
bool m_isVerticallyReversed;
|
||||
@ -84,9 +85,6 @@ public:
|
||||
void gui();
|
||||
};
|
||||
|
||||
CEREAL_REGISTER_TYPE(TextureResource)
|
||||
CEREAL_REGISTER_POLYMORPHIC_RELATION(ResourceInterface,TextureResource)
|
||||
|
||||
class MaterialResource : public ResourceInterface
|
||||
{
|
||||
glm::vec3 m_albedo;
|
||||
@ -121,7 +119,8 @@ public:
|
||||
CEREAL_NVP(m_roughnessTexture),
|
||||
CEREAL_NVP(m_emissionTexture),
|
||||
CEREAL_NVP(m_normalTexture),
|
||||
CEREAL_NVP(m_alphaMaskTexture));
|
||||
CEREAL_NVP(m_alphaMaskTexture)
|
||||
);
|
||||
}
|
||||
|
||||
void loadResource(float & progress);
|
||||
@ -131,26 +130,6 @@ public:
|
||||
void gui();
|
||||
};
|
||||
|
||||
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)
|
||||
|
||||
class MeshResource : public ResourceInterface
|
||||
{
|
||||
//add metadata for mesh
|
||||
@ -175,4 +154,12 @@ public:
|
||||
void gui();
|
||||
};
|
||||
|
||||
CEREAL_REGISTER_TYPE(TextureResource)
|
||||
CEREAL_REGISTER_TYPE(MaterialResource)
|
||||
CEREAL_REGISTER_TYPE(MeshResource)
|
||||
|
||||
CEREAL_REGISTER_POLYMORPHIC_RELATION(ResourceInterface,TextureResource)
|
||||
CEREAL_REGISTER_POLYMORPHIC_RELATION(ResourceInterface,MaterialResource)
|
||||
CEREAL_REGISTER_POLYMORPHIC_RELATION(ResourceInterface,MeshResource)
|
||||
|
||||
#endif // RESOURCEPACK_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user