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:
parent
210d535c41
commit
9a9db279a5
@ -1,6 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
struct EditorContext {
|
struct EditorContext {
|
||||||
std::shared_ptr<Project> CurrentProject;
|
std::shared_ptr<Project> CurrentProject;
|
||||||
|
|
||||||
Scene MainScene;
|
Scene MainScene;
|
||||||
|
|
||||||
EditorContext() = default;
|
EditorContext() = default;
|
||||||
|
@ -5,10 +5,10 @@
|
|||||||
#include "../../YoggieEngine/src/Scene/Entity.h"
|
#include "../../YoggieEngine/src/Scene/Entity.h"
|
||||||
#include "Project.h"
|
#include "Project.h"
|
||||||
|
|
||||||
class SceneRuntime : public ApplicationRuntime {
|
class EditorRuntime : public ApplicationRuntime {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SceneRuntime() = default;
|
EditorRuntime() = default;
|
||||||
void Start() override
|
void Start() override
|
||||||
{
|
{
|
||||||
CurrentProject = std::make_shared<Project>("Random");
|
CurrentProject = std::make_shared<Project>("Random");
|
||||||
|
@ -42,8 +42,6 @@ void Inspector(entt::entity ent , Scene& scene) {
|
|||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ImGui::NewLine();
|
ImGui::NewLine();
|
||||||
|
|
||||||
auto component = entity.GetComponent<IdentifierComponent>();
|
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>()) {
|
if (entity.HasComponent<LightComponent>()) {
|
||||||
auto& light = entity.GetComponent<LightComponent>();
|
auto& light = entity.GetComponent<LightComponent>();
|
||||||
if (ImGui::CollapsingHeader("Light", ImGuiTreeNodeFlags_DefaultOpen)) {
|
if (ImGui::CollapsingHeader("Light", ImGuiTreeNodeFlags_DefaultOpen)) {
|
||||||
@ -110,13 +115,8 @@ void SceneExplorer(entt::entity& selected, Scene& scene )
|
|||||||
|
|
||||||
void Viewport(Framebuffer& framebuffer) {
|
void Viewport(Framebuffer& framebuffer) {
|
||||||
|
|
||||||
unsigned int viewportWindowFlags = ImGuiWindowFlags_NoTitleBar
|
unsigned int viewportWindowFlags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar ;
|
||||||
| ImGuiWindowFlags_NoDecoration
|
|
||||||
| ImGuiWindowFlags_NoScrollbar
|
|
||||||
| ImGuiWindowFlags_NoMove
|
|
||||||
| ImGuiWindowFlags_NoCollapse;
|
|
||||||
|
|
||||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2{ 0,0 });
|
|
||||||
ImGui::Begin("Viewport", false, viewportWindowFlags);
|
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)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::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);
|
ImGuizmo::ViewManipulate(glm::value_ptr(cam), 8.0f, ImVec2{ 0.0f,0.0f }, ImVec2{ 128.0f,128.0f }, 0x10101010);
|
||||||
ImGui::End();
|
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 Viewport(Framebuffer& framebuffer);
|
||||||
|
|
||||||
|
void GamePort(Framebuffer& framebuffer);
|
||||||
|
|
||||||
void Settings();
|
void Settings();
|
||||||
|
|
||||||
void Console();
|
void Console();
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
#include <glm/gtc/type_ptr.hpp>
|
|
||||||
#include <glm/gtc/matrix_transform.hpp>
|
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
#include <backends/imgui_impl_opengl3.h>
|
#include <backends/imgui_impl_opengl3.h>
|
||||||
#include <backends/imgui_impl_glfw.h>
|
#include <backends/imgui_impl_glfw.h>
|
||||||
#include <imgui_internal.h>
|
#include <ImGuizmo.h>
|
||||||
|
|
||||||
#include <nfd.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 "UI/Widgets.h"
|
||||||
#include "Project.h"
|
#include "Project.h"
|
||||||
@ -230,6 +231,7 @@ public:
|
|||||||
|
|
||||||
//ShowStats();
|
//ShowStats();
|
||||||
Viewport(*activeRuntime.framebuffer);
|
Viewport(*activeRuntime.framebuffer);
|
||||||
|
GamePort(*activeRuntime.framebuffer);
|
||||||
SceneExplorer(activeRuntime.Selected, activeRuntime.MainScene);
|
SceneExplorer(activeRuntime.Selected, activeRuntime.MainScene);
|
||||||
Inspector(activeRuntime.Selected, activeRuntime.MainScene);
|
Inspector(activeRuntime.Selected, activeRuntime.MainScene);
|
||||||
|
|
||||||
@ -245,7 +247,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
EditorContext context;
|
EditorContext context;
|
||||||
SceneRuntime activeRuntime ;
|
EditorRuntime activeRuntime ;
|
||||||
char* path = nullptr;
|
char* path = nullptr;
|
||||||
char* savePath = nullptr;
|
char* savePath = nullptr;
|
||||||
char* scenePath = nullptr;
|
char* scenePath = nullptr;
|
||||||
|
Loading…
Reference in New Issue
Block a user