Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does ImGuizmo only support Euler angles? I have encountered a problem with Gimbal lock, which is causing me a headache. I hope it can support quaternions in the future. #353

Open
bingbingmasdhg opened this issue Dec 10, 2024 · 1 comment

Comments

@bingbingmasdhg
Copy link

Does ImGuizmo only support Euler angles? I have encountered a problem with Gimbal lock, which is causing me a headache. I hope it can support quaternions in the future.
I tried to use quaternions to complete imguizmo, but unfortunately many of its functions only support vec3 and do not have quats, such as void DecomposeMatrixToComponents (const float * matrix, float * translation, float * rotation, float * scale);
void RecomposeMatrixFromComponents(const float *translation, const float *rotation, const float scale, float matrix);
If I use the Euler angles of vec3, I will encounter a very bad Gimbal lock problem, even if I use quaternions to store rotation information, it will become abnormal when using Manipulate. I hope it can support quaternions in the future. Although it may not be intuitive, it is the most scientific approach. thank you!

glm::mat4 modelMatrix = glm::toMat4(quaternion);
glm::mat4 viewMatrix = ...; // Your view matrix
glm::mat4 projectionMatrix = ...; // Your projection matrix
//Set operation mode, such as rotation
ImGuizmo::Operation operation = ImGuizmo::OPERATION::ROTATE;
//Set modes, such as local space
ImGuizmo::Mode mode = ImGuizmo::MODE::LOCAL;
bool changed = ImGuizmo::Manipulate(viewMatrix.data(), projectionMatrix.data(), modelMatrix.data(), operation, mode);
if (changed) {
quaternion = glm::quat(modelMatrix); // Update Quaternion
}

@CedricGuillemet
Copy link
Owner

imguizmo works on matrices and not Euler angles. So you can extract quaternion from delta matrix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants