HexaEngine / Hexa.NET.ImGui

A .NET wrapper for the Dear ImGui.
Other
77 stars 6 forks source link

Regarding the use of imguizmo. #5

Closed qian-o closed 8 months ago

qian-o commented 8 months ago

Hello, this is my first time using 'imguizmo' as a small tool for a 3D scene. I have encountered an issue where even after calling the SetRect function and moving the camera, the tool goes beyond the viewport area. I am unsure how to resolve this. I have tried setting the clipping area for the drawlist as suggested in the imguizmo repo's issue, but unfortunately, it did not work.

ImGuizmo.SetDrawlist();
ImGuizmo.SetRect(Left, Top, Width, Height);

float[] view = Camera.View.ToArray();

ImGuizmo.ViewManipulate(ref view[0],
                        8.0f,
                        new Vector2(Left + Width - 128.0f, Top),
                        new Vector2(128.0f, 128.0f),
                        ImGui.GetColorU32(Vector4.Zero));

Camera.UpdateView(view.ToMatrix());

or

ImDrawListPtr drawList = ImGui.GetWindowDrawList();
drawList.PushClipRect(new Vector2(Left, Top), new Vector2(Left + Width, Top + Height));

ImGuizmo.SetDrawlist(drawList);
ImGuizmo.SetRect(Left, Top, Width, Height);

float[] view = Camera.View.ToArray();

ImGuizmo.ViewManipulate(ref view[0],
                        8.0f,
                        new Vector2(Left + Width - 128.0f, Top),
                        new Vector2(128.0f, 128.0f),
                        ImGui.GetColorU32(Vector4.Zero));

Camera.UpdateView(view.ToMatrix());

The final result: image

I can guarantee that the parameters left, top, width, and height are all correct.