Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

imguizmo (C++)

ImGuizmo: 3D gizmos to move, rotate and scale an object, a cube to orient the view, and small editors (curves, gradients, a sequencer).

The C++ API of ImGuizmo as it is bound to Python: the entries of the module imgui_bundle.imguizmo, in the same order, with their C++ signatures and the headers’ comments. From the stubs: the functions excluded from the bindings, the typedefs and the macros are absent.

ImGuizmo.h

Submodule im_guizmo

im_guizmo (struct)

im_guizmo::SetDrawlist
IMGUI_API void SetDrawlist(ImDrawList* drawlist = nullptr);

call inside your own window and before Manipulate() in order to draw gizmo to that window.
Or pass a specific ImDrawList to draw to (e.g. ImGui::GetForegroundDrawList()).

im_guizmo::BeginFrame
IMGUI_API void BeginFrame();
call BeginFrame right after ImGui_XXXX_NewFrame();
im_guizmo::SetImGuiContext
IMGUI_API void SetImGuiContext(ImGuiContext* ctx);

this is necessary because when imguizmo is compiled into a dll, and imgui into another globals are not shared between them.
More details at https://stackoverflow.com/questions/19373061/what-happens-to-global-and-static-variables-in-a-shared-library-when-it-is-dynam expose method to set imgui context

im_guizmo::IsOver
IMGUI_API bool IsOver();
IMGUI_API bool IsOver(OPERATION op);

return True if mouse cursor is over any gizmo control (axis, plan or screen component)

im_guizmo::IsUsing
IMGUI_API bool IsUsing();

return True if mouse IsOver or if the gizmo is in moving state

im_guizmo::IsUsingViewManipulate
IMGUI_API bool IsUsingViewManipulate();

return True if the view gizmo is in moving state

im_guizmo::IsViewManipulateHovered
IMGUI_API bool IsViewManipulateHovered();

only check if your mouse is over the view manipulator - no matter whether it’s active or not

im_guizmo::IsUsingAny
IMGUI_API bool IsUsingAny();

return True if any gizmo is in moving state

im_guizmo::Enable
IMGUI_API void Enable(bool enable);

enable/disable the gizmo. Stay in the state until next call to Enable. gizmo is rendered with gray half transparent color when disabled

im_guizmo::SetRect
IMGUI_API void SetRect(float x, float y, float width, float height);

helper functions for manualy editing translation/rotation/scale with an input float translation, rotation and scale float points to 3 floats each
Angles are in degrees (more suitable for human editing) example:

float matrixTranslation[3], matrixRotation[3], matrixScale[3];
ImGuizmo::DecomposeMatrixToComponents(gizmoMatrix.m16, matrixTranslation, matrixRotation, matrixScale);
ImGui::InputFloat3("Tr", matrixTranslation, 3);
ImGui::InputFloat3("Rt", matrixRotation, 3);
ImGui::InputFloat3("Sc", matrixScale, 3);
ImGuizmo::RecomposeMatrixFromComponents(matrixTranslation, matrixRotation, matrixScale, gizmoMatrix.m16);

These functions have some numerical stability issues for now. Use with caution.

im_guizmo::SetOrthographic
IMGUI_API void SetOrthographic(bool isOrthographic);

default is False

im_guizmo::OPERATION (enum)

call it when you want a gizmo
Needs view and projection matrices. matrix parameter is the source matrix (where will be gizmo be drawn) and might be transformed by the function. Return deltaMatrix is optional translation is applied in world space

