CedricGuillemet / ImGuizmo

Immediate mode 3D gizmo for scene editing and other controls based on Dear Imgui
MIT License
3.22k stars 907 forks source link

Can you embed the guizmos in the frame buffer directly? (i.e. not imgui windows)? #241

Closed Makogan closed 2 years ago

Makogan commented 2 years ago

I am trying to add some simple editing capabilities to a research tool. I integrated ImGuizmo and got this:

image

As you can see the guizmo is being rendered in an imgui window on top of the model I am rendering. I want just the cube to be rendered to the same FB without the imgui window decoration stuff.

Is this possible?

This is my function:

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;
void Demo_GUI(NECamera::ArcballCamera& camera)
{
    // Start the Dear ImGui frame
    ImGui_ImplGlfw_NewFrame();
    ImGui::NewFrame();
    ImGuizmo::BeginFrame();

    ImGuizmo::SetDrawlist();
    ImGuizmo::SetRect(0, 0, 800, 800);

    Eigen::Matrix4f view = camera.GetViewMatrix();
    Eigen::Matrix4f proj = camera.GetProjectionMatrix();
    Eigen::Matrix4f model = Eigen::Matrix4f::Identity();

    ImGuizmo::DrawCubes(view.data(), proj.data(), model.data(), 1);

    hovering_imgui = ImGui::GetIO().WantCaptureMouse;
    ImGui::Render();
}
CedricGuillemet commented 2 years ago

Imguizmo init is a bit different between a window and full screen. Check this code block :

https://github.com/CedricGuillemet/ImGuizmo/blob/8afa1d7050392111cb917a6439dc76450cda5aa6/example/main.cpp#L279

Makogan commented 2 years ago

Oh I see. Thank you lots. A small follow up, I don't see in the example how to render the rotation and translation widgets. (Thank you for the patience). NVM I see it is done implicitly through the use of the TRANSLATE and company enumerators, thank you.