diff --git a/Editor/Editor.cpp b/Editor/Editor.cpp index 96398676..2279bd49 100644 --- a/Editor/Editor.cpp +++ b/Editor/Editor.cpp @@ -67,6 +67,8 @@ int main() { gizmoDrawer.DrawGizmos(currentScene); } + + // } sceneFramebuffer->Unbind(); diff --git a/Editor/src/ComponentsPanel/MeshPanel.h b/Editor/src/ComponentsPanel/MeshPanel.h index 30c8ed81..ebd7d479 100644 --- a/Editor/src/ComponentsPanel/MeshPanel.h +++ b/Editor/src/ComponentsPanel/MeshPanel.h @@ -3,6 +3,8 @@ #include #include +#include + class MeshPanel : ComponentPanel { public: @@ -19,18 +21,19 @@ public: ImGui::Text("Mesh"); ImGui::TableNextColumn(); - std::string path = component.ModelPath; - ImGui::Button(component.ModelPath.c_str(), ImVec2(ImGui::GetContentRegionAvail().x, 0)); + std::string label = std::to_string(component.ModelResource->ID); + ImGui::Button(label.c_str(), ImVec2(ImGui::GetContentRegionAvail().x, 0)); + if (ImGui::BeginDragDropTarget()) { if (const ImGuiPayload* payload = ImGui::AcceptDragDropPayload("_Model")) { char* file = (char*)payload->Data; std::string fullPath = std::string(file, 256); - path = Nuake::FileSystem::AbsoluteToRelative(fullPath); - - component.ModelPath = path; - component.LoadModel(); + fullPath = Nuake::FileSystem::AbsoluteToRelative(fullPath); + + //component.ModelPath = path; + //component.LoadModel(); } ImGui::EndDragDropTarget(); } diff --git a/Editor/src/Windows/EditorInterface.cpp b/Editor/src/Windows/EditorInterface.cpp index 0fed5b5c..719506ce 100644 --- a/Editor/src/Windows/EditorInterface.cpp +++ b/Editor/src/Windows/EditorInterface.cpp @@ -43,6 +43,7 @@ #include "WelcomeWindow.h" #include "src/Rendering/SceneRenderer.h" #include +#include namespace Nuake { Ref userInterface; @@ -54,6 +55,8 @@ namespace Nuake { { filesystem = new FileSystemUI(this); _WelcomeWindow = new WelcomeWindow(this); + + m_EntitySelectionFramebuffer = CreateRef(false, Vector2(1280, 720)); } void EditorInterface::Init() @@ -1078,19 +1081,8 @@ namespace Nuake { Engine::LoadScene(scene); } - Ref SceneSnapshot; - void EditorInterface::Draw() + void EditorInterface::DrawMenuBar() { - Init(); - - if (!Engine::GetProject()) - { - _WelcomeWindow->Draw(); - return; - } - - pInterface.m_CurrentProject = Engine::GetProject(); - if (ImGui::BeginMainMenuBar()) { if (ImGui::BeginMenu("File")) @@ -1122,7 +1114,7 @@ namespace Nuake { Selection = EditorSelection(); } ImGui::Separator(); - if (ImGui::MenuItem("Set current scene as default")) + if (ImGui::MenuItem("Set current scene as default")) { Engine::GetProject()->DefaultScene = Engine::GetCurrentScene(); } @@ -1180,16 +1172,16 @@ namespace Nuake { { if (ImGui::BeginMenu("Create new")) { - if (ImGui::MenuItem("Empty")) + if (ImGui::MenuItem("Empty")) { auto ent = Engine::GetCurrentScene()->CreateEntity("Empty entity"); } - if (ImGui::MenuItem("Light")) + if (ImGui::MenuItem("Light")) { auto ent = Engine::GetCurrentScene()->CreateEntity("Light"); ent.AddComponent(); } - if (ImGui::MenuItem("Camera")) + if (ImGui::MenuItem("Camera")) { auto ent = Engine::GetCurrentScene()->CreateEntity("Camera"); ent.AddComponent(); @@ -1204,7 +1196,7 @@ namespace Nuake { auto ent = Engine::GetCurrentScene()->CreateEntity("Trenchbroom map"); ent.AddComponent(); } - if (ImGui::MenuItem("Mesh")) + if (ImGui::MenuItem("Mesh")) { auto ent = Engine::GetCurrentScene()->CreateEntity("Mesh"); ent.AddComponent(); @@ -1230,6 +1222,22 @@ namespace Nuake { if (ImGui::BeginMenu("Quit")) ImGui::EndMenu(); ImGui::EndMainMenuBar(); } + } + + Ref SceneSnapshot; + void EditorInterface::Draw() + { + Init(); + + if (!Engine::GetProject()) + { + _WelcomeWindow->Draw(); + return; + } + + pInterface.m_CurrentProject = Engine::GetProject(); + + DrawMenuBar(); pInterface.DrawEntitySettings(); DrawViewport(); diff --git a/Editor/src/Windows/EditorInterface.h b/Editor/src/Windows/EditorInterface.h index 8e5f3309..e7e51728 100644 --- a/Editor/src/Windows/EditorInterface.h +++ b/Editor/src/Windows/EditorInterface.h @@ -21,6 +21,7 @@ namespace Nuake { ImGuizmo::MODE CurrentMode = ImGuizmo::WORLD; Ref m_SelectedMaterial; Ref m_CurrentDirectory; + Ref m_EntitySelectionFramebuffer; bool m_IsMaterialSelected = false; public: @@ -35,6 +36,7 @@ namespace Nuake { void BuildFonts(); void Init(); void Draw(); + void DrawMenuBar(); void DrawViewport(); void DrawEntityTree(Entity ent); void DrawSceneTree(); diff --git a/Nuake/src/Rendering/SceneRenderer.cpp b/Nuake/src/Rendering/SceneRenderer.cpp index 92155180..7be16d47 100644 --- a/Nuake/src/Rendering/SceneRenderer.cpp +++ b/Nuake/src/Rendering/SceneRenderer.cpp @@ -13,7 +13,7 @@ namespace Nuake { mGBuffer->SetTexture(CreateRef(Vector2(1920, 1080), GL_RGB), GL_COLOR_ATTACHMENT1); mGBuffer->SetTexture(CreateRef(Vector2(1920, 1080), GL_RGB), GL_COLOR_ATTACHMENT2); mGBuffer->SetTexture(CreateRef(Vector2(1920, 1080), GL_RGB), GL_COLOR_ATTACHMENT3); - + mShadingBuffer = CreateScope(true, Vector2(1920, 1080)); Ref shadedTexture = CreateRef(Vector2(1920, 1080), GL_RGB, GL_RGB16F, GL_FLOAT); mShadingBuffer->SetTexture(shadedTexture); @@ -27,7 +27,6 @@ namespace Nuake { mToneMapBuffer = CreateScope(false, Vector2(1920, 1080)); mToneMapBuffer->SetTexture(CreateRef(Vector2(1920, 1080), GL_RGB), GL_COLOR_ATTACHMENT0); - } void SceneRenderer::Cleanup() diff --git a/Nuake/src/Resource/ResourceLoader.h b/Nuake/src/Resource/ResourceLoader.h index ed82010a..95a28101 100644 --- a/Nuake/src/Resource/ResourceLoader.h +++ b/Nuake/src/Resource/ResourceLoader.h @@ -18,8 +18,7 @@ namespace Nuake ResourceLoader() = default; ~ResourceLoader() = default; - - static Ref LoadResource(const std::string& path) + static Ref LoadMaterial(const std::string& path) { const std::string FILE_NOT_FOUND = "[Resource Loader] File doesn't exists. \n "; const std::string WRONG_EXTENSION = "[Resource Loader] Resource type mismatch file extension. \n expected: "; @@ -55,7 +54,6 @@ namespace Nuake return material; } - private: static UUID ReadUUID(json j) { diff --git a/Nuake/src/Scene/Components/MeshComponent.h b/Nuake/src/Scene/Components/MeshComponent.h index 54e25865..1b9caa6e 100644 --- a/Nuake/src/Scene/Components/MeshComponent.h +++ b/Nuake/src/Scene/Components/MeshComponent.h @@ -30,12 +30,12 @@ namespace Nuake bool Deserialize(const std::string str) { BEGIN_DESERIALIZE(); - ModelPath = j["ModelPath"]; + ModelPath = j["ModelPath"].dump(); ModelResource = CreateRef(); if (j.contains("ModelResource")) { - auto res = j["ModelResource"]; + auto& res = j["ModelResource"]; ModelResource->Deserialize(res.dump()); }