### Core Setup Source: https://context7.com/cedricguillemet/imguizmo/llms.txt Essential functions to call each frame for ImGuizmo initialization and rendering setup. This includes starting the frame, optionally setting a specific draw list, defining the gizmo drawing rectangle, and setting projection mode. ```APIDOC ## Core Setup `BeginFrame` and `SetRect` must be called every frame before any gizmo or helper is drawn; `SetDrawlist` optionally redirects rendering into an explicit `ImDrawList` (e.g. the foreground draw list). ```cpp // Per-frame initialization — call immediately after ImGui_ImplXXXX_NewFrame() ImGuizmo::BeginFrame(); // Optionally redirect gizmo rendering into a specific draw list // e.g. draw on top of everything: ImGuizmo::SetDrawlist(ImGui::GetForegroundDrawList()); // Define the rectangle in which gizmos are drawn (matches the window or viewport) ImGuio& io = ImGui::GetIO(); ImGuizmo::SetRect(0, 0, io.DisplaySize.x, io.DisplaySize.y); // When using ImGuizmo inside a specific ImGui window, match the window extents ImGui::Begin("Viewport"); ImGuizmo::SetDrawlist(); ImGuizmo::SetRect(ImGui::GetWindowPos().x, ImGui::GetWindowPos().y, ImGui::GetWindowWidth(), ImGui::GetWindowHeight()); // ... gizmo calls here ... ImGui::End(); // Toggle orthographic projection mode (default: false = perspective) ImGuizmo::SetOrthographic(false); // Share the ImGui context when ImGuizmo is compiled into a separate DLL ImGuizmo::SetImGuiContext(ImGui::GetCurrentContext()); ``` ``` -------------------------------- ### Install ImGuizmo with vcpkg Source: https://github.com/cedricguillemet/imguizmo/blob/master/README.md Use this command to install ImGuizmo via the vcpkg package manager. Ensure vcpkg is set up in your system. ```bash vcpkg install imguizmo ``` -------------------------------- ### ImGuizmo Core Setup and Initialization Source: https://context7.com/cedricguillemet/imguizmo/llms.txt Essential per-frame setup for ImGuizmo. Call BeginFrame after ImGui_XXXX_NewFrame(). Optionally set the draw list and the rectangle for gizmo rendering. Sharing the ImGui context is necessary when ImGuizmo is compiled into a separate DLL. ```cpp // Per-frame initialization — call immediately after ImGui_ImplXXXX_NewFrame() ImGuizmo::BeginFrame(); // Optionally redirect gizmo rendering into a specific draw list // e.g. draw on top of everything: ImGuizmo::SetDrawlist(ImGui::GetForegroundDrawList()); // Define the rectangle in which gizmos are drawn (matches the window or viewport) ImGuiIO& io = ImGui::GetIO(); ImGuizmo::SetRect(0, 0, io.DisplaySize.x, io.DisplaySize.y); // When using ImGuizmo inside a specific ImGui window, match the window extents ImGui::Begin("Viewport"); ImGuizmo::SetDrawlist(); ImGuizmo::SetRect(ImGui::GetWindowPos().x, ImGui::GetWindowPos().y, ImGui::GetWindowWidth(), ImGui::GetWindowHeight()); // ... gizmo calls here ... ImGui::End(); // Toggle orthographic projection mode (default: false = perspective) ImGuizmo::SetOrthographic(false); // Share the ImGui context when ImGuizmo is compiled into a separate DLL ImGuizmo::SetImGuiContext(ImGui::GetCurrentContext()); ``` -------------------------------- ### Implement ImGradient::Delegate for Custom Gradient Editing Source: https://context7.com/cedricguillemet/imguizmo/llms.txt Implement the ImGradient::Delegate interface to manage gradient points and define custom editing behavior. This example shows a basic implementation for linear interpolation. ```cpp struct MyGradient : public ImGradient::Delegate { std::vector points = { {0.0f, 0.0f, 0.0f, 0.0f}, // black at t=0 {1.0f, 1.0f, 1.0f, 1.0f} // white at t=1 }; int selection = -1; size_t GetPointCount() override { return points.size(); } ImVec4* GetPoints() override { return points.data(); } int EditPoint(int idx, ImVec4 v) override { points[idx] = v; return idx; } void AddPoint(ImVec4 v) override { points.push_back(v); } ImVec4 GetPoint(float t) override { // simple linear interpolation between nearest stops ImVec4 lo = points.front(), hi = points.back(); for (auto& p : points) { if (p.w <= t) lo = p; } for (auto& p : points) { if (p.w >= t) { hi = p; break; } } float f = (hi.w == lo.w) ? 0.f : (t-lo.w)/(hi.w-lo.w); return ImVec4(lo.x+(hi.x-lo.x)*f, lo.y+(hi.y-lo.y)*f, lo.z+(hi.z-lo.z)*f, t); } }; // --- per-frame usage --- static MyGradient grad; static int selection = -1; bool changed = ImGradient::Edit(grad, ImVec2(300, 30), selection); if (changed && selection >= 0) { ImVec4& sel = grad.points[selection]; ImGui::ColorEdit3("Stop color", &sel.x); ImGui::SliderFloat("Position", &sel.w, 0.f, 1.f); } ``` -------------------------------- ### Fetch and Include stb Library Source: https://github.com/cedricguillemet/imguizmo/blob/master/example/CMakeLists.txt This snippet uses FetchContent to download and make the stb library available. It then adds the stb source directory to the include paths for the imgui target. ```cmake include(FetchContent) FetchContent_Declare( stb GIT_REPOSITORY https://github.com/nothings/stb.git GIT_TAG master GIT_SHALLOW TRUE ) FetchContent_MakeAvailable(stb) target_include_directories(imgui PUBLIC ${stb_SOURCE_DIR}) ``` -------------------------------- ### Initialize and Configure ImVectorEditor for Path Editing Source: https://context7.com/cedricguillemet/imguizmo/llms.txt Set up the ImVectorEditor::Path data model, define anchors with handles, and configure editor settings like tools and canvas size. An UndoDelegate is also shown for managing edit states. ```cpp // Data model ImVectorEditor::Path path; path.closed = false; // Build a simple curve: three anchors, two with handles ImVectorEditor::Anchor a; a.position = {0,0}; a.handleOut = {70,-90}; a.hasHandleOut = true; ImVectorEditor::Anchor b; b.position = {180,0}; b.handleIn = {-70,-90}; b.hasHandleIn = true; b.handleOut = {60,90}; b.hasHandleOut = true; b.handleMode = ImVectorEditor::HandleMode::Free; ImVectorEditor::Anchor c; c.position = {320,120}; c.handleIn = {-60,90}; c.hasHandleIn = true; path.anchors = { a, b, c }; // Undo/redo delegate struct UndoDelegate : ImVectorEditor::Delegate { void BeginEdit(ImVectorEditor::EditKind k, int anchor) override { /* push undo state */ } void EndEdit() override { /* commit undo state */ } }; static UndoDelegate undoDelegate; // Configuration ImVectorEditor::Config config; config.tool = ImVectorEditor::Tool::Select; // or Tool::Pen config.canvasSize = ImVec2(0.f, 320.f); // height only; width fills available config.showGrid = true; config.delegate = &undoDelegate; // Apply host-object transform (e.g. from ImGuizmo) config.transform.objectTranslation = {50.f, 0.f}; config.transform.objectRotationRadians = 0.1f; config.transform.objectScale = {1.f, 1.f}; // Editor instance (persistent across frames — store statically or in your scene) static ImVectorEditor::Editor editor; ImVectorEditor::Result result = editor.Draw("##myPath", path, config); if (result.changed) { /* path was edited this frame */ } if (result.committed) { /* user finished a drag (safe to push undo) */ } // Apply pan/zoom feedback from the widget if (result.viewZoomFactor != 1.0f) { const float oldZ = config.transform.zoom; const float newZ = std::clamp(oldZ * result.viewZoomFactor, 0.25f, 4.0f); const ImVec2 c2 = result.viewZoomCenterCanvas; config.transform.pan = { c2.x - (c2.x - config.transform.pan.x) * (newZ/oldZ), c2.y - (c2.y - config.transform.pan.y) * (newZ/oldZ) }; config.transform.zoom = newZ; } config.transform.pan.x += result.viewPanDelta.x; config.transform.pan.y += result.viewPanDelta.y; // Anchor utilities ImVectorEditor::MakeCorner(path.anchors[0]); // remove handles ImVectorEditor::MakeMirrored(path.anchors[1]); // symmetric handles ImVectorEditor::MakeAligned(path.anchors[1]); // aligned-length handles ImVectorEditor::AddHandles(path.anchors[2], /*length=*/50.f); ImVectorEditor::DeleteHandles(path.anchors[0]); ImVectorEditor::ReversePath(path); ``` -------------------------------- ### Define Executable and Link Libraries Source: https://github.com/cedricguillemet/imguizmo/blob/master/example/CMakeLists.txt This snippet defines the main executable 'example-app' and links it with the 'imguizmo' library. It also adds the current source directory to the include paths for the executable. ```cmake add_executable(example-app main.cpp) target_link_libraries(example-app PRIVATE imguizmo) target_include_directories(example-app PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) ``` -------------------------------- ### Windows Platform Specific Linking Source: https://github.com/cedricguillemet/imguizmo/blob/master/example/CMakeLists.txt For Windows, this snippet links the example-app with necessary OpenGL and ImGui libraries. ```cmake if(WIN32) target_link_libraries(example-app PRIVATE opengl32 imm32 gdi32) endif() ``` -------------------------------- ### Initialize Gizmo Frame Source: https://github.com/cedricguillemet/imguizmo/blob/master/docs/documentation.md Call BeginFrame once per frame after ImGui_XXXX_NewFrame() to initialize the gizmo system. ```cpp ImGuizmo::BeginFrame(); ``` -------------------------------- ### BeginFrame Source: https://github.com/cedricguillemet/imguizmo/blob/master/docs/documentation.md Call BeginFrame once per frame, right after ImGui_XXXX_NewFrame(). ```APIDOC ## BeginFrame ### Description Call `BeginFrame` once per frame, right after `ImGui_XXXX_NewFrame()`. ### Method ```cpp ImGuizmo::BeginFrame(); ``` ``` -------------------------------- ### Manipulate Source: https://github.com/cedricguillemet/imguizmo/blob/master/docs/documentation.md Draws and handles a gizmo for the given matrix. Requires view and projection matrices. The matrix parameter is both input and output: it defines where the gizmo is drawn and is updated when the user interacts with it. deltaMatrix is optional and receives the incremental transform. snap points to a float[3] for translation snapping, or a single float for rotation or scale snapping. Snap angles are in degrees. ```APIDOC ## Manipulate ### Description Draws and handles a gizmo for the given matrix. Requires view and projection matrices. The `matrix` parameter is both input and output: it defines where the gizmo is drawn and is updated when the user interacts with it. `deltaMatrix` is optional and receives the incremental transform. `snap` points to a `float[3]` for translation snapping, or a single `float` for rotation or scale snapping. Snap angles are in degrees. > **Note:** Both finite and infinite far plane projection matrices are supported. Left-handed and right-handed coordinate systems are both supported — ImGuizmo derives its behavior from the matrices you provide. ### Method ```cpp enum OPERATION { TRANSLATE, ROTATE, SCALE }; enum MODE { LOCAL, WORLD }; void Manipulate(const float* view, const float* projection, OPERATION operation, MODE mode, float* matrix, float* deltaMatrix = 0, float* snap = 0); ``` ``` -------------------------------- ### Customize ImGuizmo Style and Colors Source: https://context7.com/cedricguillemet/imguizmo/llms.txt Modify the global Style struct to control gizmo visual properties like line thicknesses, arrow sizes, and colors. Use `ImGuizmo::AllowAxisFlip` and `ImGuizmo::SetGizmoSizeClipSpace` to adjust gizmo behavior and visibility. ```cpp ImGuizmo::Style& style = ImGuizmo::GetStyle(); // Line thicknesses style.TranslationLineThickness = 3.0f; style.TranslationLineArrowSize = 6.0f; style.RotationLineThickness = 2.0f; style.RotationOuterLineThickness = 3.0f; style.ScaleLineThickness = 3.0f; style.ScaleLineCircleSize = 6.0f; style.HatchedAxisLineThickness = 0.0f; // 0 = no hatching style.CenterCircleSize = 6.0f; // Colors (indexed by ImGuizmo::COLOR enum) style.Colors[ImGuizmo::DIRECTION_X] = ImVec4(0.858f, 0.243f, 0.113f, 0.93f); style.Colors[ImGuizmo::DIRECTION_Y] = ImVec4(0.375f, 0.820f, 0.070f, 0.93f); style.Colors[ImGuizmo::DIRECTION_Z] = ImVec4(0.227f, 0.478f, 0.972f, 0.93f); style.Colors[ImGuizmo::SELECTION] = ImVec4(1.0f, 0.6f, 0.1f, 0.8f); style.Colors[ImGuizmo::INACTIVE] = ImVec4(0.6f, 0.6f, 0.6f, 0.6f); // Axis and plane visibility limits ImGuizmo::AllowAxisFlip(true); // flip axis for better visibility (default: true) ImGuizmo::SetGizmoSizeClipSpace(0.1f); // gizmo size relative to clip space ImGuizmo::SetAxisLimit(0.02f); // hide axis below this dot-product threshold ImGuizmo::SetPlaneLimit(0.2f); // hide plane below this threshold ImGuizmo::SetAxisMask(false, false, false); // true = permanently hide that axis ``` -------------------------------- ### Implement ImSequencer Timeline Editor Source: https://context7.com/cedricguillemet/imguizmo/llms.txt Create a custom `SequenceInterface` to manage timeline items, frame ranges, and drawing. Use the `ImSequencer::Sequencer` function to render an editable timeline with options for editing start/end times, adding/deleting items, and frame manipulation. ```cpp struct MySequence : public ImSequencer::SequenceInterface { int mFrameMin = 0, mFrameMax = 200; struct Item { int type, start, end; bool expanded; }; std::vector items = { { 0, 10, 30, false }, { 1, 20, 80, false }, { 2, 90, 150, false } }; static constexpr const char* typeNames[] = { "Camera", "Music", "Effect" }; int GetFrameMin() const override { return mFrameMin; } int GetFrameMax() const override { return mFrameMax; } int GetItemCount() const override { return (int)items.size(); } int GetItemTypeCount() const override { return 3; } const char* GetItemTypeName(int i) const override { return typeNames[i]; } const char* GetItemLabel(int i) const override { return typeNames[items[i].type]; } void Get(int i, int** start, int** end, int* type, unsigned int* color) override { if (start) *start = &items[i].start; if (end) *end = &items[i].end; if (type) *type = items[i].type; if (color) *color = 0xFFAA8080; } void Add(int type) override { items.push_back({ type, 0, 10, false }); } void Del(int i) override { items.erase(items.begin() + i); } }; // --- per-frame usage --- static MySequence seq; static int currentFrame = 0; static int firstFrame = 0; static int selectedEntry = -1; static bool expanded = true; bool selChanged = ImSequencer::Sequencer( &seq, ¤tFrame, &expanded, &selectedEntry, &firstFrame, ImSequencer::SEQUENCER_EDIT_STARTEND | ImSequencer::SEQUENCER_ADD | ImSequencer::SEQUENCER_DEL | ImSequencer::SEQUENCER_COPYPASTE | ImSequencer::SEQUENCER_CHANGE_FRAME ); if (selChanged && selectedEntry >= 0) ImGui::Text("Selected: %s", MySequence::typeNames[seq.items[selectedEntry].type]); ``` -------------------------------- ### ImGuizmo Handle Queries Source: https://context7.com/cedricguillemet/imguizmo/llms.txt Queries the type of handle currently being hovered or actively dragged, useful for custom interactions. ```APIDOC ## ImGuizmo Handle Queries (MOVETYPE) Query which handle is hovered or actively dragged — useful for custom highlighting or input filtering. ```cpp ImGuizmo::MOVETYPE hovered = ImGuizmo::GetHoveredHandleType(); ImGuizmo::MOVETYPE active = ImGuizmo::GetActiveHandleType(); switch (active) { case ImGuizmo::MT_MOVE_X: ImGui::Text("Dragging X axis"); break; case ImGuizmo::MT_MOVE_XY: ImGui::Text("Dragging XY plane"); break; case ImGuizmo::MT_ROTATE_Y: ImGui::Text("Rotating around Y"); break; case ImGuizmo::MT_SCALE_XYZ: ImGui::Text("Uniform scale"); break; case ImGuizmo::MT_NONE: /* nothing active */ break; default: ImGui::Text("Other handle active"); break; } // Check if mouse is within pixelRadius of a world-space point float worldPos[3] = { 0.0f, 1.0f, 0.0f }; if (ImGuizmo::IsOver(worldPos, 8.0f)) ImGui::Text("Mouse near world point"); ``` ``` -------------------------------- ### ImGuizmo::DrawGrid / DrawGridCustom / DrawGridCustomColor Source: https://context7.com/cedricguillemet/imguizmo/llms.txt Renders a world-space reference grid aligned to a given matrix, with options for customization. ```APIDOC ## ImGuizmo::DrawGrid / DrawGridCustom / DrawGridCustomColor ### Description Renders a world-space reference grid aligned to the given matrix. `DrawGridCustom` and `DrawGridCustomColor` add control over major-line stepping, subdivision, and per-line-type color. ### ImGuizmo::DrawGrid ```cpp void ImGuizmo::DrawGrid( const float cameraView[16], const float cameraProjection[16], const float gridMatrix[16], float gridSize ); ``` #### Parameters - **cameraView** (const float[16]) - Camera view matrix. - **cameraProjection** (const float[16]) - Camera projection matrix. - **gridMatrix** (const float[16]) - The matrix defining the grid's orientation and position. - **gridSize** (float) - The radius of the grid. ### ImGuizmo::DrawGridCustom ```cpp void ImGuizmo::DrawGridCustom( const float cameraView[16], const float cameraProjection[16], const float gridMatrix[16], float gridSize, float majorStep, int subdivision ); ``` #### Parameters - **cameraView** (const float[16]) - Camera view matrix. - **cameraProjection** (const float[16]) - Camera projection matrix. - **gridMatrix** (const float[16]) - The matrix defining the grid's orientation and position. - **gridSize** (float) - The radius of the grid. - **majorStep** (float) - The distance between major lines. - **subdivision** (int) - The number of subdivisions between major lines. ### ImGuizmo::DrawGridCustomColor ```cpp void ImGuizmo::DrawGridCustomColor( const float cameraView[16], const float cameraProjection[16], const float gridMatrix[16], float gridSize, float majorStep, int subdivision, ImU32 majorColor, ImU32 minorColor, ImU32 centerColor ); ``` #### Parameters - **cameraView** (const float[16]) - Camera view matrix. - **cameraProjection** (const float[16]) - Camera projection matrix. - **gridMatrix** (const float[16]) - The matrix defining the grid's orientation and position. - **gridSize** (float) - The radius of the grid. - **majorStep** (float) - The distance between major lines. - **subdivision** (int) - The number of subdivisions between major lines. - **majorColor** (ImU32) - Color for major grid lines (ABGR). - **minorColor** (ImU32) - Color for minor grid lines (ABGR). - **centerColor** (ImU32) - Color for the center lines (ABGR). ### Usage Example ```cpp const float identityMatrix[16] = { 1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1 }; // Simple uniform grid (100-unit radius) ImGuizmo::DrawGrid(cameraView, cameraProjection, identityMatrix, 100.0f); // Grid with major lines every 10 units, 5 subdivisions between them ImGuizmo::DrawGridCustom(cameraView, cameraProjection, identityMatrix, 100.0f, // gridSize 10.0f, // majorStep 5 // subdivision ); // Full color control ImGuizmo::DrawGridCustomColor( cameraView, cameraProjection, identityMatrix, 100.0f, 10.0f, 5, IM_COL32(255, 255, 255, 60), // major lines IM_COL32(255, 255, 255, 20), // minor lines IM_COL32(255, 80, 80, 200) // center lines ); ``` ``` -------------------------------- ### Enable Source: https://github.com/cedricguillemet/imguizmo/blob/master/docs/documentation.md Enables or disables the gizmo. The state persists until the next call to Enable. When disabled, the gizmo is rendered with a semi-transparent gray color. ```APIDOC ## Enable ### Description Enables or disables the gizmo. The state persists until the next call to `Enable`. When disabled, the gizmo is rendered with a semi-transparent gray color. ### Method ```cpp void Enable(bool enable); ``` ``` -------------------------------- ### ImGuizmo::DrawGrid - World-Space Reference Grid Source: https://context7.com/cedricguillemet/imguizmo/llms.txt Renders a world-space reference grid aligned to a given matrix. Supports custom stepping, subdivisions, and colors for major, minor, and center lines. ```cpp const float identityMatrix[16] = { 1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1 }; ImGuizmo::DrawGrid(cameraView, cameraProjection, identityMatrix, 100.0f); ``` ```cpp ImGuizmo::DrawGridCustom(cameraView, cameraProjection, identityMatrix, 100.0f, 10.0f, 5 ); ``` ```cpp ImGuizmo::DrawGridCustomColor( cameraView, cameraProjection, identityMatrix, 100.0f, 10.0f, 5, IM_COL32(255, 255, 255, 60), IM_COL32(255, 255, 255, 20), IM_COL32(255, 80, 80, 200) ); ``` -------------------------------- ### Configure CMake with vcpkg Toolchain Source: https://github.com/cedricguillemet/imguizmo/blob/master/vcpkg-example/README.md Use this command to configure your CMake project with the vcpkg toolchain file, enabling automatic dependency management. ```bash mkdir build cd build cmake .. -DCMAKE_TOOLCHAIN_FILE=C:/dev/vcpkg/scripts/buildsystem/vcpkg.cmake ``` -------------------------------- ### IsUsing Source: https://github.com/cedricguillemet/imguizmo/blob/master/docs/documentation.md Returns true if the mouse is over the gizmo or if the gizmo is currently being moved. ```APIDOC ## IsUsing ### Description Returns `true` if the mouse is over the gizmo or if the gizmo is currently being moved. ### Method ```cpp bool IsUsing(); ``` ``` -------------------------------- ### ImZoomSlider: UV Pan/Zoom for Texture Preview Source: https://context7.com/cedricguillemet/imguizmo/llms.txt Demonstrates using ImZoomSlider for controlling the UV coordinates of a texture. Requires setting up min/max UV values and then calling the ImZoomSlider function for both vertical and horizontal axes. ```cpp // UV pan/zoom for a texture preview static float uMin = 0.4f, uMax = 0.6f; static float vMin = 0.4f, vMax = 0.6f; // Display texture clipped to the current UV window ImGui::Image((ImTextureID)(uint64_t)myTexture, ImVec2(800, 300), ImVec2(uMin, vMin), ImVec2(uMax, vMax)); // Vertical zoom slider (place immediately after the image) ImGui::SameLine(); ImGui::PushID(1); bool vChanged = ImZoomSlider::ImZoomSlider( 0.f, 1.f, // full range vMin, vMax, // current view window (in/out) 0.01f, // wheel sensitivity ImZoomSlider::ImGuiZoomSliderFlags_Vertical ); ImGui::PopID(); // Horizontal zoom slider ImGui::PushID(2); bool uChanged = ImZoomSlider::ImZoomSlider( 0.f, 1.f, uMin, uMax, 0.01f // default flags = horizontal + anchors + middle carets + wheel ); ImGui::PopID(); ``` -------------------------------- ### Query ImGuizmo Hovered and Active Handles Source: https://context7.com/cedricguillemet/imguizmo/llms.txt Determine which ImGuizmo handle is currently hovered or being dragged using `GetHoveredHandleType()` and `GetActiveHandleType()`. Use `IsOver()` to check if the mouse is near a world-space point. ```cpp ImGuizmo::MOVETYPE hovered = ImGuizmo::GetHoveredHandleType(); ImGuizmo::MOVETYPE active = ImGuizmo::GetActiveHandleType(); switch (active) { case ImGuizmo::MT_MOVE_X: ImGui::Text("Dragging X axis"); break; case ImGuizmo::MT_MOVE_XY: ImGui::Text("Dragging XY plane"); break; case ImGuizmo::MT_ROTATE_Y: ImGui::Text("Rotating around Y"); break; case ImGuizmo::MT_SCALE_XYZ: ImGui::Text("Uniform scale"); break; case ImGuizmo::MT_NONE: /* nothing active */ break; default: ImGui::Text("Other handle active"); break; } // Check if mouse is within pixelRadius of a world-space point float worldPos[3] = { 0.0f, 1.0f, 0.0f }; if (ImGuizmo::IsOver(worldPos, 8.0f)) ImGui::Text("Mouse near world point"); ``` -------------------------------- ### ImGuizmo::DrawCubes / DrawAxes - Debug Visualization Source: https://context7.com/cedricguillemet/imguizmo/llms.txt Helper functions for debug visualization. DrawCubes renders face-colored cubes, and DrawAxes renders XYZ axis tripods. Both support batched rendering of multiple matrices. ```cpp float objectMatrices[4][16] = { /* four 4×4 matrices */ }; ImGuizmo::DrawCubes(cameraView, cameraProjection, &objectMatrices[0][0], 4 ); ``` ```cpp ImGuizmo::DrawAxes(cameraView, cameraProjection, &objectMatrices[0][0], 4); ``` -------------------------------- ### ImGuizmo::DrawCubes / DrawAxes Source: https://context7.com/cedricguillemet/imguizmo/llms.txt Debug visualization helpers to render cubes or axes, supporting batched rendering. ```APIDOC ## ImGuizmo::DrawCubes / DrawAxes ### Description Debug-visualization helpers. `DrawCubes` renders face-colored cubes (face color = face normal direction); `DrawAxes` renders XYZ axis tripods — both support batched rendering of multiple matrices at once. ### ImGuizmo::DrawCubes ```cpp void ImGuizmo::DrawCubes( const float cameraView[16], const float cameraProjection[16], const float objectMatrices[][16], int count ); ``` #### Parameters - **cameraView** (const float[16]) - Camera view matrix. - **cameraProjection** (const float[16]) - Camera projection matrix. - **objectMatrices** (const float[][16]) - Array of 4x4 matrices for the cubes. - **count** (int) - The number of matrices in the array. ### ImGuizmo::DrawAxes ```cpp void ImGuizmo::DrawAxes( const float cameraView[16], const float cameraProjection[16], const float objectMatrices[][16], int count ); ``` #### Parameters - **cameraView** (const float[16]) - Camera view matrix. - **cameraProjection** (const float[16]) - Camera projection matrix. - **objectMatrices** (const float[][16]) - Array of 4x4 matrices for the axes. - **count** (int) - The number of matrices in the array. ### Usage Example ```cpp float objectMatrices[4][16] = { /* four 4x4 matrices */ }; // Render 4 debug cubes ImGuizmo::DrawCubes(cameraView, cameraProjection, &objectMatrices[0][0], 4 /*count*/); // Render axis tripods for the same matrices ImGuizmo::DrawAxes(cameraView, cameraProjection, &objectMatrices[0][0], 4); ``` ``` -------------------------------- ### ImGuizmo Style and Color Customization Source: https://context7.com/cedricguillemet/imguizmo/llms.txt Allows customization of gizmo visual properties like line thicknesses, colors, and visibility limits. ```APIDOC ## ImGuizmo::Style and Color Customization `GetStyle()` returns a reference to the global `Style` struct that controls all gizmo visual properties. Modify it once during setup or at any time to change the appearance. ```cpp ImGuizmo::Style& style = ImGuizmo::GetStyle(); // Line thicknesses style.TranslationLineThickness = 3.0f; style.TranslationLineArrowSize = 6.0f; style.RotationLineThickness = 2.0f; style.RotationOuterLineThickness = 3.0f; style.ScaleLineThickness = 3.0f; style.ScaleLineCircleSize = 6.0f; style.HatchedAxisLineThickness = 0.0f; // 0 = no hatching style.CenterCircleSize = 6.0f; // Colors (indexed by ImGuizmo::COLOR enum) style.Colors[ImGuizmo::DIRECTION_X] = ImVec4(0.858f, 0.243f, 0.113f, 0.93f); style.Colors[ImGuizmo::DIRECTION_Y] = ImVec4(0.375f, 0.820f, 0.070f, 0.93f); style.Colors[ImGuizmo::DIRECTION_Z] = ImVec4(0.227f, 0.478f, 0.972f, 0.93f); style.Colors[ImGuizmo::SELECTION] = ImVec4(1.0f, 0.6f, 0.1f, 0.8f); style.Colors[ImGuizmo::INACTIVE] = ImVec4(0.6f, 0.6f, 0.6f, 0.6f); // Axis and plane visibility limits ImGuizmo::AllowAxisFlip(true); // flip axis for better visibility (default: true) ImGuizmo::SetGizmoSizeClipSpace(0.1f); // gizmo size relative to clip space ImGuizmo::SetAxisLimit(0.02f); // hide axis below this dot-product threshold ImGuizmo::SetPlaneLimit(0.2f); // hide plane below this threshold ImGuizmo::SetAxisMask(false, false, false); // true = permanently hide that axis ``` ``` -------------------------------- ### ImLightRig::Edit: Light Rig Editor Source: https://context7.com/cedricguillemet/imguizmo/llms.txt Renders a 2D circular canvas for editing light rig properties. Lights are represented as colored dots, and their positions can be adjusted by dragging. Returns the index of the selected light for further editing. ```cpp static ImLightRig::Light lights[] = { // r, g, b, intensity, x, y { 1.0f, 0.3f, 0.1f, 1.0f, 0.5f, 0.5f }, // warm key { 0.3f, 1.0f, 0.1f, 0.8f, -0.5f, 0.5f }, // green fill { 0.1f, 0.3f, 1.0f, 0.6f, -0.5f, -0.5f }, // blue back }; static int lightCount = 3; static int selectedIdx = -1; // Draw the rig widget (200×200 pixels) selectedIdx = ImLightRig::Edit(lights, lightCount, selectedIdx, ImVec2(200, 200)); // Edit selected light properties if (selectedIdx >= 0 && selectedIdx < lightCount) { auto& L = lights[selectedIdx]; ImGui::ColorEdit3("Color", &L.r); ImGui::SliderFloat("Intensity", &L.intensity, 0.f, 10.f); ImGui::Text("Position: %.2f, %.2f", L.x, L.y); } ``` -------------------------------- ### Use GraphEditor::Show Source: https://context7.com/cedricguillemet/imguizmo/llms.txt Per-frame usage of the GraphEditor. Requires a delegate instance, options, and view state. Buttons can be used to control the view state, such as fitting all or selected nodes. ```cpp // --- per-frame usage --- static MyDelegate delegate; static GraphEditor::Options options; // colors, grid, zoom limits, etc. static GraphEditor::ViewState viewState; // scroll + zoom (persisted across frames) static GraphEditor::FitOnScreen fit = GraphEditor::Fit_None; ImGui::Begin("Graph"); if (ImGui::Button("Fit All")) fit = GraphEditor::Fit_AllNodes; if (ImGui::Button("Fit Selected")) fit = GraphEditor::Fit_SelectedNodes; GraphEditor::Show(delegate, options, viewState, /*enabled=*/true, &fit); ImGui::End(); // Edit display options interactively GraphEditor::EditOptions(options); ``` -------------------------------- ### Manipulate Gizmo Source: https://github.com/cedricguillemet/imguizmo/blob/master/docs/documentation.md Draws and handles a gizmo for the given matrix, supporting translation, rotation, and scale operations in local or world modes. Requires view and projection matrices. The matrix parameter is updated by user interaction. DeltaMatrix receives incremental transforms, and snap points to optional snapping values. Supports both finite and infinite far plane projections, and derives coordinate system behavior from input matrices. ```cpp enum OPERATION { TRANSLATE, ROTATE, SCALE }; enum MODE { LOCAL, WORLD }; void Manipulate(const float* view, const float* projection, OPERATION operation, MODE mode, float* matrix, float* deltaMatrix = 0, float* snap = 0); ``` -------------------------------- ### Check if Gizmo is Interactive Source: https://github.com/cedricguillemet/imguizmo/blob/master/docs/documentation.md IsOver returns true if the mouse cursor is over any gizmo control. IsUsing returns true if the mouse is over the gizmo or if it's currently being moved. ```cpp bool IsOver(); ``` ```cpp bool IsUsing(); ``` -------------------------------- ### VSCode CMake Configuration for vcpkg Source: https://github.com/cedricguillemet/imguizmo/blob/master/vcpkg-example/README.md Add this JSON configuration to your VSCode .vscode/settings.json file to automatically include the vcpkg toolchain file during CMake configuration. ```json { "cmake.configureArgs": [ "-DCMAKE_TOOLCHAIN_FILE=C:\\dev\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake" ] } ``` -------------------------------- ### Edit 3D Object Transform with ImGuizmo Source: https://github.com/cedricguillemet/imguizmo/blob/master/docs/documentation.md This C++ snippet shows how to use ImGuizmo to edit the transformation matrix of a 3D object. It allows switching between translate, rotate, and scale operations, and supports local or world space manipulation. Snap functionality for translation, rotation, and scale can be enabled and configured. ```cpp void EditTransform(float* cameraView, float* cameraProjection, float* matrix) { static ImGuizmo::OPERATION mCurrentGizmoOperation(ImGuizmo::ROTATE); static ImGuizmo::MODE mCurrentGizmoMode(ImGuizmo::WORLD); if (ImGui::IsKeyPressed(ImGuiKey_T)) mCurrentGizmoOperation = ImGuizmo::TRANSLATE; if (ImGui::IsKeyPressed(ImGuiKey_E)) mCurrentGizmoOperation = ImGuizmo::ROTATE; if (ImGui::IsKeyPressed(ImGuiKey_R)) mCurrentGizmoOperation = ImGuizmo::SCALE; if (ImGui::RadioButton("Translate", mCurrentGizmoOperation == ImGuizmo::TRANSLATE)) mCurrentGizmoOperation = ImGuizmo::TRANSLATE; ImGui::SameLine(); if (ImGui::RadioButton("Rotate", mCurrentGizmoOperation == ImGuizmo::ROTATE)) mCurrentGizmoOperation = ImGuizmo::ROTATE; ImGui::SameLine(); if (ImGui::RadioButton("Scale", mCurrentGizmoOperation == ImGuizmo::SCALE)) mCurrentGizmoOperation = ImGuizmo::SCALE; float matrixTranslation[3], matrixRotation[3], matrixScale[3]; ImGuizmo::DecomposeMatrixToComponents(matrix, matrixTranslation, matrixRotation, matrixScale); ImGui::InputFloat3("Tr", matrixTranslation); ImGui::InputFloat3("Rt", matrixRotation); ImGui::InputFloat3("Sc", matrixScale); ImGuizmo::RecomposeMatrixFromComponents(matrixTranslation, matrixRotation, matrixScale, matrix); if (mCurrentGizmoOperation != ImGuizmo::SCALE) { if (ImGui::RadioButton("Local", mCurrentGizmoMode == ImGuizmo::LOCAL)) mCurrentGizmoMode = ImGuizmo::LOCAL; ImGui::SameLine(); if (ImGui::RadioButton("World", mCurrentGizmoMode == ImGuizmo::WORLD)) mCurrentGizmoMode = ImGuizmo::WORLD; } static bool useSnap(false); if (ImGui::IsKeyPressed(ImGuiKey_S)) useSnap = !useSnap; ImGui::Checkbox("##useSnap", &useSnap); ImGui::SameLine(); vec_t snap; switch (mCurrentGizmoOperation) { case ImGuizmo::TRANSLATE: snap = config.mSnapTranslation; ImGui::InputFloat3("Snap", &snap.x); break; case ImGuizmo::ROTATE: snap = config.mSnapRotation; ImGui::InputFloat("Angle Snap", &snap.x); break; case ImGuizmo::SCALE: snap = config.mSnapScale; ImGui::InputFloat("Scale Snap", &snap.x); break; default: break; } ImGuiIO& io = ImGui::GetIO(); ImGuizmo::SetRect(0, 0, io.DisplaySize.x, io.DisplaySize.y); ImGuizmo::Manipulate(cameraView, cameraProjection, mCurrentGizmoOperation, mCurrentGizmoMode, matrix, NULL, useSnap ? &snap.x : NULL); } ``` -------------------------------- ### Linux Platform Specific Linking Source: https://github.com/cedricguillemet/imguizmo/blob/master/example/CMakeLists.txt For Linux (Unix), this snippet finds and links against the X11 and OpenGL libraries, as well as the dynamic linking library. ```cmake elseif(UNIX) find_package(X11 REQUIRED) find_package(OpenGL REQUIRED) target_link_libraries(example-app PRIVATE X11::X11 OpenGL::GL ${CMAKE_DL_LIBS}) endif() ``` -------------------------------- ### Enable/Disable Gizmo Source: https://github.com/cedricguillemet/imguizmo/blob/master/docs/documentation.md Enables or disables the gizmo. When disabled, it is rendered with a semi-transparent gray color. The state persists until the next call. ```cpp void Enable(bool enable); ``` -------------------------------- ### ImSequencer::Sequencer Source: https://context7.com/cedricguillemet/imguizmo/llms.txt Renders and manages an editable timeline for multiple tracks, allowing for frame manipulation, item addition, deletion, and copying. ```APIDOC ## ImSequencer::Sequencer — Timeline Sequencer Renders an editable timeline for multiple tracks. The caller subclasses `SequenceInterface`, which provides frame range, item list, and optional custom per-item drawing. Returns `true` when a selection changes. ```cpp struct MySequence : public ImSequencer::SequenceInterface { int mFrameMin = 0, mFrameMax = 200; struct Item { int type, start, end; bool expanded; }; std::vector items = { { 0, 10, 30, false }, { 1, 20, 80, false }, { 2, 90, 150, false } }; static constexpr const char* typeNames[] = { "Camera", "Music", "Effect" }; int GetFrameMin() const override { return mFrameMin; } int GetFrameMax() const override { return mFrameMax; } int GetItemCount() const override { return (int)items.size(); } int GetItemTypeCount() const override { return 3; } const char* GetItemTypeName(int i) const override { return typeNames[i]; } const char* GetItemLabel(int i) const override { return typeNames[items[i].type]; } void Get(int i, int** start, int** end, int* type, unsigned int* color) override { if (start) *start = &items[i].start; if (end) *end = &items[i].end; if (type) *type = items[i].type; if (color) *color = 0xFFAA8080; } void Add(int type) override { items.push_back({ type, 0, 10, false }); } void Del(int i) override { items.erase(items.begin() + i); } }; // --- per-frame usage --- static MySequence seq; static int currentFrame = 0; static int firstFrame = 0; static int selectedEntry = -1; static bool expanded = true; bool selChanged = ImSequencer::Sequencer( &seq, ¤tFrame, &expanded, &selectedEntry, &firstFrame, ImSequencer::SEQUENCER_EDIT_STARTEND | ImSequencer::SEQUENCER_ADD | ImSequencer::SEQUENCER_DEL | ImSequencer::SEQUENCER_COPYPASTE | ImSequencer::SEQUENCER_CHANGE_FRAME ); if (selChanged && selectedEntry >= 0) ImGui::Text("Selected: %s", MySequence::typeNames[seq.items[selectedEntry].type]); ``` ```