Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion EclipseEngine/EclipseEditor/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ App::App(int argc, char* args[])
core = new Core();
panelHandler = new PanelHandler(this);
editorCamera = new Camera(core->window->GetWidth(), core->window->GetHeight(), glm::vec3(38.0f, 20.0f, -37.0f));
editorRenderer = new EditorRenderer();
editorRenderer = new EditorRenderer(this);

AddModule(editorRenderer, true);
AddModule(panelHandler, true);
Expand Down
2 changes: 2 additions & 0 deletions EclipseEngine/EclipseEditor/EclipseEditor.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
<ClCompile Include="InspectorPanel.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="MenuPanel.cpp" />
<ClCompile Include="NodeEditorPanel.cpp" />
<ClCompile Include="PanelHandler.cpp" />
<ClCompile Include="ResourceImporter.cpp" />
<ClCompile Include="SettingsPanel.cpp" />
Expand All @@ -125,6 +126,7 @@
<ClInclude Include="HierarchyPanel.h" />
<ClInclude Include="MenuPanel.h" />
<ClInclude Include="Module.h" />
<ClInclude Include="NodeEditorPanel.h" />
<ClInclude Include="Panel.h" />
<ClInclude Include="PanelHandler.h" />
<ClInclude Include="ResourceImporter.h" />
Expand Down
6 changes: 6 additions & 0 deletions EclipseEngine/EclipseEditor/EclipseEditor.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@
<ClCompile Include="ResourceImporter.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="NodeEditorPanel.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Panel.h">
Expand Down Expand Up @@ -125,6 +128,9 @@
<ClInclude Include="ResourceImporter.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="NodeEditorPanel.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="Shaders\outline.frag">
Expand Down
6 changes: 5 additions & 1 deletion EclipseEngine/EclipseEditor/EditorRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@

#include "Grid.h"
#include "Module.h"
#include "App.h"

class EditorRenderer : public Module
{
public:
EditorRenderer();
EditorRenderer(App* application);
~EditorRenderer();

bool Initialize() override;
Expand All @@ -30,6 +31,7 @@ class EditorRenderer : public Module
void RenderGrid(Grid* grid, Camera* editorCamera);
void RenderGuizmo();
void RenderAABB(AABB aabb, Shader& shader);
void DrawFrustum(const std::array<glm::vec3, 8>& frustumVertices, Shader& shader, const glm::mat4& view, const glm::mat4& projection);
//void RenderLight(Light* light); // no lights for now

Grid* grid = nullptr;
Expand All @@ -40,8 +42,10 @@ class EditorRenderer : public Module
Shader* normalShader = nullptr;
Shader* outliningShader = nullptr;
Shader* aabbShader = nullptr;
Shader* frustumShader = nullptr;

Shader* optionShader = nullptr;
App* app;
};

#endif // !EDITOR_RENDERER_H
4 changes: 4 additions & 0 deletions EclipseEngine/EclipseEditor/HierarchyPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ void HierarchyPanel::Render()
{
if (!IsVisible()) return;

ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0.1f, 0.1f, 0.1f, 1.0f));

ImGui::Begin(GetName().c_str(), &m_Visible);

ImGui::PopStyleColor();

if (core->scene != nullptr)
{
m_RootObjects = core->scene->GetObjects();
Expand Down
1 change: 0 additions & 1 deletion EclipseEngine/EclipseEditor/HierarchyPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,4 @@ class HierarchyPanel : public Panel
std::list<std::shared_ptr<GameObject>> m_RootObjects;
std::shared_ptr<GameObject> m_SelectedObject = nullptr;
};

#endif // HIERARCHY_PANEL_H
20 changes: 18 additions & 2 deletions EclipseEngine/EclipseEditor/InspectorPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ void InspectorPanel::Render()
{
//m_SelectedObject->GetComponent<Camera>()->UpdateProjectionMatrix();
}
if (ImGui::SliderFloat("Near Plane", &m_SelectedObject->GetComponent<Camera>()->nearPlane, 0.1f, 100.0f));
if (ImGui::SliderFloat("Far Plane", &m_SelectedObject->GetComponent<Camera>()->farPlane, 0.1f, 100.0f));
RenderCameraSettings(m_SelectedObject->GetComponent<Camera>());
}
ImGui::Separator();
if (ImGui::Button("Delete Object")) {
Expand All @@ -158,3 +157,20 @@ void InspectorPanel::Render()
}

}

void InspectorPanel::RenderCameraSettings(Camera* camera)
{
ImGui::Text("Camera Settings");

float nearPlane = camera->nearPlane;
if (ImGui::SliderFloat("Near Plane", &nearPlane, 0.01f, 10.0f))
{
camera->SetNearPlane(nearPlane);
}

float farPlane = camera->farPlane;
if (ImGui::SliderFloat("Far Plane", &farPlane, 10.0f, 1000.0f))
{
camera->SetFarPlane(farPlane);
}
}
1 change: 1 addition & 0 deletions EclipseEngine/EclipseEditor/InspectorPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class InspectorPanel : public Panel
void Render() override;

