Skip to content

Commit 7486412

Browse files
authored
Merge pull request #3 from migon25/Structure_Remake
Structure remake
2 parents e4f2ef2 + d153995 commit 7486412

23 files changed

Lines changed: 282 additions & 47 deletions

EclipseEngine/EclipseEditor/App.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ App::App(int argc, char* args[])
88
core = new Core();
99
panelHandler = new PanelHandler(this);
1010
editorCamera = new Camera(core->window->GetWidth(), core->window->GetHeight(), glm::vec3(38.0f, 20.0f, -37.0f));
11-
editorRenderer = new EditorRenderer();
11+
editorRenderer = new EditorRenderer(this);
1212

1313
AddModule(editorRenderer, true);
1414
AddModule(panelHandler, true);

EclipseEngine/EclipseEditor/EclipseEditor.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
<ClCompile Include="InspectorPanel.cpp" />
102102
<ClCompile Include="main.cpp" />
103103
<ClCompile Include="MenuPanel.cpp" />
104+
<ClCompile Include="NodeEditorPanel.cpp" />
104105
<ClCompile Include="PanelHandler.cpp" />
105106
<ClCompile Include="ResourceImporter.cpp" />
106107
<ClCompile Include="SettingsPanel.cpp" />
@@ -125,6 +126,7 @@
125126
<ClInclude Include="HierarchyPanel.h" />
126127
<ClInclude Include="MenuPanel.h" />
127128
<ClInclude Include="Module.h" />
129+
<ClInclude Include="NodeEditorPanel.h" />
128130
<ClInclude Include="Panel.h" />
129131
<ClInclude Include="PanelHandler.h" />
130132
<ClInclude Include="ResourceImporter.h" />

EclipseEngine/EclipseEditor/EclipseEditor.vcxproj.filters

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@
6969
<ClCompile Include="ResourceImporter.cpp">
7070
<Filter>Source Files</Filter>
7171
</ClCompile>
72+
<ClCompile Include="NodeEditorPanel.cpp">
73+
<Filter>Source Files</Filter>
74+
</ClCompile>
7275
</ItemGroup>
7376
<ItemGroup>
7477
<ClInclude Include="Panel.h">
@@ -125,6 +128,9 @@
125128
<ClInclude Include="ResourceImporter.h">
126129
<Filter>Header Files</Filter>
127130
</ClInclude>
131+
<ClInclude Include="NodeEditorPanel.h">
132+
<Filter>Header Files</Filter>
133+
</ClInclude>
128134
</ItemGroup>
129135
<ItemGroup>
130136
<None Include="Shaders\outline.frag">

EclipseEngine/EclipseEditor/EditorRenderer.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@
1111

1212
#include "Grid.h"
1313
#include "Module.h"
14+
#include "App.h"
1415

1516
class EditorRenderer : public Module
1617
{
1718
public:
18-
EditorRenderer();
19+
EditorRenderer(App* application);
1920
~EditorRenderer();
2021

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

3537
Grid* grid = nullptr;
@@ -40,8 +42,10 @@ class EditorRenderer : public Module
4042
Shader* normalShader = nullptr;
4143
Shader* outliningShader = nullptr;
4244
Shader* aabbShader = nullptr;
45+
Shader* frustumShader = nullptr;
4346

4447
Shader* optionShader = nullptr;
48+
App* app;
4549
};
4650

4751
#endif // !EDITOR_RENDERER_H

EclipseEngine/EclipseEditor/HierarchyPanel.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@ void HierarchyPanel::Render()
1919
{
2020
if (!IsVisible()) return;
2121

22+
ImGui::PushStyleColor(ImGuiCol_WindowBg, ImVec4(0.1f, 0.1f, 0.1f, 1.0f));
23+
2224
ImGui::Begin(GetName().c_str(), &m_Visible);
2325

26+
ImGui::PopStyleColor();
27+
2428
if (core->scene != nullptr)
2529
{
2630
m_RootObjects = core->scene->GetObjects();

EclipseEngine/EclipseEditor/HierarchyPanel.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,4 @@ class HierarchyPanel : public Panel
3030
std::list<std::shared_ptr<GameObject>> m_RootObjects;
3131
std::shared_ptr<GameObject> m_SelectedObject = nullptr;
3232
};
33-
3433
#endif // HIERARCHY_PANEL_H

EclipseEngine/EclipseEditor/InspectorPanel.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,7 @@ void InspectorPanel::Render()
133133
{
134134
//m_SelectedObject->GetComponent<Camera>()->UpdateProjectionMatrix();
135135
}
136-
if (ImGui::SliderFloat("Near Plane", &m_SelectedObject->GetComponent<Camera>()->nearPlane, 0.1f, 100.0f));
137-
if (ImGui::SliderFloat("Far Plane", &m_SelectedObject->GetComponent<Camera>()->farPlane, 0.1f, 100.0f));
136+
RenderCameraSettings(m_SelectedObject->GetComponent<Camera>());
138137
}
139138
ImGui::Separator();
140139
if (ImGui::Button("Delete Object")) {
@@ -158,3 +157,20 @@ void InspectorPanel::Render()
158157
}
159158