MemberValue
TRANSLATE_X = (1u << 0)(1u << 0)
TRANSLATE_Y = (1u << 1)(1u << 1)
TRANSLATE_Z = (1u << 2)(1u << 2)
ROTATE_X = (1u << 3)(1u << 3)
ROTATE_Y = (1u << 4)(1u << 4)
ROTATE_Z = (1u << 5)(1u << 5)
ROTATE_SCREEN = (1u << 6)(1u << 6)
SCALE_X = (1u << 7)(1u << 7)
SCALE_Y = (1u << 8)(1u << 8)
SCALE_Z = (1u << 9)(1u << 9)
BOUNDS = (1u << 10)(1u << 10)
SCALE_XU = (1u << 11)(1u << 11)
SCALE_YU = (1u << 12)(1u << 12)
SCALE_ZU = (1u << 13)(1u << 13)
TRANSLATE = TRANSLATE_X | TRANSLATE_Y | TRANSLATE_ZOPERATION.translate_x | OPERATION.translate_y | OPERATION.translate_z
ROTATE = ROTATE_X | ROTATE_Y | ROTATE_Z | ROTATE_SCREENOPERATION.rotate_x | OPERATION.rotate_y | OPERATION.rotate_z | OPERATION.rotate_screen
SCALE = SCALE_X | SCALE_Y | SCALE_ZOPERATION.scale_x | OPERATION.scale_y | OPERATION.scale_z
SCALEU = SCALE_XU | SCALE_YU | SCALE_ZUOPERATION.scale_xu | OPERATION.scale_yu | OPERATION.scale_zuuniversal
UNIVERSAL = TRANSLATE | ROTATE | SCALEUOPERATION.translate | OPERATION.rotate | OPERATION.scaleu
im_guizmo::MODE (enum)
MemberValue
LOCAL0
WORLD1
im_guizmo::SetAlternativeWindow
IMGUI_API void SetAlternativeWindow(ImGuiWindow* window);
im_guizmo::PushID
IMGUI_API void PushID(const char* str_id);
IMGUI_API void PushID(const char* str_id_begin, const char* str_id_end);
IMGUI_API void PushID(const void* ptr_id);
IMGUI_API void PushID(int int_id);

push string into the ID stack (will hash string).

im_guizmo::PopID
IMGUI_API void PopID();

pop from the ID stack.

im_guizmo::GetID
IMGUI_API ImGuiID GetID(const char* str_id);
IMGUI_API ImGuiID GetID(const char* str_id_begin, const char* str_id_end);
IMGUI_API ImGuiID GetID(const void* ptr_id);

calculate unique ID (hash of whole ID stack + given parameter). e.g. if you want to query into ImGuiStorage yourself

im_guizmo::SetGizmoSizeClipSpace
IMGUI_API void SetGizmoSizeClipSpace(float value);
im_guizmo::MOVETYPE (enum)

Handle type used by the translate/rotate/scale gizmos.

MemberValue
MT_NONE0
MT_MOVE_X1
MT_MOVE_Y2
MT_MOVE_Z3
MT_MOVE_YZ4
MT_MOVE_ZX5
MT_MOVE_XY6
MT_MOVE_SCREEN7
MT_ROTATE_X8
MT_ROTATE_Y9
MT_ROTATE_Z10
MT_ROTATE_SCREEN11
MT_SCALE_X12
MT_SCALE_Y13
MT_SCALE_Z14
MT_SCALE_XYZ15
im_guizmo::GetActiveHandleType
IMGUI_API MOVETYPE GetActiveHandleType();

Returns which handle is actively being dragged, or MT_NONE.

im_guizmo::GetHoveredHandleType
IMGUI_API MOVETYPE GetHoveredHandleType();

Returns which handle is currently hovered, or MT_NONE.

im_guizmo::GetActiveMoveType
IMGUI_API MOVETYPE GetActiveMoveType();

Aliases matching the MOVETYPE enum name.

im_guizmo::GetHoveredMoveType
IMGUI_API MOVETYPE GetHoveredMoveType();
im_guizmo::AllowAxisFlip
IMGUI_API void AllowAxisFlip(bool value);

Allow axis to flip
When True (default), the guizmo axis flip for better visibility
When False, they always stay along the positive world/local axis

im_guizmo::SetAxisLimit
IMGUI_API void SetAxisLimit(float value);

Configure the limit where axis are hidden

im_guizmo::SetAxisMask
IMGUI_API void SetAxisMask(bool x, bool y, bool z);

Set an axis mask to permanently hide a given axis (True -> hidden, False -> shown)

im_guizmo::SetPlaneLimit
IMGUI_API void SetPlaneLimit(float value);

Configure the limit where planes are hiden

