diff --git a/EclipseEngine/EclipseEditor/App.cpp b/EclipseEngine/EclipseEditor/App.cpp index 227614be..98a4c74b 100644 --- a/EclipseEngine/EclipseEditor/App.cpp +++ b/EclipseEngine/EclipseEditor/App.cpp @@ -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); diff --git a/EclipseEngine/EclipseEditor/EclipseEditor.vcxproj b/EclipseEngine/EclipseEditor/EclipseEditor.vcxproj index 14702089..35f47c6b 100644 --- a/EclipseEngine/EclipseEditor/EclipseEditor.vcxproj +++ b/EclipseEngine/EclipseEditor/EclipseEditor.vcxproj @@ -101,6 +101,7 @@ + @@ -125,6 +126,7 @@ + diff --git a/EclipseEngine/EclipseEditor/EclipseEditor.vcxproj.filters b/EclipseEngine/EclipseEditor/EclipseEditor.vcxproj.filters index 681eff9d..6ba33ce2 100644 --- a/EclipseEngine/EclipseEditor/EclipseEditor.vcxproj.filters +++ b/EclipseEngine/EclipseEditor/EclipseEditor.vcxproj.filters @@ -69,6 +69,9 @@ Source Files + + Source Files + @@ -125,6 +128,9 @@ Header Files + + Header Files + diff --git a/EclipseEngine/EclipseEditor/EditorRenderer.h b/EclipseEngine/EclipseEditor/EditorRenderer.h index 39b65343..f4c3d2bb 100644 --- a/EclipseEngine/EclipseEditor/EditorRenderer.h +++ b/EclipseEngine/EclipseEditor/EditorRenderer.h @@ -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; @@ -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& frustumVertices, Shader& shader, const glm::mat4& view, const glm::mat4& projection); //void RenderLight(Light* light); // no lights for now Grid* grid = nullptr; @@ -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 diff --git a/EclipseEngine/EclipseEditor/HierarchyPanel.cpp b/EclipseEngine/EclipseEditor/HierarchyPanel.cpp index 7c2323b1..f02a57b2 100644 --- a/EclipseEngine/EclipseEditor/HierarchyPanel.cpp +++ b/EclipseEngine/EclipseEditor/HierarchyPanel.cpp @@ -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(); diff --git a/EclipseEngine/EclipseEditor/HierarchyPanel.h b/EclipseEngine/EclipseEditor/HierarchyPanel.h index 3000e628..3b94ae78 100644 --- a/EclipseEngine/EclipseEditor/HierarchyPanel.h +++ b/EclipseEngine/EclipseEditor/HierarchyPanel.h @@ -30,5 +30,4 @@ class HierarchyPanel : public Panel std::list> m_RootObjects; std::shared_ptr m_SelectedObject = nullptr; }; - #endif // HIERARCHY_PANEL_H \ No newline at end of file diff --git a/EclipseEngine/EclipseEditor/InspectorPanel.cpp b/EclipseEngine/EclipseEditor/InspectorPanel.cpp index ac05ffaf..46213743 100644 --- a/EclipseEngine/EclipseEditor/InspectorPanel.cpp +++ b/EclipseEngine/EclipseEditor/InspectorPanel.cpp @@ -133,8 +133,7 @@ void InspectorPanel::Render() { //m_SelectedObject->GetComponent()->UpdateProjectionMatrix(); } - if (ImGui::SliderFloat("Near Plane", &m_SelectedObject->GetComponent()->nearPlane, 0.1f, 100.0f)); - if (ImGui::SliderFloat("Far Plane", &m_SelectedObject->GetComponent()->farPlane, 0.1f, 100.0f)); + RenderCameraSettings(m_SelectedObject->GetComponent()); } ImGui::Separator(); if (ImGui::Button("Delete Object")) { @@ -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); + } +} \ No newline at end of file diff --git a/EclipseEngine/EclipseEditor/InspectorPanel.h b/EclipseEngine/EclipseEditor/InspectorPanel.h index 54062388..5dc2070a 100644 --- a/EclipseEngine/EclipseEditor/InspectorPanel.h +++ b/EclipseEngine/EclipseEditor/InspectorPanel.h @@ -12,6 +12,7 @@ class InspectorPanel : public Panel void Render() override; void SetSelectedObject(const std::shared_ptr& selectedObject) { m_SelectedObject = selectedObject; } + void RenderCameraSettings(Camera* camera); private: std::shared_ptr m_SelectedObject = nullptr; diff --git a/EclipseEngine/EclipseEditor/NodeEditor.json b/EclipseEngine/EclipseEditor/NodeEditor.json new file mode 100644 index 00000000..e179f9d5 --- /dev/null +++ b/EclipseEngine/EclipseEditor/NodeEditor.json @@ -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}} \ No newline at end of file diff --git a/EclipseEngine/EclipseEditor/NodeEditorPanel.cpp b/EclipseEngine/EclipseEditor/NodeEditorPanel.cpp new file mode 100644 index 00000000..ddedf1f3 --- /dev/null +++ b/EclipseEngine/EclipseEditor/NodeEditorPanel.cpp @@ -0,0 +1,73 @@ +#include "NodeEditorPanel.h" +#include + +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(); + } +} \ No newline at end of file diff --git a/EclipseEngine/EclipseEditor/NodeEditorPanel.h b/EclipseEngine/EclipseEditor/NodeEditorPanel.h new file mode 100644 index 00000000..6ea14cae --- /dev/null +++ b/EclipseEngine/EclipseEditor/NodeEditorPanel.h @@ -0,0 +1,46 @@ +#ifndef NODEEDITORPANEL_H +#define NODEEDITORPANEL_H + +#include "Panel.h" +#include +#include +#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 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 diff --git a/EclipseEngine/EclipseEditor/PanelHandler.cpp b/EclipseEngine/EclipseEditor/PanelHandler.cpp index 8607936b..1cc44ed3 100644 --- a/EclipseEngine/EclipseEditor/PanelHandler.cpp +++ b/EclipseEngine/EclipseEditor/PanelHandler.cpp @@ -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) @@ -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) @@ -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 @@ -238,6 +239,7 @@ void PanelHandler::InitializePanels() AddPanel(std::make_shared("Settings Panel", false)); AddPanel(std::make_shared("Assets Panel", true)); AddPanel(std::make_shared("Inspector Panel", true)); + AddPanel(std::make_shared("Node Editor Panel", true)); AddPanel(std::make_shared("Game Panel", core->renderer->GetFramebuffer(), core->scene->GetActiveCamera(), true)); // this is the game viewport AddPanel(std::make_shared("Viewport Panel", app->editorRenderer->GetFramebuffer(), app->editorCamera, true)); // this is the editor viewport @@ -245,6 +247,8 @@ void PanelHandler::InitializePanels() hierarchyPanel = static_cast(GetPanel("Hierarchy Panel").get()); hierarchyPanel->SetInspectorPanel(static_cast(GetPanel("Inspector Panel").get())); hierarchyPanel->SetViewportPanel(static_cast(GetPanel("Viewport Panel").get())); + + viewportPanel = static_cast(GetPanel("Viewport Panel").get()); } void PanelHandler::AddPanel(std::shared_ptr panel) { diff --git a/EclipseEngine/EclipseEditor/PanelHandler.h b/EclipseEngine/EclipseEditor/PanelHandler.h index ff29a9bf..906deae4 100644 --- a/EclipseEngine/EclipseEditor/PanelHandler.h +++ b/EclipseEngine/EclipseEditor/PanelHandler.h @@ -3,7 +3,7 @@ #include #include -#include // For std::unique_ptr +#include #include #include "imgui_impl_glfw.h" @@ -40,6 +40,7 @@ class PanelHandler : public Module std::shared_ptr GetPanel(const std::string& name); HierarchyPanel* hierarchyPanel; + ViewportPanel* viewportPanel; private: std::vector> m_Panels; diff --git a/EclipseEngine/EclipseEditor/Shaders/frustum.frag b/EclipseEngine/EclipseEditor/Shaders/frustum.frag new file mode 100644 index 00000000..65c24e07 --- /dev/null +++ b/EclipseEngine/EclipseEditor/Shaders/frustum.frag @@ -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 +} diff --git a/EclipseEngine/EclipseEditor/Shaders/frustum.vert b/EclipseEngine/EclipseEditor/Shaders/frustum.vert new file mode 100644 index 00000000..1bf52828 --- /dev/null +++ b/EclipseEngine/EclipseEditor/Shaders/frustum.vert @@ -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); +} \ No newline at end of file diff --git a/EclipseEngine/EclipseEditor/frustum.frag b/EclipseEngine/EclipseEditor/frustum.frag new file mode 100644 index 00000000..65c24e07 --- /dev/null +++ b/EclipseEngine/EclipseEditor/frustum.frag @@ -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 +} diff --git a/EclipseEngine/EclipseEditor/imgui.ini b/EclipseEngine/EclipseEditor/imgui.ini index 162203cc..6eceae30 100644 --- a/EclipseEngine/EclipseEditor/imgui.ini +++ b/EclipseEngine/EclipseEditor/imgui.ini @@ -9,62 +9,72 @@ Size=400,400 Collapsed=0 [Window][Console Panel] -Pos=859,584 -Size=636,255 +Pos=1200,674 +Size=295,165 Collapsed=0 -DockId=0x00000009,0 +DockId=0x0000000A,0 [Window][Hierarchy Panel] -Pos=5,29 -Size=204,553 +Pos=1200,29 +Size=295,182 Collapsed=0 -DockId=0x00000005,0 +DockId=0x00000003,0 [Window][Inspector Panel] -Pos=1198,29 -Size=297,553 +Pos=1200,213 +Size=295,459 Collapsed=0 -DockId=0x00000004,0 +DockId=0x00000009,0 [Window][Game] -ViewportPos=-1020,211 -ViewportId=0x83199EB2 -Size=896,457 +Pos=853,29 +Size=345,230 Collapsed=0 +DockId=0x0000000B,0 [Window][Viewport] -Pos=211,29 -Size=985,553 +Pos=5,29 +Size=846,590 Collapsed=0 -DockId=0x00000006,0 +DockId=0x0000000E,0 [Window][Assets Panel] -Pos=5,584 -Size=852,255 +Pos=5,621 +Size=1193,218 Collapsed=0 DockId=0x00000007,0 [Window][FPS Panel] -Pos=1688,757 -Size=227,255 +Pos=1258,788 +Size=360,224 Collapsed=0 -DockId=0x0000000A,0 +DockId=0x00000008,0 [Window][Delete Confirmation] Pos=568,254 Size=334,77 Collapsed=0 +[Window][Node Editor Panel] +Pos=853,261 +Size=345,358 +Collapsed=0 +DockId=0x0000000D,0 + [Docking][Data] -DockSpace ID=0x3FC20BEE Window=0x9A404470 Pos=169,216 Size=1490,810 Split=Y - DockNode ID=0x00000001 Parent=0x3FC20BEE SizeRef=1490,726 Split=X Selected=0x13926F0B - DockNode ID=0x00000003 Parent=0x00000001 SizeRef=1611,562 Split=X Selected=0x26816F31 - DockNode ID=0x00000005 Parent=0x00000003 SizeRef=204,726 Selected=0xE096E5AE - DockNode ID=0x00000006 Parent=0x00000003 SizeRef=1405,726 CentralNode=1 Selected=0x13926F0B - DockNode ID=0x00000004 Parent=0x00000001 SizeRef=297,562 Selected=0x0E9312B4 - DockNode ID=0x00000002 Parent=0x3FC20BEE SizeRef=1490,255 Split=X Selected=0xE86CE49B - DockNode ID=0x00000007 Parent=0x00000002 SizeRef=1093,246 Selected=0xE86CE49B - DockNode ID=0x00000008 Parent=0x00000002 SizeRef=815,246 Split=X Selected=0x9985E007 - DockNode ID=0x00000009 Parent=0x00000008 SizeRef=586,190 Selected=0x3A3DF33A - DockNode ID=0x0000000A Parent=0x00000008 SizeRef=227,190 Selected=0x9985E007 +DockSpace ID=0x3FC20BEE Window=0x9A404470 Pos=39,86 Size=1490,810 Split=X + DockNode ID=0x00000005 Parent=0x3FC20BEE SizeRef=1613,810 Split=Y + DockNode ID=0x00000001 Parent=0x00000005 SizeRef=1490,763 Split=X Selected=0x13926F0B + DockNode ID=0x0000000E Parent=0x00000001 SizeRef=846,229 Selected=0x13926F0B + DockNode ID=0x0000000F Parent=0x00000001 SizeRef=345,229 Split=Y Selected=0x26816F31 + DockNode ID=0x0000000B Parent=0x0000000F SizeRef=395,403 CentralNode=1 Selected=0x26816F31 + DockNode ID=0x0000000D Parent=0x0000000F SizeRef=395,358 Selected=0xF45274E3 + DockNode ID=0x00000002 Parent=0x00000005 SizeRef=1490,218 Split=X Selected=0xE86CE49B + DockNode ID=0x00000007 Parent=0x00000002 SizeRef=925,246 Selected=0xE86CE49B + DockNode ID=0x00000008 Parent=0x00000002 SizeRef=266,246 Selected=0x9985E007 + DockNode ID=0x00000006 Parent=0x3FC20BEE SizeRef=295,810 Split=Y Selected=0xE096E5AE + DockNode ID=0x00000003 Parent=0x00000006 SizeRef=204,221 Selected=0xE096E5AE + DockNode ID=0x00000004 Parent=0x00000006 SizeRef=204,760 Split=Y Selected=0x0E9312B4 + DockNode ID=0x00000009 Parent=0x00000004 SizeRef=299,558 Selected=0x0E9312B4 + DockNode ID=0x0000000A Parent=0x00000004 SizeRef=299,200 Selected=0x3A3DF33A diff --git a/EclipseEngine/EclipseEngine/Camera.cpp b/EclipseEngine/EclipseEngine/Camera.cpp index bec7a3ef..c461abbe 100644 --- a/EclipseEngine/EclipseEngine/Camera.cpp +++ b/EclipseEngine/EclipseEngine/Camera.cpp @@ -202,6 +202,19 @@ void Camera::Inputs(GLFWwindow* window) } } +void Camera::SetNearPlane(float nearPlane) +{ + this->nearPlane = nearPlane; + UpdateMatrix(nearPlane, farPlane); +} + +void Camera::SetFarPlane(float farPlane) +{ + this->farPlane = farPlane; + UpdateMatrix(nearPlane, farPlane); +} + + // Scroll callback function to adjust the zoom level void Camera::scroll_callback(GLFWwindow* window, double xoffset, double yoffset) { @@ -242,3 +255,26 @@ glm::vec3 Camera::GetRaycastHitPoint(GLFWwindow* window) // Return the intersection point return rayOrigin + rayWorld * t; } + +std::array Camera::GetFrustumVertices(float nearPlane, float farPlane) const { + glm::mat4 invVP = glm::inverse(projection * glm::lookAt(Position, Position + Orientation, Up)); + + std::array frustumVertices; + std::array frustumVertices4 = { + invVP * glm::vec4(-1, -1, -1, 1), + invVP * glm::vec4(1, -1, -1, 1), + invVP * glm::vec4(1, 1, -1, 1), + invVP * glm::vec4(-1, 1, -1, 1), + invVP * glm::vec4(-1, -1, 1, 1), + invVP * glm::vec4(1, -1, 1, 1), + invVP * glm::vec4(1, 1, 1, 1), + invVP * glm::vec4(-1, 1, 1, 1) + }; + + for (size_t i = 0; i < frustumVertices.size(); ++i) { + frustumVertices4[i] /= frustumVertices4[i].w; + frustumVertices[i] = glm::vec3(frustumVertices4[i]); + } + + return frustumVertices; +} diff --git a/EclipseEngine/EclipseEngine/Camera.h b/EclipseEngine/EclipseEngine/Camera.h index 98227b55..0504fda7 100644 --- a/EclipseEngine/EclipseEngine/Camera.h +++ b/EclipseEngine/EclipseEngine/Camera.h @@ -3,6 +3,9 @@ #define GLM_ENABLE_EXPERIMENTAL +#include +#include + #include #include #include @@ -24,7 +27,10 @@ class Camera : public Component void UpdateMatrix(float nearPlane, float farPlane); void Matrix(Shader& shader, const char* uniform); void Inputs(GLFWwindow* window); //C + glm::mat4 GetViewMatrix() const { return glm::lookAt(Position, Position + Orientation, Up); } glm::mat4 GetProjectionMatrix() { return projection; } + void SetNearPlane(float nearPlane); + void SetFarPlane(float farPlane); // Static scroll callback function static void scroll_callback(GLFWwindow* window, double xoffset, double yoffset); //C @@ -53,6 +59,8 @@ class Camera : public Component float FOVdeg = 45.0f; // Field of View, adjustable for zoom static float scrollOffset; //C + + std::array GetFrustumVertices(float nearPlane, float farPlane) const; }; #endif //CAMERA_H \ No newline at end of file diff --git a/EclipseEngine/EclipseEngine/Renderer.cpp b/EclipseEngine/EclipseEngine/Renderer.cpp index 8f8656e7..ca7f9020 100644 --- a/EclipseEngine/EclipseEngine/Renderer.cpp +++ b/EclipseEngine/EclipseEngine/Renderer.cpp @@ -23,7 +23,7 @@ void Renderer::BeginFrame() { glBindFramebuffer(GL_FRAMEBUFFER, fbo->GetFBO()); glViewport(0, 0, fbo->GetWidth(), fbo->GetHeight()); - glClearColor(0.1f, 0.1f, 0.1f, 1.0); + glClearColor(0.05f, 0.05f, 0.05f, 1.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } diff --git a/EclipseEngine/EclipseEngine/Scene.cpp b/EclipseEngine/EclipseEngine/Scene.cpp index f197e2f8..c3ae34b0 100644 --- a/EclipseEngine/EclipseEngine/Scene.cpp +++ b/EclipseEngine/EclipseEngine/Scene.cpp @@ -27,7 +27,7 @@ bool Scene::Update(double dt) { if (activeCamera) { - activeCamera->UpdateMatrix(0.1f, 100.0f); + activeCamera->UpdateMatrix(activeCamera->nearPlane, activeCamera->farPlane); } for (auto& obj : gameObjects) { @@ -38,10 +38,9 @@ bool Scene::Update(double dt) void Scene::Draw(Shader& shader) { - for (auto& obj : gameObjects) - { - glm::mat4 identity = obj->transform.GetMatrix(); - obj->Draw(shader, *activeCamera, identity); + skybox->Draw(*activeCamera); + for (auto& obj : gameObjects){ + obj->Draw(shader, *activeCamera, obj->transform.GetMatrix()); } } diff --git a/EclipseEngine/EclipseEngine/Shader.h b/EclipseEngine/EclipseEngine/Shader.h index bf37a39c..343bde9d 100644 --- a/EclipseEngine/EclipseEngine/Shader.h +++ b/EclipseEngine/EclipseEngine/Shader.h @@ -22,6 +22,9 @@ class Shader void SetMat4(const std::string& name, const glm::mat4& matrix) const { glUniformMatrix4fv(glGetUniformLocation(ID, name.c_str()), 1, GL_FALSE, glm::value_ptr(matrix)); } void SetFloat(const std::string& name, float value) { glUniform1f(glGetUniformLocation(ID, name.c_str()), value); } + void SetFloat4(const std::string& name, float v0, float v1, float v2, float v3) { glUniform4f(glGetUniformLocation(ID, name.c_str()), v0, v1, v2, v3); } + void SetInt(const std::string& name, int value) { glUniform1i(glGetUniformLocation(ID, name.c_str()), value); } + void SetVec3(const std::string& name, const glm::vec3& value) { glUniform3fv(glGetUniformLocation(ID, name.c_str()), 1, &value[0]); } GLuint ID; }; diff --git a/vcpkg.json b/vcpkg.json index 47ab80fd..1a4c0c71 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -14,6 +14,7 @@ ] }, "imguizmo", + "imgui-node-editor", "openssl", "nlohmann-json" ]