From 129f128f900a4042ce5b563a15d4fbe5452dde82 Mon Sep 17 00:00:00 2001 From: 4sval Date: Fri, 2 Sep 2022 20:38:27 +0200 Subject: [PATCH] transforms --- CUE4Parse | 2 +- FModel/Extensions/ImGuiExtensions.cs | 47 ++++------ FModel/FModel.csproj | 8 +- FModel/MainWindow.xaml.cs | 2 +- .../Resources/{shader.frag => default.frag} | 0 .../Resources/{shader.vert => default.vert} | 0 FModel/Views/SettingsView.xaml | 13 +-- FModel/Views/Snooper/Camera.cs | 9 -- FModel/Views/Snooper/FramebufferObject.cs | 2 +- FModel/Views/Snooper/Grid.cs | 4 +- FModel/Views/Snooper/Model.cs | 93 ++++++++++++++++--- FModel/Views/Snooper/Section.cs | 17 ++-- FModel/Views/Snooper/Shader.cs | 8 +- FModel/Views/Snooper/Skybox.cs | 6 +- FModel/Views/Snooper/Snooper.cs | 35 +++---- FModel/Views/Snooper/Transform.cs | 21 +++-- 16 files changed, 156 insertions(+), 111 deletions(-) rename FModel/Resources/{shader.frag => default.frag} (100%) rename FModel/Resources/{shader.vert => default.vert} (100%) diff --git a/CUE4Parse b/CUE4Parse index 194224af..19dfffa9 160000 --- a/CUE4Parse +++ b/CUE4Parse @@ -1 +1 @@ -Subproject commit 194224aff89fa4512edac7557e7a1859b878f3a8 +Subproject commit 19dfffa9e55d0951e7da75789e65c8c4e6e62a3e diff --git a/FModel/Extensions/ImGuiExtensions.cs b/FModel/Extensions/ImGuiExtensions.cs index c6ab3b33..f49c63cf 100644 --- a/FModel/Extensions/ImGuiExtensions.cs +++ b/FModel/Extensions/ImGuiExtensions.cs @@ -8,7 +8,7 @@ namespace FModel.Extensions; public static class ImGuiExtensions { - public const float PADDING = 2.5f; + public const uint DockspaceId = 1337; private static bool _viewportFocus; @@ -23,13 +23,19 @@ public static class ImGuiExtensions ImGui.SetNextWindowPos(new Vector2(0, 0)); ImGui.SetNextWindowSize(new Vector2(size.X, size.Y)); ImGui.Begin("Snooper", flags); - ImGui.DockSpace(0); + ImGui.DockSpace(DockspaceId); } public static void DrawNavbar() { if (!ImGui.BeginMainMenuBar()) return; + if (ImGui.BeginMenu("Window")) + { + ImGui.MenuItem("Append", "CTRL+A"); + ImGui.MenuItem("Close", "ESC"); + ImGui.EndMenu(); + } if (ImGui.BeginMenu("Edit")) { if (ImGui.MenuItem("Undo", "CTRL+Z")) {} @@ -48,29 +54,12 @@ public static class ImGuiExtensions ImGui.EndMainMenuBar(); } - public static void DrawFPS() - { - const ImGuiWindowFlags flags = - ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.AlwaysAutoResize | - ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoFocusOnAppearing | - ImGuiWindowFlags.NoBackground | ImGuiWindowFlags.NoNav; - var viewport = ImGui.GetMainViewport(); - var work_pos = viewport.WorkPos; - var work_size = viewport.WorkSize; - - ImGui.SetNextWindowPos(new Vector2(work_pos.X + PADDING, work_pos.Y + work_size.Y - PADDING), ImGuiCond.Always, new Vector2(0, 1)); - if (ImGui.Begin("FPS Overlay", flags)) - { - float framerate = ImGui.GetIO().Framerate; - ImGui.Text($"FPS: {framerate:0} ({1000.0f / framerate:0.##} ms)"); - } - ImGui.End(); - } - public static void DrawViewport(FramebufferObject framebuffer, Camera camera, IMouse mouse) { const float lookSensitivity = 0.1f; - const ImGuiWindowFlags flags = ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse; + const ImGuiWindowFlags flags = + ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse | + ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.AlwaysUseWindowPadding; ImGui.Begin("Viewport", flags); @@ -87,8 +76,9 @@ public static class ImGuiExtensions } var pos = new Vector2(largest.X / 2f - width / 2f + ImGui.GetCursorPosX(), largest.Y / 2f - height / 2f + ImGui.GetCursorPosY()); + var size = new Vector2(width, height); ImGui.SetCursorPos(pos); - ImGui.ImageButton(framebuffer.GetPointer(), new Vector2(width, height), new Vector2(0, 1), new Vector2(1, 0), 0); + ImGui.ImageButton(framebuffer.GetPointer(), size, new Vector2(0, 1), new Vector2(1, 0), 0); // it took me 5 hours to make it work, don't change any of the following code // basically the Raw cursor doesn't actually freeze the mouse position @@ -121,6 +111,12 @@ public static class ImGuiExtensions mouse.Cursor.CursorMode = CursorMode.Normal; } + const float padding = 5f; + float framerate = ImGui.GetIO().Framerate; + var text = $"FPS: {framerate:0} ({1000.0f / framerate:0.##} ms)"; + ImGui.SetCursorPos(new Vector2(pos.X + padding, pos.Y + size.Y - ImGui.CalcTextSize(text).Y - padding)); + ImGui.Text(text); + ImGui.End(); } @@ -130,13 +126,10 @@ public static class ImGuiExtensions io.ConfigFlags |= ImGuiConfigFlags.DockingEnable; io.ConfigFlags |= ImGuiConfigFlags.ViewportsEnable; io.ConfigWindowsMoveFromTitleBarOnly = true; - io.ConfigWindowsResizeFromEdges = false; + io.ConfigDockingWithShift = true; var style = ImGui.GetStyle(); - style.FrameRounding = 2.0f; - style.GrabRounding = 2.0f; style.WindowPadding = Vector2.Zero; - // style.Colors[(int) ImGuiCol.Text] = new Vector4(0.95f, 0.96f, 0.98f, 1.00f); // style.Colors[(int) ImGuiCol.TextDisabled] = new Vector4(0.36f, 0.42f, 0.47f, 1.00f); // style.Colors[(int) ImGuiCol.WindowBg] = new Vector4(0.149f, 0.149f, 0.188f, 0.35f); diff --git a/FModel/FModel.csproj b/FModel/FModel.csproj index 1dcb7ee1..ce1ddf6b 100644 --- a/FModel/FModel.csproj +++ b/FModel/FModel.csproj @@ -93,8 +93,8 @@ - - + + @@ -110,8 +110,8 @@ - - + + diff --git a/FModel/MainWindow.xaml.cs b/FModel/MainWindow.xaml.cs index 563c3b27..f58f8d56 100644 --- a/FModel/MainWindow.xaml.cs +++ b/FModel/MainWindow.xaml.cs @@ -79,7 +79,7 @@ public partial class MainWindow #if DEBUG await _threadWorkerView.Begin(_ => _applicationView.CUE4Parse.Extract( - "FortniteGame/Content/Environments/Props/Winter/Meshes/SM_ChristmasTree_Llama.uasset")); + "Engine/Content/BasicShapes/Cube.uasset")); #endif } diff --git a/FModel/Resources/shader.frag b/FModel/Resources/default.frag similarity index 100% rename from FModel/Resources/shader.frag rename to FModel/Resources/default.frag diff --git a/FModel/Resources/shader.vert b/FModel/Resources/default.vert similarity index 100% rename from FModel/Resources/shader.vert rename to FModel/Resources/default.vert diff --git a/FModel/Views/SettingsView.xaml b/FModel/Views/SettingsView.xaml index a0b22557..fd3b2703 100644 --- a/FModel/Views/SettingsView.xaml +++ b/FModel/Views/SettingsView.xaml @@ -189,18 +189,7 @@ +