im_guizmo::COLOR (enum)
MemberValue
DIRECTION_X0directionColor[0]
DIRECTION_Y1directionColor[1]
DIRECTION_Z2directionColor[2]
PLANE_X3planeColor[0]
PLANE_Y4planeColor[1]
PLANE_Z5planeColor[2]
SELECTION6selectionColor
INACTIVE7inactiveColor
TRANSLATION_LINE8translationLineColor
SCALE_LINE9
ROTATION_USING_BORDER10
ROTATION_USING_FILL11
HATCHED_AXIS_LINES12
TEXT13
TEXT_SHADOW14
COUNT15
im_guizmo::Style (struct)
Member
float TranslationLineThickness;Thickness of lines for translation gizmo
float TranslationLineArrowSize;Size of arrow at the end of lines for translation gizmo
float RotationLineThickness;Thickness of lines for rotation gizmo
float RotationOuterLineThickness;Thickness of line surrounding the rotation gizmo
float ScaleLineThickness;Thickness of lines for scale gizmo
float ScaleLineCircleSize;Size of circle at the end of lines for scale gizmo
float HatchedAxisLineThickness;Thickness of hatched axis lines
float CenterCircleSize;Size of circle at the center of the translate/scale gizmo
im_guizmo::Style::Style
IMGUI_API Style();
im_guizmo::GetStyle
IMGUI_API Style& GetStyle();
}
im_guizmo::Matrix16 (struct)
Member
float values[16]{};ndarray[type=float, size=16] default:float()
im_guizmo::Matrix16::Matrix16
Matrix16();
explicit Matrix16(const std::array<float, 16>& v);
im_guizmo::Matrix6 (struct)
Member
float values[6]{};ndarray[type=float, size=6] default:float()
im_guizmo::Matrix6::Matrix6
Matrix6();
explicit Matrix6(const std::array<float, 6>& v);
im_guizmo::Matrix3 (struct)
Member
float values[3]{};ndarray[type=float, size=3] default:float()
im_guizmo::Matrix3::Matrix3
Matrix3();
explicit Matrix3(const std::array<float, 3>& v);
im_guizmo::MatrixComponents (struct)
Member
Matrix3 Translation;
Matrix3 Rotation;
Matrix3 Scale;
im_guizmo::DecomposeMatrixToComponents
IMGUI_API MatrixComponents DecomposeMatrixToComponents(const Matrix16 &matrix);

helper functions for manualy editing translation/rotation/scale with an input float translation, rotation and scale float points to 3 floats each
Angles are in degrees (more suitable for human editing) example:

float matrixTranslation[3], matrixRotation[3], matrixScale[3];
ImGuizmo::DecomposeMatrixToComponents(gizmoMatrix.m16, matrixTranslation, matrixRotation, matrixScale);
ImGui::InputFloat3("Tr", matrixTranslation, 3);
ImGui::InputFloat3("Rt", matrixRotation, 3);
ImGui::InputFloat3("Sc", matrixScale, 3);
ImGuizmo::RecomposeMatrixFromComponents(matrixTranslation, matrixRotation, matrixScale, gizmoMatrix.m16);

These functions have some numerical stability issues for now. Use with caution.

im_guizmo::RecomposeMatrixFromComponents
IMGUI_API Matrix16 RecomposeMatrixFromComponents(const MatrixComponents& matrixComponents);
im_guizmo::DrawCubes
IMGUI_API void DrawCubes(const Matrix16& view, const Matrix16& projection, const std::vector<Matrix16> & matrices);

Render a cube with face color corresponding to face normal. Usefull for debug/tests

im_guizmo::DrawGrid
IMGUI_API void DrawGrid(const Matrix16& view, const Matrix16& projection, const Matrix16& matrix, const float gridSize);
im_guizmo::Manipulate
IMGUI_API bool Manipulate( const Matrix16& view, const Matrix16& projection, OPERATION operation, MODE mode, Matrix16& object_matrix, // This matrix may be modified! Matrix16* delta_matrix = nullptr, std::optional<Matrix3> snap = std::nullopt, std::optional<Matrix6> local_bounds = std::nullopt, std::optional<Matrix3> bounds_snap = std::nullopt );

Manipulate: main API of ImGuizmo
Returns True if the objectMatrix has been modified

Mandatory input parameters:

Optional output parameter:

Optional input parameters:

im_guizmo::ViewManipulate
IMGUI_API void ViewManipulate( Matrix16& view, // This matrix may be modified! float length, ImVec2 position, ImVec2 size, ImU32 backgroundColor);
IMGUI_API void ViewManipulate( Matrix16& view, const Matrix16& projection, OPERATION operation, MODE mode, Matrix16& matrix, // !!! float length, ImVec2 position, ImVec2 size, ImU32 backgroundColor); }

Please note that this cubeview is patented by Autodesk : https://patents.google.com/patent/US7782319B2/en
It seems to be a defensive patent in the US. I don’t think it will bring troubles using it as other software are using the same mechanics. But just in case, you are now warned!

ViewManipulate may change the view parameter