diff --git a/Brio/Config/InterfaceConfiguration.cs b/Brio/Config/InterfaceConfiguration.cs index 5c74f0f9..fb06bfd4 100644 --- a/Brio/Config/InterfaceConfiguration.cs +++ b/Brio/Config/InterfaceConfiguration.cs @@ -1,4 +1,6 @@ -namespace Brio.Config; +using ImGuiNET; + +namespace Brio.Config; internal class InterfaceConfiguration { @@ -7,4 +9,7 @@ internal class InterfaceConfiguration public bool ShowInCutscene { get; set; } = false; public bool ShowWhenUIHidden { get; set; } = false; public bool CensorActorNames { get; set; } = false; + + public ImGuiKey IncrementSmall { get; set; } = ImGuiKey.RightCtrl; + public ImGuiKey IncrementLarge { get; set; } = ImGuiKey.RightShift; } diff --git a/Brio/Core/ImGuizmoExtensions.cs b/Brio/Core/ImGuizmoExtensions.cs new file mode 100644 index 00000000..3a466961 --- /dev/null +++ b/Brio/Core/ImGuizmoExtensions.cs @@ -0,0 +1,46 @@ +using Brio.Config; +using ImGuiNET; +using ImGuizmoNET; +using System.Numerics; + +namespace Brio.Core; + +internal static class ImGuizmoExtensions +{ + public static bool MouseWheelManipulate(ref Matrix4x4 matrix) + { + if(ImGui.IsAnyMouseDown()) + return false; + + float mouseWheel = ImGui.GetIO().MouseWheel / 100; + + if(mouseWheel != 0) + { + bool smallIncrement = ImGui.IsKeyDown(ConfigurationService.Instance.Configuration.Interface.IncrementSmall); + if(smallIncrement) + mouseWheel /= 10; + + bool largeIncrement = ImGui.IsKeyDown(ConfigurationService.Instance.Configuration.Interface.IncrementLarge); + if(largeIncrement) + mouseWheel *= 10; + + if(ImGuizmo.IsOver(OPERATION.ROTATE_X)) + { + matrix = Matrix4x4.CreateRotationX(mouseWheel) * matrix; + return true; + } + else if(ImGuizmo.IsOver(OPERATION.ROTATE_Y)) + { + matrix = Matrix4x4.CreateRotationY(mouseWheel) * matrix; + return true; + } + else if(ImGuizmo.IsOver(OPERATION.ROTATE_Z)) + { + matrix = Matrix4x4.CreateRotationZ(mouseWheel) * matrix; + return true; + } + } + + return false; + } +} diff --git a/Brio/UI/Windows/Specialized/PosingGraphicalWindow.cs b/Brio/UI/Windows/Specialized/PosingGraphicalWindow.cs index be96ff24..d25d67e0 100644 --- a/Brio/UI/Windows/Specialized/PosingGraphicalWindow.cs +++ b/Brio/UI/Windows/Specialized/PosingGraphicalWindow.cs @@ -345,6 +345,11 @@ private unsafe void DrawGizmo() ImGuizmo.Enable(true); + if(ImGuizmoExtensions.MouseWheelManipulate(ref matrix)) + { + _trackingMatrix = matrix; + } + if(ImGuizmo.Manipulate(ref viewMatrix.M11, ref projectionMatrix.M11, OPERATION.ROTATE, _posingService.CoordinateMode.AsGizmoMode(), ref matrix.M11)) { _trackingMatrix = matrix; diff --git a/Brio/UI/Windows/Specialized/PosingOverlayWindow.cs b/Brio/UI/Windows/Specialized/PosingOverlayWindow.cs index 02404468..ed3116d5 100644 --- a/Brio/UI/Windows/Specialized/PosingOverlayWindow.cs +++ b/Brio/UI/Windows/Specialized/PosingOverlayWindow.cs @@ -406,6 +406,12 @@ private unsafe void DrawGizmo(PosingCapability posing, OverlayUIState uiState) Transform? newTransform = null; + if(ImGuizmoExtensions.MouseWheelManipulate(ref matrix)) + { + newTransform = matrix.ToTransform(); + _trackingTransform = newTransform; + } + if(ImGuizmo.Manipulate( ref worldViewMatrix.M11, ref projectionMatrix.M11,