Added new ComponentWidget and ViewWidget
A Render3DComponent can now be edited, A game view is available in the editor for game runtime rendering
This commit is contained in:
		| @ -1,6 +1,7 @@ | ||||
| #pragma once | ||||
| struct EditorContext { | ||||
|     std::shared_ptr<Project> CurrentProject; | ||||
|  | ||||
|     Scene MainScene; | ||||
|  | ||||
|     EditorContext() = default; | ||||
|  | ||||
| @ -5,10 +5,10 @@ | ||||
| #include "../../YoggieEngine/src/Scene/Entity.h" | ||||
| #include "Project.h" | ||||
|  | ||||
| class SceneRuntime : public  ApplicationRuntime { | ||||
| class EditorRuntime : public  ApplicationRuntime { | ||||
|  | ||||
| public: | ||||
|     SceneRuntime() = default; | ||||
|     EditorRuntime() = default; | ||||
| 	void Start() override   | ||||
| 	{ | ||||
|         CurrentProject = std::make_shared<Project>("Random"); | ||||
|  | ||||
| @ -42,8 +42,6 @@ void Inspector(entt::entity ent , Scene& scene) { | ||||
|             ImGui::EndPopup(); | ||||
|         } | ||||
|  | ||||
|  | ||||
|  | ||||
|         ImGui::NewLine(); | ||||
|          | ||||
|         auto component = entity.GetComponent<IdentifierComponent>(); | ||||
| @ -62,6 +60,13 @@ void Inspector(entt::entity ent , Scene& scene) { | ||||
|                  | ||||
|         } | ||||
|  | ||||
|         if (entity.HasComponent<Render3DComponent>()) { | ||||
|             auto& render3d = entity.GetComponent<Render3DComponent>(); | ||||
|             if (ImGui::CollapsingHeader("Render3D", ImGuiTreeNodeFlags_DefaultOpen)) { | ||||
|                 ImGui::ColorEdit3("Colour", glm::value_ptr(render3d.color)); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         if (entity.HasComponent<LightComponent>()) { | ||||
|             auto& light = entity.GetComponent<LightComponent>(); | ||||
|             if (ImGui::CollapsingHeader("Light", ImGuiTreeNodeFlags_DefaultOpen)) { | ||||
| @ -110,13 +115,8 @@ void SceneExplorer(entt::entity& selected, Scene& scene ) | ||||
|  | ||||
| void Viewport(Framebuffer& framebuffer) { | ||||
|  | ||||
|     unsigned int viewportWindowFlags = ImGuiWindowFlags_NoTitleBar | ||||
|         | ImGuiWindowFlags_NoDecoration | ||||
|         | ImGuiWindowFlags_NoScrollbar | ||||
|         | ImGuiWindowFlags_NoMove | ||||
|         | ImGuiWindowFlags_NoCollapse; | ||||
|     unsigned int viewportWindowFlags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar ; | ||||
|  | ||||
|     ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2{ 0,0 }); | ||||
|     ImGui::Begin("Viewport", false, viewportWindowFlags); | ||||
|     ImGui::Image((void*)(intptr_t)framebuffer.GetColourAttachment(), ImVec2{ (float)800,(float)600 }); | ||||
|  | ||||
| @ -138,7 +138,18 @@ void Viewport(Framebuffer& framebuffer) { | ||||
|     //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(); | ||||
|     ImGui::PopStyleVar(); | ||||
|  | ||||
| } | ||||
|  | ||||
| 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::End(); | ||||
|  | ||||
| } | ||||
|  | ||||
|  | ||||
| @ -19,6 +19,8 @@ void SceneExplorer(entt::entity& selected, Scene& scene); | ||||
|  | ||||
| void Viewport(Framebuffer& framebuffer); | ||||
|  | ||||
| void GamePort(Framebuffer& framebuffer); | ||||
|  | ||||
| void Settings(); | ||||
|  | ||||
| void Console(); | ||||
|  | ||||
| @ -1,12 +1,13 @@ | ||||
| #include <glm/gtc/type_ptr.hpp> | ||||
| #include <glm/gtc/matrix_transform.hpp> | ||||
| #include <imgui.h> | ||||
| #include <backends/imgui_impl_opengl3.h> | ||||
| #include <backends/imgui_impl_glfw.h> | ||||
| #include <imgui_internal.h> | ||||
| #include <ImGuizmo.h> | ||||
|  | ||||
| #include <nfd.h> | ||||
|  | ||||
| #include "../../libs/guizmo/ImGuizmo.h" | ||||
| #include <glm/glm.hpp> | ||||
| #include <glm/gtc/type_ptr.hpp> | ||||
| #include <glm/gtc/matrix_transform.hpp> | ||||
|  | ||||
| #include "UI/Widgets.h" | ||||
| #include "Project.h" | ||||
| @ -230,6 +231,7 @@ public: | ||||
|  | ||||
|         //ShowStats(); | ||||
|         Viewport(*activeRuntime.framebuffer); | ||||
|         GamePort(*activeRuntime.framebuffer); | ||||
|         SceneExplorer(activeRuntime.Selected, activeRuntime.MainScene); | ||||
|         Inspector(activeRuntime.Selected, activeRuntime.MainScene); | ||||
|  | ||||
| @ -245,7 +247,7 @@ public: | ||||
|  | ||||
| private: | ||||
|     EditorContext context; | ||||
|     SceneRuntime activeRuntime ; | ||||
|     EditorRuntime activeRuntime ; | ||||
|     char* path = nullptr; | ||||
|     char* savePath = nullptr; | ||||
|     char* scenePath = nullptr; | ||||
|  | ||||
		Reference in New Issue
	
	Block a user