void SetSelectedObject(const std::shared_ptr<GameObject>& selectedObject) { m_SelectedObject = selectedObject; }
void RenderCameraSettings(Camera* camera);

private:
std::shared_ptr<GameObject> m_SelectedObject = nullptr;
Expand Down
1 change: 1 addition & 0 deletions EclipseEngine/EclipseEditor/NodeEditor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"nodes":{"node:1":{"location":{"x":100,"y":100}}},"selection":null,"view":{"scroll":{"x":-303.387115478515625,"y":202.416122436523438},"visible_rect":{"max":{"x":433.128936767578125,"y":176.161956787109375},"min":{"x":-147.877365112304688,"y":98.6619491577148438}},"zoom":2.05161285400390625}}
73 changes: 73 additions & 0 deletions EclipseEngine/EclipseEditor/NodeEditorPanel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#include "NodeEditorPanel.h"
#include <imgui.h>

NodeEditorPanel::NodeEditorPanel(const std::string& name, bool isVisible)
: Panel(name), m_EditorContext(nullptr)
{
SetVisible(isVisible);
m_EditorContext = ed::CreateEditor(); // Create the node editor context
ed::Config config;
config.SettingsFile = nullptr; // Prevent saving settings
m_EditorContext = ed::CreateEditor(&config);
ed::SetCurrentEditor(m_EditorContext);

// Set background color
ed::Style& style = ed::GetStyle();
style.Colors[ed::StyleColor_Bg] = ImColor(20, 20, 20, 255); // Dark Gray
style.Colors[ed::StyleColor_Grid] = ImColor(30, 30, 30, 255); // Grid color
style.Colors[ed::StyleColor_NodeBg] = ImColor(40, 40, 40, 255); // Node bg
style.Colors[ed::StyleColor_NodeBorder] = ImColor(80, 80, 80, 255); // Node border
style.Colors[ed::StyleColor_HovNodeBorder] = ImColor(155, 194, 130, 255); // Hovered node border
}

NodeEditorPanel::~NodeEditorPanel()
{
ed::DestroyEditor(m_EditorContext); // Cleanup the node editor
}

void NodeEditorPanel::Render()
{
if (IsVisible())
{
ImGui::Begin(GetName().c_str(), &m_Visible);

ImGui::Text(GetName().c_str()); // Debug

ed::SetCurrentEditor(m_EditorContext);
ed::Begin("Node Editor");

// Example Node
ed::BeginNode(1);
ImGui::Text("Node 1");

ed::BeginPin(2, ed::PinKind::Input);
ImGui::Text("-> Input");
ed::EndPin();

ed::BeginPin(3, ed::PinKind::Output);
ImGui::Text("Output ->");
ed::EndPin();

ed::EndNode();
//ed::SetNodePosition(1, ImVec2(100, 100)); // Ensure visible position

// Example Node
ed::BeginNode(4);
ImGui::Text("Node 2");

ed::BeginPin(5, ed::PinKind::Input);
ImGui::Text("-> Input");
ed::EndPin();

ed::BeginPin(6, ed::PinKind::Output);
ImGui::Text("Output ->");
ed::EndPin();

ed::EndNode();

ed::End();
ed::SetCurrentEditor(nullptr);

ImGui::End();
}
}
46 changes: 46 additions & 0 deletions EclipseEngine/EclipseEditor/NodeEditorPanel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#ifndef NODEEDITORPANEL_H
#define NODEEDITORPANEL_H

#include "Panel.h"
#include <string>
#include <vector>
#include "imgui-node-editor/imgui_node_editor.h"

namespace ed = ax::NodeEditor;

struct Node {
int Id;
int InputPinId;
int OutputPinId;
};

class NodeGraph {
public:
std::vector<Node> nodes;

void CreateExampleNode(int id) {
Node node;
node.Id = id;
node.InputPinId = id * 2; // Unique Input Pin ID
node.OutputPinId = id * 2 + 1; // Unique Output Pin ID

nodes.push_back(node);
}
};

class NodeEditorPanel : public Panel
{
public:
NodeEditorPanel(const std::string& name, bool isVisible = true);
~NodeEditorPanel();

void Render() override;

private:
ed::EditorContext* m_EditorContext;
NodeGraph m_NodeGraph;

void RenderNodes();
};

#endif // NODEEDITORPANEL_H
12 changes: 8 additions & 4 deletions EclipseEngine/EclipseEditor/PanelHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "AssetsPanel.h"
#include "InspectorPanel.h"
#include "ViewportPanel.h"
#include "NodeEditorPanel.h"
#include "GamePanel.h"

