CedricGuillemet / ImGuizmo

Immediate mode 3D gizmo for scene editing and other controls based on Dear Imgui

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ImGuizmo::DrawGrid() not working.

KennyProgrammer opened this issue · comments

Hey everyone!

This function does not want to work. I want to say that my usual gizmos work on OpenGL and DirectX 11, so I'm sure that this function is the problem. I noticed that it accepts the view and projection of the matrix, and 3 more parameter 'matrix', and I don't quite understand what exactly this matrix is. Camera transformation matrix or what?

In general, here's what I got:

ImGuizmo::SetOrthographic(camera.GetProjectionMatrixType() == CameraProjectionType::Orthographic ? true : false);
ImGuizmo::SetDrawlist();
ImGuizmo::SetRect(windowPos.x, windowPos.y, windowWidth, windowHeight);

// Camera projection & view
const glm::mat4& cameraProjection = camera.GetProjectionMatrix();
glm::mat4 cameraView = camera.GetViewMatrix();

ImGuizmo::DrawGrid(glm::value_ptr(cameraProjection), glm::value_ptr(glm::inverse(cameraView)), glm::value_ptr(glm::mat4(1.0f)), 10.0f);

image

I think problem was in that because im use glm::inverse on view matrix, but i removed it what i got:
image

Any suggestions? I will be very grateful!

I think you swapped view and projection matrix in DrawGrid call.

Oh my God! And it really turned out that way! I really didn't notice it thank you! Lord....