Skip to content

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

@bingbingmasdhg

Description

@bingbingmasdhg

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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions