imguizmo,渲染了小部件,但赢得了回应

发布于 2025-01-26 03:33:03 字数 2271 浏览 5 评论 0原文

我正在尝试将Imguizmo整合到一个项目中。我能够像这样渲染guizmo:

”在此处输入图像说明”

但是,当我悬停在箭头上时,它们不会突出显示,我没有得到任何类型的响应,我尝试了所有列出的方法在诸如isoveriSusing之类的读书中,无论光标的位置如何,它总是返回false。我还在打印传递到操纵的矩阵的值,它永远不会更改(它始终是身份矩阵)。

这是我的IMGUI调用:

bool show_demo_window = true;
bool show_another_window = false;
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
int selected_vertex = 0;
bool hovering_imgui = false;
static ImGuiWindowFlags gizmoWindowFlags = 0;
static ImGuizmo::MODE mCurrentGizmoMode(ImGuizmo::LOCAL);
static ImGuizmo::OPERATION mCurrentGizmoOperation(ImGuizmo::TRANSLATE);
static bool useSnap = true;
static float snap[3] = { 1.f, 1.f, 1.f };
static float bounds[] = { -0.5f, -0.5f, -0.5f, 0.5f, 0.5f, 0.5f };
static float boundsSnap[] = { 0.1f, 0.1f, 0.1f };
static bool boundSizing = false;
static bool boundSizingSnap = false;
float camDistance = 8.f;
Eigen::Matrix4f model = Eigen::Matrix4f::Identity();
void Demo_GUI(NECamera::ArcballCamera& camera)
{
    mCurrentGizmoOperation = ImGuizmo::TRANSLATE;
    // Start the Dear ImGui frame
    ImGui_ImplGlfw_NewFrame();
    ImGui::NewFrame();
    ImGuizmo::BeginFrame();

    ImGuiIO& io = ImGui::GetIO();
    float viewManipulateRight = io.DisplaySize.x;
    float viewManipulateTop = 0;
    static ImGuiWindowFlags gizmoWindowFlags = 0;
    
    ImGuizmo::SetRect(0, 0, io.DisplaySize.x, io.DisplaySize.y);

    Eigen::Matrix4f view = camera.GetViewMatrix();
    Eigen::Matrix4f proj = camera.GetProjectionMatrix();
    proj(1, 1) *= -1;

    ImGuizmo::Enable(true);
    ImGuizmo::Manipulate(view.data(), proj.data(), mCurrentGizmoOperation, mCurrentGizmoMode, model.data(), NULL, useSnap ? &snap[0] : NULL, boundSizing ? bounds : NULL, boundSizingSnap ? boundsSnap : NULL);
    ImGui::InputFloat3("Snap", &snap[0]);

    std::cout << model << std::endl;

    // Rendering
    ImGui::Render();
}

Imgui本身可以使用,屏幕截图中的调试窗口正常,我可以将其拖动并调整大小。因此,iMgui已正确配置了它,只是行为奇怪的Imguizmo。

我不确定我缺少什么。为什么Guizmo不回应?

我正在使用Vulkan作为渲染后端。

I am trying to integrate imguizmo into a project. I am able to render the guizmo like this:

enter image description here

However when I hover over the arrows, they don;t get highlighted and I don't get any type of response, I have tried all the methods listed in the readme such as IsOver and IsUsing which always return false regardless of the position of the cursor. I am also printing the values of the matrix passed into Manipulate, it never changes (it;s always the identity matrix).

This is my imgui call:

bool show_demo_window = true;
bool show_another_window = false;
ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);
int selected_vertex = 0;
bool hovering_imgui = false;
static ImGuiWindowFlags gizmoWindowFlags = 0;
static ImGuizmo::MODE mCurrentGizmoMode(ImGuizmo::LOCAL);
static ImGuizmo::OPERATION mCurrentGizmoOperation(ImGuizmo::TRANSLATE);
static bool useSnap = true;
static float snap[3] = { 1.f, 1.f, 1.f };
static float bounds[] = { -0.5f, -0.5f, -0.5f, 0.5f, 0.5f, 0.5f };
static float boundsSnap[] = { 0.1f, 0.1f, 0.1f };
static bool boundSizing = false;
static bool boundSizingSnap = false;
float camDistance = 8.f;
Eigen::Matrix4f model = Eigen::Matrix4f::Identity();
void Demo_GUI(NECamera::ArcballCamera& camera)
{
    mCurrentGizmoOperation = ImGuizmo::TRANSLATE;
    // Start the Dear ImGui frame
    ImGui_ImplGlfw_NewFrame();
    ImGui::NewFrame();
    ImGuizmo::BeginFrame();

    ImGuiIO& io = ImGui::GetIO();
    float viewManipulateRight = io.DisplaySize.x;
    float viewManipulateTop = 0;
    static ImGuiWindowFlags gizmoWindowFlags = 0;
    
    ImGuizmo::SetRect(0, 0, io.DisplaySize.x, io.DisplaySize.y);

    Eigen::Matrix4f view = camera.GetViewMatrix();
    Eigen::Matrix4f proj = camera.GetProjectionMatrix();
    proj(1, 1) *= -1;

    ImGuizmo::Enable(true);
    ImGuizmo::Manipulate(view.data(), proj.data(), mCurrentGizmoOperation, mCurrentGizmoMode, model.data(), NULL, useSnap ? &snap[0] : NULL, boundSizing ? bounds : NULL, boundSizingSnap ? boundsSnap : NULL);
    ImGui::InputFloat3("Snap", &snap[0]);

    std::cout << model << std::endl;

    // Rendering
    ImGui::Render();
}

Imgui itself works, the debug window in the screenshot behaves normally, I can drag it and resize it. So Imgui has been properly configured it;s just ImGuizmo that behaves oddly.

I am not sure what I am missing. Why is the guizmo not responding?

I am using vulkan as the rendering backend.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文