From 1af4547c97436fc44b1c68e1fa8660141f184347 Mon Sep 17 00:00:00 2001 From: Chewico Date: Wed, 4 Mar 2026 00:03:43 +0100 Subject: [PATCH] Changes --- .../DeerCore/Scripting/InternalAPI/Entity.cpp | 12 +++- .../DeerCore/Scripting/InternalAPI/Entity.h | 6 +- .../DeerCore/Scripting/InternalAPI/Math.cpp | 22 +++++++ .../src/DeerCore/Scripting/InternalAPI/Math.h | 2 + .../Scripting/Registry/EntityRegistry.cpp | 6 +- .../Scripting/Registry/MathRegistry.cpp | 2 + .../DeerRender/Scripting/ImGuiRegistry.cpp | 1 + .../Scripting/InternalAPI/ImGUI.cpp | 26 ++++---- .../DeerRender/Scripting/InternalAPI/ImGUI.h | 1 + DeerStudio/src/DeerStudio/DeerStudio.cpp | 2 + DeerStudio/src/DeerStudio/Fonts.cpp | 2 +- DeerStudio/src/DeerStudio/Style.cpp | 65 +++++++++++++++++++ .../AddComponent.as | 3 - .../CameraProperties.as | 0 .../MeshProperties.as | 50 +++++++++----- .../PropertiesPannel.as | 2 +- .../TransformRender.as | 6 +- .../ResourceExplorer/ResourceExplorer.as | 2 +- Editor/Scripts/TreeExplorer/Tree.as | 8 +-- Editor/Scripts/Viewport/Viewport.as | 46 ++++++++++--- imgui.ini | 60 +++++++++++------ q | 0 22 files changed, 248 insertions(+), 76 deletions(-) rename Editor/Scripts/{EntityManipulation => Properties}/AddComponent.as (93%) rename Editor/Scripts/{EntityManipulation => Properties}/CameraProperties.as (100%) rename Editor/Scripts/{EntityManipulation => Properties}/MeshProperties.as (74%) rename Editor/Scripts/{EntityManipulation => Properties}/PropertiesPannel.as (99%) rename Editor/Scripts/{EntityManipulation => Properties}/TransformRender.as (81%) create mode 100644 q diff --git a/Deer/src/DeerCore/Scripting/InternalAPI/Entity.cpp b/Deer/src/DeerCore/Scripting/InternalAPI/Entity.cpp index 5fd1e06..205c83d 100644 --- a/Deer/src/DeerCore/Scripting/InternalAPI/Entity.cpp +++ b/Deer/src/DeerCore/Scripting/InternalAPI/Entity.cpp @@ -231,7 +231,11 @@ namespace Deer { TransformComponent& transformComponent = getContextEntityComponent(handle); return transformComponent.scale; } - glm::vec3 Scripting::transform_getRotation(EntityHandle& handle) { + glm::quat Scripting::transform_getRotation(EntityHandle& handle) { + TransformComponent& transformComponent = getContextEntityComponent(handle); + return transformComponent.rotation; + } + glm::vec3 Scripting::transform_getEuler(EntityHandle& handle) { TransformComponent& transformComponent = getContextEntityComponent(handle); return transformComponent.getEulerAngles(); } @@ -244,7 +248,11 @@ namespace Deer { TransformComponent& transformComponent = getContextEntityComponent(handle); transformComponent.scale = scale; } - void Scripting::transform_setRotation(glm::vec3 rotation, EntityHandle& handle) { + void Scripting::transform_setRotation(glm::quat rotation, EntityHandle& handle) { + TransformComponent& transformComponent = getContextEntityComponent(handle); + transformComponent.rotation = rotation; + } + void Scripting::transform_setEuler(glm::vec3 rotation, EntityHandle& handle) { TransformComponent& transformComponent = getContextEntityComponent(handle); transformComponent.setEulerAngles(rotation); } diff --git a/Deer/src/DeerCore/Scripting/InternalAPI/Entity.h b/Deer/src/DeerCore/Scripting/InternalAPI/Entity.h index c8e514b..7850be1 100644 --- a/Deer/src/DeerCore/Scripting/InternalAPI/Entity.h +++ b/Deer/src/DeerCore/Scripting/InternalAPI/Entity.h @@ -54,10 +54,12 @@ namespace Deer { // SPECIFIC TRANSFORM SECTION glm::vec3 transform_getPosition(EntityHandle&); glm::vec3 transform_getScale(EntityHandle&); - glm::vec3 transform_getRotation(EntityHandle&); + glm::quat transform_getRotation(EntityHandle&); + glm::vec3 transform_getEuler(EntityHandle&); void transform_setPosition(glm::vec3, EntityHandle&); void transform_setScale(glm::vec3, EntityHandle&); - void transform_setRotation(glm::vec3, EntityHandle&); + void transform_setRotation(glm::quat, EntityHandle&); + void transform_setEuler(glm::vec3, EntityHandle&); void constructEntityStruct(void* memory); void destructEntityStruct(void* memory); diff --git a/Deer/src/DeerCore/Scripting/InternalAPI/Math.cpp b/Deer/src/DeerCore/Scripting/InternalAPI/Math.cpp index 777ab14..a6b7a90 100644 --- a/Deer/src/DeerCore/Scripting/InternalAPI/Math.cpp +++ b/Deer/src/DeerCore/Scripting/InternalAPI/Math.cpp @@ -19,6 +19,28 @@ namespace Deer { return glm::vec3(matrix[3][0], matrix[3][1], matrix[3][2]); } + glm::quat mat4_getRotation(glm::mat4& m) { + glm::vec3 scale = mat4_getScale(m); + + // Avoid division by zero + glm::mat3 rotationMatrix; + rotationMatrix[0] = glm::vec3(m[0]) / scale.x; + rotationMatrix[1] = glm::vec3(m[1]) / scale.y; + rotationMatrix[2] = glm::vec3(m[2]) / scale.z; + + return glm::quat_cast(rotationMatrix); + } + + glm::vec3 mat4_getScale(glm::mat4& m) { + glm::vec3 scale; + + scale.x = glm::length(glm::vec3(m[0])); + scale.y = glm::length(glm::vec3(m[1])); + scale.z = glm::length(glm::vec3(m[2])); + + return scale; + } + void vec3_constructor_params(float x, float y, float z, void* mem) { new (mem) glm::vec3(x, y, z); } diff --git a/Deer/src/DeerCore/Scripting/InternalAPI/Math.h b/Deer/src/DeerCore/Scripting/InternalAPI/Math.h index a9e5bc1..17528a6 100644 --- a/Deer/src/DeerCore/Scripting/InternalAPI/Math.h +++ b/Deer/src/DeerCore/Scripting/InternalAPI/Math.h @@ -13,6 +13,8 @@ namespace Deer { void mat4_constructor(void*); glm::mat4 mat4_getRelativeMatrix(glm::mat4&, glm::mat4&); glm::vec3 mat4_getPosition(glm::mat4&); + glm::quat mat4_getRotation(glm::mat4&); + glm::vec3 mat4_getScale(glm::mat4&); glm::vec3 vec3_add(glm::vec3&, glm::vec3&); glm::vec3 vec3_sub(const glm::vec3&, glm::vec3&); diff --git a/Deer/src/DeerCore/Scripting/Registry/EntityRegistry.cpp b/Deer/src/DeerCore/Scripting/Registry/EntityRegistry.cpp index 2c2ac17..2d043d8 100644 --- a/Deer/src/DeerCore/Scripting/Registry/EntityRegistry.cpp +++ b/Deer/src/DeerCore/Scripting/Registry/EntityRegistry.cpp @@ -45,10 +45,12 @@ namespace Deer { REGISTER_EXT_OBJECT_METHOD(scriptEngine, "TransformComponent", "vec3 get_position() const property", transform_getPosition); REGISTER_EXT_OBJECT_METHOD(scriptEngine, "TransformComponent", "vec3 get_scale() const property", transform_getScale); - REGISTER_EXT_OBJECT_METHOD(scriptEngine, "TransformComponent", "vec3 get_rotation() const property", transform_getRotation); + REGISTER_EXT_OBJECT_METHOD(scriptEngine, "TransformComponent", "quat get_rotation() const property", transform_getRotation); + REGISTER_EXT_OBJECT_METHOD(scriptEngine, "TransformComponent", "vec3 getEuler() const", transform_getEuler); REGISTER_EXT_OBJECT_METHOD(scriptEngine, "TransformComponent", "void set_position(const vec3) property", transform_setPosition); REGISTER_EXT_OBJECT_METHOD(scriptEngine, "TransformComponent", "void set_scale(const vec3) property", transform_setScale); - REGISTER_EXT_OBJECT_METHOD(scriptEngine, "TransformComponent", "void set_rotation(const vec3) property", transform_setRotation); + REGISTER_EXT_OBJECT_METHOD(scriptEngine, "TransformComponent", "void set_rotation(const quat) property", transform_setRotation); + REGISTER_EXT_OBJECT_METHOD(scriptEngine, "TransformComponent", "void setEuler(const vec3)", transform_setEuler); } void Scripting::registerEntityStructs() { diff --git a/Deer/src/DeerCore/Scripting/Registry/MathRegistry.cpp b/Deer/src/DeerCore/Scripting/Registry/MathRegistry.cpp index d08f946..e1d3679 100644 --- a/Deer/src/DeerCore/Scripting/Registry/MathRegistry.cpp +++ b/Deer/src/DeerCore/Scripting/Registry/MathRegistry.cpp @@ -63,6 +63,8 @@ namespace Deer { REGISTER_EXT_OBJECT_METHOD(scriptEngine, "mat4", "mat4 getRelativeMatrix(mat4&in) const", mat4_getRelativeMatrix); REGISTER_EXT_OBJECT_METHOD(scriptEngine, "mat4", "vec3 getPosition() const", mat4_getPosition); + REGISTER_EXT_OBJECT_METHOD(scriptEngine, "mat4", "quat getRotation() const", mat4_getRotation); + REGISTER_EXT_OBJECT_METHOD(scriptEngine, "mat4", "vec3 getScale() const", mat4_getScale); REGISTER_EXT_OBJECT_METHOD(scriptEngine, "Transform", "vec3 relative(vec3)", transform_relative); } diff --git a/Deer/src/DeerRender/Scripting/ImGuiRegistry.cpp b/Deer/src/DeerRender/Scripting/ImGuiRegistry.cpp index 1da6a2e..0a4c084 100644 --- a/Deer/src/DeerRender/Scripting/ImGuiRegistry.cpp +++ b/Deer/src/DeerRender/Scripting/ImGuiRegistry.cpp @@ -24,6 +24,7 @@ namespace Deer { REGISTER_GLOBAL_FUNC(scriptEngine, "bool button(const string& in text)", Scripting::button); REGISTER_GLOBAL_FUNC(scriptEngine, "bool buttonCenter(const string& in text)", Scripting::buttonCenter); REGISTER_GLOBAL_FUNC(scriptEngine, "bool buttonEnd(const string& in text)", Scripting::buttonEnd); + REGISTER_GLOBAL_FUNC(scriptEngine, "bool buttonExpanded(const string& in text)", Scripting::buttonExpanded); REGISTER_GLOBAL_FUNC(scriptEngine, "bool cartIconButton(const string& in label, Texture texture, int iconSize, int width)", Scripting::cartIconButton); REGISTER_GLOBAL_FUNC(scriptEngine, "bool cartIconButton(const string& in label, FrameBuffer frameBuffer, int iconSize, int width)", Scripting::cartIconButton_frameBuffer); diff --git a/Deer/src/DeerRender/Scripting/InternalAPI/ImGUI.cpp b/Deer/src/DeerRender/Scripting/InternalAPI/ImGUI.cpp index d74d60f..47cdd43 100644 --- a/Deer/src/DeerRender/Scripting/InternalAPI/ImGUI.cpp +++ b/Deer/src/DeerRender/Scripting/InternalAPI/ImGUI.cpp @@ -93,6 +93,16 @@ namespace Deer { return ImGui::Button(txt.c_str()); } + bool buttonExpanded(std::string& txt) { + float sizeX; + if (ImGui::GetColumnsCount() > 1) + sizeX = ImGui::GetColumnWidth(-1); + else + sizeX = ImGui::GetContentRegionAvail().x; + + return ImGui::Button(txt.c_str(), ImVec2(sizeX, 0)); + } + void setCursorElementRight(std::string& txt, bool has_padding) { float sizeX; if (ImGui::GetColumnsCount() > 1) @@ -312,10 +322,8 @@ namespace Deer { ImGuizmo::SetRect(window_pos.x, window_pos.y, window_size.x, window_size.y); glm::mat4 cameraProjection = camera.camera.getMatrix(); - cameraProjection[2][2] *= -1.0f; - cameraProjection[2][3] *= -1.0f; - glm::mat4 cameraView = glm::inverse(camera.transform.getMatrix()); + glm::mat4 cameraView = glm::inverse(glm::scale(camera.transform.getMatrix(), glm::vec3(1, 1, -1))); outMatrix = objMatrix; ImGuizmo::MODE mode = local ? ImGuizmo::MODE::LOCAL : ImGuizmo::MODE::WORLD; @@ -333,10 +341,7 @@ namespace Deer { ImGuizmo::SetRect(window_pos.x, window_pos.y, window_size.x, window_size.y); glm::mat4 cameraProjection = camera.camera.getMatrix(); - cameraProjection[2][2] *= -1.0f; - cameraProjection[2][3] *= -1.0f; - - glm::mat4 cameraView = glm::inverse(camera.transform.getMatrix()); + glm::mat4 cameraView = glm::inverse(glm::scale(camera.transform.getMatrix(), glm::vec3(1, 1, -1))); outMatrix = objMatrix; ImGuizmo::MODE mode = local ? ImGuizmo::MODE::LOCAL : ImGuizmo::MODE::WORLD; @@ -354,10 +359,7 @@ namespace Deer { ImGuizmo::SetRect(window_pos.x, window_pos.y, window_size.x, window_size.y); glm::mat4 cameraProjection = camera.camera.getMatrix(); - cameraProjection[2][2] *= -1.0f; - cameraProjection[2][3] *= -1.0f; - - glm::mat4 cameraView = glm::inverse(camera.transform.getMatrix()); + glm::mat4 cameraView = glm::inverse(glm::scale(camera.transform.getMatrix(), glm::vec3(1, 1, -1))); outMatrix = objMatrix; ImGuizmo::MODE mode = local ? ImGuizmo::MODE::LOCAL : ImGuizmo::MODE::WORLD; @@ -760,7 +762,7 @@ namespace Deer { } void drawCombo(std::string& name, std::string& selectedValue, asIScriptFunction* function) { - if (ImGui::BeginCombo(name.c_str(), selectedValue.c_str(), ImGuiComboFlags_WidthFitPreview)) { + if (ImGui::BeginCombo(name.c_str(), selectedValue.c_str())) { asIScriptContext* scriptContext = asGetActiveContext(); if (scriptContext->PushState() == asSUCCESS) { diff --git a/Deer/src/DeerRender/Scripting/InternalAPI/ImGUI.h b/Deer/src/DeerRender/Scripting/InternalAPI/ImGUI.h index 0f09959..875c40a 100644 --- a/Deer/src/DeerRender/Scripting/InternalAPI/ImGUI.h +++ b/Deer/src/DeerRender/Scripting/InternalAPI/ImGUI.h @@ -31,6 +31,7 @@ namespace Deer { bool button(std::string&); bool buttonCenter(std::string&); bool buttonEnd(std::string&); + bool buttonExpanded(std::string&); bool cartIconButton(const std::string& label, Resource icon, int iconSize, int width); bool cartIconButton_frameBuffer(const std::string& label, Resource frameBuffer, int iconSize, int width); diff --git a/DeerStudio/src/DeerStudio/DeerStudio.cpp b/DeerStudio/src/DeerStudio/DeerStudio.cpp index 43960bd..120a78d 100644 --- a/DeerStudio/src/DeerStudio/DeerStudio.cpp +++ b/DeerStudio/src/DeerStudio/DeerStudio.cpp @@ -111,6 +111,8 @@ namespace Deer { } ImGui::PopStyleVar(); + ImGui::ShowDemoWindow(); + if (world.getExecutionState() == Deer::WorldState::Executing) StudioPanel::render(); diff --git a/DeerStudio/src/DeerStudio/Fonts.cpp b/DeerStudio/src/DeerStudio/Fonts.cpp index 2bc0759..0e71c2d 100644 --- a/DeerStudio/src/DeerStudio/Fonts.cpp +++ b/DeerStudio/src/DeerStudio/Fonts.cpp @@ -15,7 +15,7 @@ namespace Deer { Path faNPath = "Editor/fonts/FontAwesome-Normal.otf"; ImFontConfig cnfg; // cnfg.SizePixels = 26 - normalText = io.Fonts->AddFontFromFileTTF(rfPath.generic_string().c_str(), 18); + normalText = io.Fonts->AddFontFromFileTTF(rfPath.generic_string().c_str(), 20); ImFontConfig config; config.MergeMode = true; diff --git a/DeerStudio/src/DeerStudio/Style.cpp b/DeerStudio/src/DeerStudio/Style.cpp index b5b7b8e..07ef8e2 100644 --- a/DeerStudio/src/DeerStudio/Style.cpp +++ b/DeerStudio/src/DeerStudio/Style.cpp @@ -1,5 +1,14 @@ #include "imgui.h" +struct ImVec3 { + float x, y, z; + ImVec3(float _x = 0.0f, float _y = 0.0f, float _z = 0.0f) { + x = _x; + y = _y; + z = _z; + } +}; + void SetupImGuiStyle() { // Rest style by AaronBeardless from ImThemes ImGuiStyle& style = ImGui::GetStyle(); @@ -58,4 +67,60 @@ void SetupImGuiStyle() { // --- Text --- c[ImGuiCol_Text] = ImVec4(0.88f, 0.88f, 0.88f, 1.00f); c[ImGuiCol_TextDisabled] = ImVec4(0.52f, 0.52f, 0.52f, 1.00f); + + /* + + ImGui::GetStyle().FrameRounding = 4.0f; + ImGui::GetStyle().GrabRounding = 4.0f; + + ImVec4* colors = ImGui::GetStyle().Colors; + colors[ImGuiCol_Text] = ImVec4(0.95f, 0.96f, 0.98f, 1.00f); + colors[ImGuiCol_TextDisabled] = ImVec4(0.36f, 0.42f, 0.47f, 1.00f); + colors[ImGuiCol_WindowBg] = ImVec4(0.11f, 0.15f, 0.17f, 1.00f); + colors[ImGuiCol_ChildBg] = ImVec4(0.15f, 0.18f, 0.22f, 1.00f); + colors[ImGuiCol_PopupBg] = ImVec4(0.08f, 0.08f, 0.08f, 0.94f); + colors[ImGuiCol_Border] = ImVec4(0.08f, 0.10f, 0.12f, 1.00f); + colors[ImGuiCol_BorderShadow] = ImVec4(0.00f, 0.00f, 0.00f, 0.00f); + colors[ImGuiCol_FrameBg] = ImVec4(0.20f, 0.25f, 0.29f, 1.00f); + colors[ImGuiCol_FrameBgHovered] = ImVec4(0.12f, 0.20f, 0.28f, 1.00f); + colors[ImGuiCol_FrameBgActive] = ImVec4(0.09f, 0.12f, 0.14f, 1.00f); + colors[ImGuiCol_TitleBg] = ImVec4(0.09f, 0.12f, 0.14f, 0.65f); + colors[ImGuiCol_TitleBgActive] = ImVec4(0.08f, 0.10f, 0.12f, 1.00f); + colors[ImGuiCol_TitleBgCollapsed] = ImVec4(0.00f, 0.00f, 0.00f, 0.51f); + colors[ImGuiCol_MenuBarBg] = ImVec4(0.15f, 0.18f, 0.22f, 1.00f); + colors[ImGuiCol_ScrollbarBg] = ImVec4(0.02f, 0.02f, 0.02f, 0.39f); + colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.20f, 0.25f, 0.29f, 1.00f); + colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.18f, 0.22f, 0.25f, 1.00f); + colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.09f, 0.21f, 0.31f, 1.00f); + colors[ImGuiCol_CheckMark] = ImVec4(0.28f, 0.56f, 1.00f, 1.00f); + colors[ImGuiCol_SliderGrab] = ImVec4(0.28f, 0.56f, 1.00f, 1.00f); + colors[ImGuiCol_SliderGrabActive] = ImVec4(0.37f, 0.61f, 1.00f, 1.00f); + colors[ImGuiCol_Button] = ImVec4(0.20f, 0.25f, 0.29f, 1.00f); + colors[ImGuiCol_ButtonHovered] = ImVec4(0.28f, 0.56f, 1.00f, 1.00f); + colors[ImGuiCol_ButtonActive] = ImVec4(0.06f, 0.53f, 0.98f, 1.00f); + colors[ImGuiCol_Header] = ImVec4(0.20f, 0.25f, 0.29f, 0.55f); + colors[ImGuiCol_HeaderHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.80f); + colors[ImGuiCol_HeaderActive] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); + colors[ImGuiCol_Separator] = ImVec4(0.20f, 0.25f, 0.29f, 1.00f); + colors[ImGuiCol_SeparatorHovered] = ImVec4(0.10f, 0.40f, 0.75f, 0.78f); + colors[ImGuiCol_SeparatorActive] = ImVec4(0.10f, 0.40f, 0.75f, 1.00f); + colors[ImGuiCol_ResizeGrip] = ImVec4(0.26f, 0.59f, 0.98f, 0.25f); + colors[ImGuiCol_ResizeGripHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.67f); + colors[ImGuiCol_ResizeGripActive] = ImVec4(0.26f, 0.59f, 0.98f, 0.95f); + colors[ImGuiCol_Tab] = ImVec4(0.11f, 0.15f, 0.17f, 1.00f); + colors[ImGuiCol_TabHovered] = ImVec4(0.26f, 0.59f, 0.98f, 0.80f); + colors[ImGuiCol_TabActive] = ImVec4(0.20f, 0.25f, 0.29f, 1.00f); + colors[ImGuiCol_TabUnfocused] = ImVec4(0.11f, 0.15f, 0.17f, 1.00f); + colors[ImGuiCol_TabUnfocusedActive] = ImVec4(0.11f, 0.15f, 0.17f, 1.00f); + colors[ImGuiCol_PlotLines] = ImVec4(0.61f, 0.61f, 0.61f, 1.00f); + colors[ImGuiCol_PlotLinesHovered] = ImVec4(1.00f, 0.43f, 0.35f, 1.00f); + colors[ImGuiCol_PlotHistogram] = ImVec4(0.90f, 0.70f, 0.00f, 1.00f); + colors[ImGuiCol_PlotHistogramHovered] = ImVec4(1.00f, 0.60f, 0.00f, 1.00f); + colors[ImGuiCol_TextSelectedBg] = ImVec4(0.26f, 0.59f, 0.98f, 0.35f); + colors[ImGuiCol_DragDropTarget] = ImVec4(1.00f, 1.00f, 0.00f, 0.90f); + colors[ImGuiCol_NavHighlight] = ImVec4(0.26f, 0.59f, 0.98f, 1.00f); + colors[ImGuiCol_NavWindowingHighlight] = ImVec4(1.00f, 1.00f, 1.00f, 0.70f); + colors[ImGuiCol_NavWindowingDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.20f); + colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.80f, 0.80f, 0.80f, 0.35f); + */ } \ No newline at end of file diff --git a/Editor/Scripts/EntityManipulation/AddComponent.as b/Editor/Scripts/Properties/AddComponent.as similarity index 93% rename from Editor/Scripts/EntityManipulation/AddComponent.as rename to Editor/Scripts/Properties/AddComponent.as index 4ea0a7f..419214b 100644 --- a/Editor/Scripts/EntityManipulation/AddComponent.as +++ b/Editor/Scripts/Properties/AddComponent.as @@ -6,9 +6,6 @@ class AddComponentRender { } void addComponentPopup() { - ImGui::textCenter("Add Component"); - ImGui::separator(); - ImGui::subMenu( "Rendering", SimpleFunction(this.addComponentRendering) diff --git a/Editor/Scripts/EntityManipulation/CameraProperties.as b/Editor/Scripts/Properties/CameraProperties.as similarity index 100% rename from Editor/Scripts/EntityManipulation/CameraProperties.as rename to Editor/Scripts/Properties/CameraProperties.as diff --git a/Editor/Scripts/EntityManipulation/MeshProperties.as b/Editor/Scripts/Properties/MeshProperties.as similarity index 74% rename from Editor/Scripts/EntityManipulation/MeshProperties.as rename to Editor/Scripts/Properties/MeshProperties.as index a18bbd0..cfbc91b 100644 --- a/Editor/Scripts/EntityManipulation/MeshProperties.as +++ b/Editor/Scripts/Properties/MeshProperties.as @@ -11,40 +11,51 @@ class MeshComponentRender { if (!entity.hasComponent()) return; - ImGui::title("Mesh Component"); - ImGui::sameline(); - - if (ImGui::buttonEnd("Clear")) { - meshComponent.clear(); - } - - ImGui::space(10, 10); + ImGui::columns(2); ImGui::text("Mesh "); - ImGui::sameline(); + + ImGui::nextColumn(); + if (meshComponent.hasMesh) { - ImGui::textColor(0.6, 1, 0.7,meshComponent.meshResource.name); + ImGui::buttonExpanded(meshComponent.meshResource.name); } else { - ImGui::text("Empty"); + ImGui::buttonExpanded(""); } + ImGui::dragDropTarget("MESH", ReciverFunction(this.setMesh)); + ImGui::space(0, 1); + ImGui::nextColumn(); + ImGui::text("Shader "); - ImGui::sameline(); + + ImGui::nextColumn(); + if (meshComponent.hasShader) { - ImGui::textColor(0.6, 1, 0.7,meshComponent.shader.name); + ImGui::buttonExpanded(meshComponent.shader.name); } else { - ImGui::text("Empty"); + ImGui::buttonExpanded(""); } + ImGui::dragDropTarget("SHADER", ReciverFunction(this.setShader)); + ImGui::space(0, 1); + ImGui::nextColumn(); + ImGui::text("Texture "); - ImGui::sameline(); + + ImGui::nextColumn(); + if (meshComponent.hasTexture) { - ImGui::textColor(0.6, 1, 0.7,meshComponent.texture.name); + ImGui::buttonExpanded(meshComponent.texture.name); } else { - ImGui::text("Empty"); + ImGui::buttonExpanded(""); } + ImGui::dragDropTarget("TEXTURE", ReciverFunction(this.setTexture)); + + ImGui::endColumns(); + // Mesh icon /* if (meshComponent.hasMesh) { @@ -77,9 +88,14 @@ class MeshComponentRender { meshComponent.texture = texture; } } + void remove() { if (ImGui::menuItem("Remove")) { entity.removeComponent(); } + + if (ImGui::menuItem("Clear")) { + meshComponent.clear(); + } } } diff --git a/Editor/Scripts/EntityManipulation/PropertiesPannel.as b/Editor/Scripts/Properties/PropertiesPannel.as similarity index 99% rename from Editor/Scripts/EntityManipulation/PropertiesPannel.as rename to Editor/Scripts/Properties/PropertiesPannel.as index 198ee70..aa5867e 100644 --- a/Editor/Scripts/EntityManipulation/PropertiesPannel.as +++ b/Editor/Scripts/Properties/PropertiesPannel.as @@ -1,4 +1,4 @@ -class PropertiesPanel : Panel { +class Properties : Panel { void onImGui() { Entity entity = ActiveEntity::getActiveEntity(); diff --git a/Editor/Scripts/EntityManipulation/TransformRender.as b/Editor/Scripts/Properties/TransformRender.as similarity index 81% rename from Editor/Scripts/EntityManipulation/TransformRender.as rename to Editor/Scripts/Properties/TransformRender.as index 7c62096..425df6d 100644 --- a/Editor/Scripts/EntityManipulation/TransformRender.as +++ b/Editor/Scripts/Properties/TransformRender.as @@ -10,14 +10,16 @@ class TransformPropertiesRender { void render() { vec3 position = transform.position; vec3 scale = transform.scale; - vec3 rotation = transform.rotation; + vec3 rotation = transform.getEuler(); position = ImGui::magicSlider3("Position", position, 0.1f); + ImGui::space(0, 1); scale = ImGui::magicSlider3("Scale", scale, 0.1f); + ImGui::space(0, 1); rotation = ImGui::magicSlider3("Rotation", rotation, 0.1f); transform.set_position(position); transform.set_scale(scale); - transform.set_rotation(rotation); + transform.setEuler(rotation); } } diff --git a/Editor/Scripts/ResourceExplorer/ResourceExplorer.as b/Editor/Scripts/ResourceExplorer/ResourceExplorer.as index 9ae0e49..1df81f0 100644 --- a/Editor/Scripts/ResourceExplorer/ResourceExplorer.as +++ b/Editor/Scripts/ResourceExplorer/ResourceExplorer.as @@ -174,7 +174,7 @@ class ResourceExplorer : Panel { void onImGui() { fase += 0.3; - ImGui::automaticColumns(size * 1.5); + ImGui::automaticColumns(size + 64); string temp_path = currentPath; diff --git a/Editor/Scripts/TreeExplorer/Tree.as b/Editor/Scripts/TreeExplorer/Tree.as index db60268..2b99bcc 100644 --- a/Editor/Scripts/TreeExplorer/Tree.as +++ b/Editor/Scripts/TreeExplorer/Tree.as @@ -112,7 +112,7 @@ class EntityNodeUI { void renderContextMenu() { if (entity.isRoot) { if (ImGui::menuItem("New Entity")) { - entity.createChild("node"); + entity.createChild("Entity"); rootPanel.onInit(); } @@ -120,7 +120,7 @@ class EntityNodeUI { ImGui::subMenu("3d Object", SimpleFunction(this.render3dObjectMenu)); } else { if (ImGui::menuItem("Add child")) { - entity.createChild("node"); + entity.createChild("Entity"); rootPanel.onInit(); } if (ImGui::menuItem("Rename")) { @@ -141,7 +141,7 @@ class EntityNodeUI { void render3dObjectMenu() { if (ImGui::menuItem("Cube")) { - Entity child = entity.createChild("node"); + Entity child = entity.createChild("Cube"); MeshComponent childMesh = child.addComponent(); childMesh.meshResource = Builtin::cube(); childMesh.shader = Builtin::simpleShader(); @@ -150,7 +150,7 @@ class EntityNodeUI { } if (ImGui::menuItem("Sphere")) { - Entity child = entity.createChild("node"); + Entity child = entity.createChild("Sphere"); MeshComponent childMesh = child.addComponent(); childMesh.meshResource = Builtin::sphere(); childMesh.shader = Builtin::simpleShader(); diff --git a/Editor/Scripts/Viewport/Viewport.as b/Editor/Scripts/Viewport/Viewport.as index c70a926..beee663 100644 --- a/Editor/Scripts/Viewport/Viewport.as +++ b/Editor/Scripts/Viewport/Viewport.as @@ -9,6 +9,8 @@ class Viewport : Panel { float deltaAcomulated = 0; float latestFrameRate; + int editMode = 0; + void onImGui() { if (!frameBuffer.isValid()) return; @@ -33,7 +35,7 @@ class Viewport : Panel { return; frameBuffer.resize(x, y); - frameBuffer.clearRGBA(200, 230, 250, 255); + frameBuffer.clearRGBA(20, 23, 25, 255); sceneCamera.camera.aspect = float(x) / y; World::render(frameBuffer, sceneCamera); @@ -43,12 +45,26 @@ class Viewport : Panel { if(ActiveEntity::entity != World::getRoot()) { mat4 entityTransform = ActiveEntity::entity.getWorldMatrix(); - if (ImGui::manipulationTransform(sceneCamera, entityTransform, entityTransform, false)) { + if (editMode == 0 && ImGui::manipulationTransform(sceneCamera, entityTransform, entityTransform, false)) { mat4 parentTransform = ActiveEntity::entity.parent.getWorldMatrix(); mat4 relativeMatrix = entityTransform.getRelativeMatrix(parentTransform); ActiveEntity::entity.getComponent().position = relativeMatrix.getPosition(); } + + if (editMode == 1 && ImGui::manipulationRotation(sceneCamera, entityTransform, entityTransform, false)) { + mat4 parentTransform = ActiveEntity::entity.parent.getWorldMatrix(); + + mat4 relativeMatrix = entityTransform.getRelativeMatrix(parentTransform); + ActiveEntity::entity.getComponent().rotation = relativeMatrix.getRotation(); + } + + if (editMode == 2 && ImGui::manipulationScale(sceneCamera, entityTransform, entityTransform, false)) { + mat4 parentTransform = ActiveEntity::entity.parent.getWorldMatrix(); + + mat4 relativeMatrix = entityTransform.getRelativeMatrix(parentTransform); + ActiveEntity::entity.getComponent().scale = relativeMatrix.getScale(); + } } if (!ImGui::isPanelActive()) @@ -107,16 +123,28 @@ class Viewport : Panel { } void onMenuBar() { - if (ImGui::menuItem("Start")) { - - } - + /* if (ImGui::menuItem("Viewport")) { ImGui::openPopup("ViewportCameraProps", any()); - } - + }*/ + ImGui::simplePopup("ViewportCameraProps", SimpleFunction(this.viewportCameraProps)); - ImGui::textColor(0, 0.5f, 0,"" + latestFrameRate); + ImGui::textColor(0, 0.5f, 0,"" + int(latestFrameRate)); + + ImGui::drawComboEnd("##EditMode", "Translate", SimpleFunction(this.transformCombo)); + + } + + void transformCombo () { + if (ImGui::drawComboItem("Translate", editMode == 0)) { + editMode = 0; + } + if (ImGui::drawComboItem("Rotate", editMode == 1)) { + editMode = 1; + } + if (ImGui::drawComboItem("Scale", editMode == 2)) { + editMode = 2; + } } void viewportCameraProps() { diff --git a/imgui.ini b/imgui.ini index 0be5b32..64012ac 100644 --- a/imgui.ini +++ b/imgui.ini @@ -1,6 +1,6 @@ [Window][DockSpace Demo] Pos=0,0 -Size=1920,1011 +Size=2560,1371 Collapsed=0 [Window][Debug##Default] @@ -12,17 +12,17 @@ Collapsed=0 Pos=401,26 Size=940,653 Collapsed=0 -DockId=0x00000008,0 +DockId=0x00000009,0 [Window][PropertiesPanel] -Pos=1347,26 -Size=573,654 +Pos=1987,26 +Size=573,1014 Collapsed=0 DockId=0x00000006,0 [Window][ResourceExplorer] -Pos=0,682 -Size=1920,329 +Pos=0,1022 +Size=2560,349 Collapsed=0 DockId=0x00000004,0 @@ -39,25 +39,45 @@ Collapsed=0 DockId=0x00000006,1 [Window][EntityTree] -Pos=0,26 -Size=406,654 +Pos=0,28 +Size=423,992 Collapsed=0 DockId=0x00000007,0 [Window][Viewport] -Pos=408,26 -Size=937,654 +Pos=425,28 +Size=1513,992 Collapsed=0 -DockId=0x00000008,0 +DockId=0x00000009,0 + +[Window][Properties] +Pos=1940,28 +Size=620,992 +Collapsed=0 +DockId=0x0000000A,0 + +[Window][Dear ImGui Demo] +Pos=425,28 +Size=1513,992 +Collapsed=0 +DockId=0x00000009,1 + +[Window][Dear ImGui Style Editor] +Pos=425,28 +Size=1513,992 +Collapsed=0 +DockId=0x00000009,2 [Docking][Data] -DockSpace ID=0x0AC2E849 Window=0xD0388BC8 Pos=0,26 Size=1920,985 Split=Y - DockNode ID=0x00000003 Parent=0x0AC2E849 SizeRef=1920,654 Split=X - DockNode ID=0x00000001 Parent=0x00000003 SizeRef=399,985 Selected=0x16E3C1E7 - DockNode ID=0x00000002 Parent=0x00000003 SizeRef=1519,985 Split=X - DockNode ID=0x00000005 Parent=0x00000002 SizeRef=1345,493 Split=X Selected=0xC450F867 - DockNode ID=0x00000007 Parent=0x00000005 SizeRef=406,653 Selected=0xA1816002 - DockNode ID=0x00000008 Parent=0x00000005 SizeRef=937,653 CentralNode=1 Selected=0xC450F867 - DockNode ID=0x00000006 Parent=0x00000002 SizeRef=573,493 Selected=0x9876A79B - DockNode ID=0x00000004 Parent=0x0AC2E849 SizeRef=1920,329 Selected=0x018A0F9B +DockSpace ID=0x0AC2E849 Window=0xD0388BC8 Pos=0,28 Size=2560,1343 Split=Y + DockNode ID=0x00000003 Parent=0x0AC2E849 SizeRef=1920,662 Split=X + DockNode ID=0x00000001 Parent=0x00000003 SizeRef=399,985 Selected=0x16E3C1E7 + DockNode ID=0x00000002 Parent=0x00000003 SizeRef=1519,985 Split=X + DockNode ID=0x00000005 Parent=0x00000002 SizeRef=1345,493 Split=X Selected=0xC450F867 + DockNode ID=0x00000007 Parent=0x00000005 SizeRef=423,653 Selected=0xA1816002 + DockNode ID=0x00000008 Parent=0x00000005 SizeRef=2135,653 Split=X Selected=0xC450F867 + DockNode ID=0x00000009 Parent=0x00000008 SizeRef=1513,1014 CentralNode=1 Selected=0xC450F867 + DockNode ID=0x0000000A Parent=0x00000008 SizeRef=620,1014 Selected=0x8C72BEA8 + DockNode ID=0x00000006 Parent=0x00000002 SizeRef=573,493 Selected=0x9876A79B + DockNode ID=0x00000004 Parent=0x0AC2E849 SizeRef=1920,349 Selected=0x018A0F9B diff --git a/q b/q new file mode 100644 index 0000000..e69de29