160159
}
160+
161+
void InspectorPanel::RenderCameraSettings(Camera* camera)
162+
{
163+
ImGui::Text("Camera Settings");
164+
165+
float nearPlane = camera->nearPlane;
166+
if (ImGui::SliderFloat("Near Plane", &nearPlane, 0.01f, 10.0f))
167+
{
168+
camera->SetNearPlane(nearPlane);
169+
}
170+
171+
float farPlane = camera->farPlane;
172+
if (ImGui::SliderFloat("Far Plane", &farPlane, 10.0f, 1000.0f))
173+
{
174+
camera->SetFarPlane(farPlane);
175+
}
176+
}

EclipseEngine/EclipseEditor/InspectorPanel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class InspectorPanel : public Panel
1212
void Render() override;
1313

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

1617
private:
1718
std::shared_ptr<GameObject> m_SelectedObject = nullptr;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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}}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#include "NodeEditorPanel.h"
2+
#include <imgui.h>
3+
4+
NodeEditorPanel::NodeEditorPanel(const std::string& name, bool isVisible)
5+
: Panel(name), m_EditorContext(nullptr)
6+
{
7+
SetVisible(isVisible);
8+
m_EditorContext = ed::CreateEditor(); // Create the node editor context
9+
ed::Config config;
10+
config.SettingsFile = nullptr; // Prevent saving settings
11+
m_EditorContext = ed::CreateEditor(&config);
12+
ed::SetCurrentEditor(m_EditorContext);
13+
14+
// Set background color
15+
ed::Style& style = ed::GetStyle();
16+
style.Colors[ed::StyleColor_Bg] = ImColor(20, 20, 20, 255); // Dark Gray
17+
style.Colors[ed::StyleColor_Grid] = ImColor(30, 30, 30, 255); // Grid color
18+
style.Colors[ed::StyleColor_NodeBg] = ImColor(40, 40, 40, 255); // Node bg
19+
style.Colors[ed::StyleColor_NodeBorder] = ImColor(80, 80, 80, 255); // Node border
20+
style.Colors[ed::StyleColor_HovNodeBorder] = ImColor(155, 194, 130, 255); // Hovered node border
21+
}
22+
23+
NodeEditorPanel::~NodeEditorPanel()
24+
{
25+
ed::DestroyEditor(m_EditorContext); // Cleanup the node editor
26+
}
27+
28+
void NodeEditorPanel::Render()
29+
{
30+
if (IsVisible())
31+
{
32+
ImGui::Begin(GetName().c_str(), &m_Visible);
33+
34+
ImGui::Text(GetName().c_str()); // Debug
35+
36+
ed::SetCurrentEditor(m_EditorContext);
37+
ed::Begin("Node Editor");
38+
39+
// Example Node
40+
ed::BeginNode(1);
41+
ImGui::Text("Node 1");
42+
43+
ed::BeginPin(2, ed::PinKind::Input);
44+
ImGui::Text("-> Input");
45+
ed::EndPin();
46+
47+
ed::BeginPin(3, ed::PinKind::Output);
48+
ImGui::Text("Output ->");
49+
ed::EndPin();
50+
51+
ed::EndNode();
52+
//ed::SetNodePosition(1, ImVec2(100, 100)); // Ensure visible position
53+
54+
// Example Node
55+
ed::BeginNode(4);
56+
ImGui::Text("Node 2");
57+
58+
ed::BeginPin(5, ed::PinKind::Input);
59+
ImGui::Text("-> Input");
60+
ed::EndPin();
61+
62+
ed::BeginPin(6, ed::PinKind::Output);
63+
ImGui::Text("Output ->");
64+
ed::EndPin();
65+
66+
ed::EndNode();
67+
68+
ed::End();
69+
ed::SetCurrentEditor(nullptr);
70+
71+
ImGui::End();
72+
}
73+
}

0 commit comments

Comments
 (0)