From 0b01400493672ecabcdd6a16aaecafb6907fc737 Mon Sep 17 00:00:00 2001 From: 4sval Date: Mon, 29 Aug 2022 01:10:57 +0200 Subject: [PATCH] hmm --- FModel/Views/Snooper/Model.cs | 8 +++++-- FModel/Views/Snooper/Section.cs | 8 ++++--- FModel/Views/Snooper/Snooper.cs | 42 +++++++++++++++++++++++---------- 3 files changed, 40 insertions(+), 18 deletions(-) diff --git a/FModel/Views/Snooper/Model.cs b/FModel/Views/Snooper/Model.cs index f5795953..9dfdc00a 100644 --- a/FModel/Views/Snooper/Model.cs +++ b/FModel/Views/Snooper/Model.cs @@ -88,6 +88,8 @@ public class Model : IDisposable public void Bind(Camera camera) { + ImGui.Text($"Entity: {Name}"); + _vao.Bind(); _shader.Use(); @@ -115,13 +117,15 @@ public class Model : IDisposable ImGui.BeginTable("Sections", 2, ImGuiTableFlags.RowBg); ImGui.TableSetupColumn("Index", ImGuiTableColumnFlags.WidthFixed); - ImGui.TableSetupColumn("Material"); + ImGui.TableSetupColumn("Material", ImGuiTableColumnFlags.WidthStretch); ImGui.TableHeadersRow(); for (int section = 0; section < Sections.Length; section++) { - Sections[section].Bind(section); + Sections[section].Bind(section, Indices.Length); } ImGui.EndTable(); + + ImGui.Separator(); } public void Dispose() diff --git a/FModel/Views/Snooper/Section.cs b/FModel/Views/Snooper/Section.cs index 584d21d7..b43de0a0 100644 --- a/FModel/Views/Snooper/Section.cs +++ b/FModel/Views/Snooper/Section.cs @@ -1,4 +1,5 @@ using System; +using System.Numerics; using CUE4Parse.UE4.Assets.Exports.Material; using CUE4Parse.UE4.Assets.Exports.Texture; using CUE4Parse_Conversion.Meshes.PSK; @@ -75,7 +76,7 @@ public class Section : IDisposable } } - public void Bind(int index) + public void Bind(int index, float indices) { ImGui.TableNextRow(); @@ -86,10 +87,11 @@ public class Section : IDisposable if (ImGui.IsItemHovered()) { ImGui.BeginTooltip(); - ImGui.Text($"Faces: {FacesCount}"); - ImGui.Text($"Face First Index: {FirstFaceIndex}"); + ImGui.Text($"Faces: {FacesCount} ({Math.Floor(FacesCount / indices * 100f)}%%)"); + ImGui.Text($"First Face: {FirstFaceIndex}"); ImGui.Separator(); ImGui.Text($"Diffuse: ({Parameters.Diffuse?.ExportType}) {Parameters.Diffuse?.Name}"); + ImGui.Text($"Normal: ({Parameters.Normal?.ExportType}) {Parameters.Normal?.Name}"); ImGui.EndTooltip(); } diff --git a/FModel/Views/Snooper/Snooper.cs b/FModel/Views/Snooper/Snooper.cs index 6e08f056..fdaf5133 100644 --- a/FModel/Views/Snooper/Snooper.cs +++ b/FModel/Views/Snooper/Snooper.cs @@ -22,6 +22,7 @@ public class Snooper private GL _gl; private Camera _camera; private IKeyboard _keyboard; + private IMouse _mouse; private Vector2 _previousMousePosition; private Model[] _models; @@ -40,6 +41,8 @@ public class Snooper var options = WindowOptions.Default; options.Size = new Vector2D(Width, Height); + options.WindowBorder = WindowBorder.Hidden; + options.Position = new Vector2D(5, 5); // this doesn't fucking work WTF options.Title = "Snooper"; _window = Window.Create(options); @@ -87,12 +90,11 @@ public class Snooper _input = _window.CreateInput(); _keyboard = _input.Keyboards[0]; _keyboard.KeyDown += KeyDown; - foreach (var mouse in _input.Mice) - { - // mouse.Cursor.CursorMode = CursorMode.Raw; - // mouse.MouseMove += OnMouseMove; - // mouse.Scroll += OnMouseWheel; - } + _mouse = _input.Mice[0]; + _mouse.MouseDown += OnMouseDown; + _mouse.MouseUp += OnMouseUp; + _mouse.MouseMove += OnMouseMove; + _mouse.Scroll += OnMouseWheel; _gl = GL.GetApi(_window); _gl.Enable(EnableCap.Blend); @@ -130,9 +132,7 @@ public class Snooper foreach (var model in _models) { - ImGui.Text($"Entity: {model.Name}"); model.Bind(_camera); - ImGui.Separator(); } float framerate = ImGui.GetIO().Framerate; @@ -174,17 +174,33 @@ public class Snooper } } + private void OnMouseDown(IMouse mouse, MouseButton button) + { + if (button != MouseButton.Left) return; + mouse.Cursor.CursorMode = CursorMode.Raw; + } + + private void OnMouseUp(IMouse mouse, MouseButton button) + { + if (button != MouseButton.Left) return; + mouse.Cursor.CursorMode = CursorMode.Normal; + } + private void OnMouseMove(IMouse mouse, Vector2 position) { - const float lookSensitivity = 0.1f; if (_previousMousePosition == default) { _previousMousePosition = position; } else { - var xOffset = (position.X - _previousMousePosition.X) * lookSensitivity; - var yOffset = (position.Y - _previousMousePosition.Y) * lookSensitivity; - _previousMousePosition = position; + if (mouse.Cursor.CursorMode == CursorMode.Raw) + { + const float lookSensitivity = 0.1f; + var xOffset = (position.X - _previousMousePosition.X) * lookSensitivity; + var yOffset = (position.Y - _previousMousePosition.Y) * lookSensitivity; - _camera.ModifyDirection(xOffset, yOffset); + _camera.ModifyDirection(xOffset, yOffset); + } + + _previousMousePosition = position; } }