PanelHandler::PanelHandler(App* app) : app(app)
Expand Down Expand Up @@ -147,9 +148,9 @@ void PanelHandler::CustomStyle()
colors[ImGuiCol_Text] = ImVec4(1.0f, 1.0f, 1.0f, 1.0f);

// Backgrounds
colors[ImGuiCol_WindowBg] = ImVec4(0.1f, 0.1f, 0.1f, 1.0f); // Background color for main windows
colors[ImGuiCol_ChildBg] = ImVec4(0.1f, 0.1f, 0.1f, 1.0f); // Background color for child windows/panels
colors[ImGuiCol_PopupBg] = ImVec4(0.1f, 0.1f, 0.1f, 1.0f); // Background color for pop-up windows
colors[ImGuiCol_WindowBg] = ImVec4(0.15f, 0.15f, 0.15f, 1.0f); // Background color for main windows
colors[ImGuiCol_ChildBg] = ImVec4(0.15f, 0.15f, 0.15f, 1.0f); // Background color for child windows/panels
colors[ImGuiCol_PopupBg] = ImVec4(0.15f, 0.15f, 0.15f, 1.0f); // Background color for pop-up windows

// Headers
colors[ImGuiCol_Header] = ImVec4(0.3f, 0.3f, 0.3f, 1.0f); // Background color for headers (hovered or active)
Expand All @@ -158,7 +159,7 @@ void PanelHandler::CustomStyle()

// Borders and separators
colors[ImGuiCol_Border] = ImVec4(0.05f, 0.05f, 0.05f, 0.7f); // Border color
colors[ImGuiCol_BorderShadow] = ImVec4(1.0f, 0.0f, 0.0f, 1.0f) ; // Border shadow color
colors[ImGuiCol_BorderShadow] = ImVec4(0.0f, 0.0f, 0.0f, 0.0f) ; // Border shadow color

// Buttons
colors[ImGuiCol_Button] = ImVec4(0.4f, 0.4f, 0.4f, 1.0f); // Button color
Expand Down Expand Up @@ -238,13 +239,16 @@ void PanelHandler::InitializePanels()
AddPanel(std::make_shared<SettingsPanel>("Settings Panel", false));
AddPanel(std::make_shared<AssetsPanel>("Assets Panel", true));
AddPanel(std::make_shared<InspectorPanel>("Inspector Panel", true));
AddPanel(std::make_shared<NodeEditorPanel>("Node Editor Panel", true));
AddPanel(std::make_shared<GamePanel>("Game Panel", core->renderer->GetFramebuffer(), core->scene->GetActiveCamera(), true)); // this is the game viewport
AddPanel(std::make_shared<ViewportPanel>("Viewport Panel", app->editorRenderer->GetFramebuffer(), app->editorCamera, true)); // this is the editor viewport

// Set the inspector panel for the hierarchy panel
hierarchyPanel = static_cast<HierarchyPanel*>(GetPanel("Hierarchy Panel").get());
hierarchyPanel->SetInspectorPanel(static_cast<InspectorPanel*>(GetPanel("Inspector Panel").get()));
hierarchyPanel->SetViewportPanel(static_cast<ViewportPanel*>(GetPanel("Viewport Panel").get()));

viewportPanel = static_cast<ViewportPanel*>(GetPanel("Viewport Panel").get());
}

void PanelHandler::AddPanel(std::shared_ptr<Panel> panel) {
Expand Down
3 changes: 2 additions & 1 deletion EclipseEngine/EclipseEditor/PanelHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include <string>
#include <vector>
#include <memory> // For std::unique_ptr
#include <memory>

#include <imgui.h>
#include "imgui_impl_glfw.h"
Expand Down Expand Up @@ -40,6 +40,7 @@ class PanelHandler : public Module

std::shared_ptr<Panel> GetPanel(const std::string& name);
HierarchyPanel* hierarchyPanel;
ViewportPanel* viewportPanel;

private:
std::vector<std::shared_ptr<Panel>> m_Panels;
Expand Down
6 changes: 6 additions & 0 deletions EclipseEngine/EclipseEditor/Shaders/frustum.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#version 330 core
out vec4 FragColor;

void main() {
FragColor = vec4(1.0, 1.0, 1.0, 1.0); // Red color for frustum lines
}
9 changes: 9 additions & 0 deletions EclipseEngine/EclipseEditor/Shaders/frustum.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#version 330 core
layout(location = 0) in vec3 aPos;

uniform mat4 view;
uniform mat4 projection;

void main() {
gl_Position = projection * view * vec4(aPos, 1.0);
}
6 changes: 6 additions & 0 deletions EclipseEngine/EclipseEditor/frustum.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#version 330 core
out vec4 FragColor;

void main() {
FragColor = vec4(1.0, 1.0, 1.0, 1.0); // Red color for frustum lines
}
Loading
Loading