diff --git a/Editor/src/SceneRuntime.h b/Editor/src/SceneRuntime.h index bb21133..62d8afe 100644 --- a/Editor/src/SceneRuntime.h +++ b/Editor/src/SceneRuntime.h @@ -4,6 +4,8 @@ #include "../../YoggieEngine/src/PerfCounter.h" #include "../../YoggieEngine/src/Scene/Entity.h" #include "Project/Project.h" +#include "AssetManagement/AssetManager.h" + class EditorRuntime : public ApplicationRuntime { @@ -12,8 +14,15 @@ public: void Start() override { CurrentProject = std::make_shared("Random"); + + std::string path = (std::filesystem::current_path()).string(); + CurrentProject.get()->setProjectDirectory(path); - framebuffer = new Framebuffer(); + AssetManager::Init(); + AssetManager::setAssetPath(CurrentProject.get()->GetProjectDirectory()); + AssetManager::BuildAssetView(); + + framebuffer = new Framebuffer(800, 600); // Create a level and load it as the current level auto importer = ModelImporter(); @@ -43,6 +52,7 @@ public: void Update() override { + } void FixedUpdate() override diff --git a/Editor/src/UI/widgets.cpp b/Editor/src/UI/widgets.cpp index 9cd3eb3..030114e 100644 --- a/Editor/src/UI/widgets.cpp +++ b/Editor/src/UI/widgets.cpp @@ -117,27 +117,18 @@ void SceneExplorer(entt::entity& selected, Scene& scene ) void Viewport(Framebuffer& framebuffer) { unsigned int viewportWindowFlags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar ; - + ImGui::Begin("Viewport", false, viewportWindowFlags); - ImGui::Image((void*)(intptr_t)framebuffer.GetColourAttachment(), ImVec2{ (float)800,(float)600 }); + + + ImGui::Image((void*)(intptr_t)framebuffer.GetColourAttachment(), ImVec2{ (float)ImGui::GetWindowWidth(),(float)ImGui::GetWindowHeight()}); - ImGuizmo::SetDrawlist(); - ImGuizmo::SetRect(ImGui::GetWindowPos().x, ImGui::GetWindowPos().y, ImGui::GetWindowWidth(), ImGui::GetWindowHeight()); - ImGuizmo::Enable(true); - auto cam = glm::mat4(1.0f); - auto eye = glm::vec3(0.0f); - auto center = glm::vec3(0.0f); - auto up = glm::vec3(0.0f, 1.0f, 0.0f); - auto view = glm::lookAt(eye, center, up); - - glm::mat4 projection = glm::perspective(glm::radians(90.0f), (800.0f / 600.0f), 0.001f, 100.0f); - auto transformMatrix = glm::mat4(1.0f); - - ImGuizmo::Manipulate(glm::value_ptr(view), glm::value_ptr(projection), ImGuizmo::TRANSLATE, ImGuizmo::WORLD, glm::value_ptr(transformMatrix)); + //ImGuizmo::SetDrawlist(); + //ImGuizmo::SetRect(ImGui::GetWindowPos().x, ImGui::GetWindowPos().y, ImGui::GetWindowWidth(), ImGui::GetWindowHeight()); + //ImGuizmo::Enable(true); + //ImGuizmo::Manipulate(glm::value_ptr(view), glm::value_ptr(projection), ImGuizmo::TRANSLATE, ImGuizmo::WORLD, glm::value_ptr(trans)); - //ImGuizmo::Manipulate(glm::value_ptr(static_cam), glm::value_ptr(static_projection), ImGuizmo::TRANSLATE, ImGuizmo::WORLD, glm::value_ptr(trans)); - ImGuizmo::ViewManipulate(glm::value_ptr(cam), 8.0f, ImVec2{ 0.0f,0.0f }, ImVec2{ 128.0f,128.0f }, 0x10101010); ImGui::End(); } @@ -147,7 +138,7 @@ void GamePort(Framebuffer& framebuffer) unsigned int viewportWindowFlags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar; ImGui::Begin("Game", false, viewportWindowFlags); - ImGui::Image((void*)(intptr_t)framebuffer.GetColourAttachment(), ImVec2{ (float)800, (float)600 }); + ImGui::Image((void*)(intptr_t)framebuffer.GetColourAttachment(), { ImGui::GetWindowWidth(), ImGui::GetWindowHeight() }); ImGui::End(); diff --git a/Editor/src/app.cpp b/Editor/src/app.cpp index 34d48b4..d4cdaf6 100644 --- a/Editor/src/app.cpp +++ b/Editor/src/app.cpp @@ -36,7 +36,6 @@ public: double previous = glfwGetTime(); double lag = 0.0; - AssetManager::Init(); renderer->Prepare(activeRuntime.MainScene); while (!mainWindow.WindowShouldClose()) diff --git a/YoggieEngine/src/Graphics/Memory/FrameBuffer.cpp b/YoggieEngine/src/Graphics/Memory/FrameBuffer.cpp index c72cf63..df83a90 100644 --- a/YoggieEngine/src/Graphics/Memory/FrameBuffer.cpp +++ b/YoggieEngine/src/Graphics/Memory/FrameBuffer.cpp @@ -2,7 +2,7 @@ #include "Framebuffer.h" namespace YoggieEngine { - Framebuffer::Framebuffer() + Framebuffer::Framebuffer(int width, int height) { glGenFramebuffers(1, &Id); glBindFramebuffer(GL_FRAMEBUFFER, Id); @@ -11,7 +11,7 @@ namespace YoggieEngine { glGenTextures(1, &ColourAttachment); glBindTexture(GL_TEXTURE_2D, ColourAttachment); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 800, 600, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); @@ -26,7 +26,7 @@ namespace YoggieEngine { glGenTextures(1, &DepthAttachment); glBindTexture(GL_TEXTURE_2D, DepthAttachment); - glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, 800, 600, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, NULL); + glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, width, height, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, NULL); glBindTexture(GL_TEXTURE_2D, 0); diff --git a/YoggieEngine/src/Graphics/Memory/Framebuffer.h b/YoggieEngine/src/Graphics/Memory/Framebuffer.h index fd58381..ed1623e 100644 --- a/YoggieEngine/src/Graphics/Memory/Framebuffer.h +++ b/YoggieEngine/src/Graphics/Memory/Framebuffer.h @@ -3,7 +3,7 @@ namespace YoggieEngine { class Framebuffer { public: - Framebuffer(); + Framebuffer(int width,int height); ~Framebuffer(); GLuint GetId() { return Id; } diff --git a/YoggieEngine/src/Scene/Components.h b/YoggieEngine/src/Scene/Components.h index 37bbca5..6ee6813 100644 --- a/YoggieEngine/src/Scene/Components.h +++ b/YoggieEngine/src/Scene/Components.h @@ -8,6 +8,20 @@ namespace YoggieEngine { glm::vec3 Position = glm::vec3(0.0f); glm::vec3 Rotation = glm::vec3(0.0f); glm::vec3 Scale = glm::vec3(1.0f); + + + glm::mat4 GetTransformMatrix() { + glm::mat4 result = glm::mat4(1.0f); + glm::mat4 rotate = glm::rotate(glm::mat4(1.0f), Rotation.x, glm::vec3(1.f, 0.f, 0.f)); + rotate *= glm::rotate(glm::mat4(1.0f), Rotation.y, glm::vec3(0.f, 1.f, 0.f)); + rotate *= glm::rotate(glm::mat4(1.0f), Rotation.z, glm::vec3(0.f, 0.f, 1.f)); + + + result = rotate * glm::scale(glm::mat4(1.0f), Scale) * glm::translate(glm::mat4(1.0f), Position) ; + + return result; + } + }; struct LightComponent {