Skip to content

[Feature] Gizmo Tool #159

@brenocq

Description

@brenocq

Feature description
This feature proposes adding a Gizmo Tool to implot3d, allowing users to intuitively manipulate data points or objects directly within the plot area. Instead of relying on external sliders or input fields, users can drag interactive handles to translate, rotate, or scale elements.

Key Requirements:

  • Modes: Support for Translation (arrows), Rotation (rings), and Scaling (cubes/bars).
  • 3D View: A full 3-axis gizmo is rendered when navigating in 3D.
  • 2D View: When the plot is in a 2D view mode (e.g., restricted to a plane or ImPlot3DFlags_GroundOnly), the gizmo should automatically adapt to a 2D version (e.g., hiding the Z-axis handles when viewing the XY plane).
  • Immediate Mode: The API should follow the immediate mode paradigm, taking pointers to position, rotation, and scale variables to update them in real-time.

Proposed API:

// Renders a gizmo and updates the transform values based on user input
bool PlotGizmo(const char* label_id, float* translation, float* rotation, float* scale, ImPlot3DGizmoFlags flags = 0);

Tasks

  • Public API (implot3d.h)
    • Define ImPlot3DGizmoFlags (e.g., Translate, Rotate, Scale, Local, World).
    • Declare the PlotGizmo function.
  • Rendering Logic (implot3d_gizmo.cpp)
    • Implement rendering primitives for gizmo axes (lines/arrows for translation, circles for rotation, blocks for scale).
    • Ensure gizmo renders on top of plot items (depth disable or end-of-frame rendering).
    • Implement logic to detect the current view state (plane_2d vs 3D) and hide irrelevant axes for the 2D view.
  • Interaction Logic (implot3d_gizmo.cpp)
    • Implement raycasting to detect mouse hovers over specific gizmo handles.
    • Calculate mouse delta projected onto the active transformation axis/plane.
    • Apply the calculated delta to the user's translation, rotation, or scale arrays.
  • Demo (implot3d_demo.cpp)
    • Create a demo tab "Gizmo" showing a simple meshes (e.g., cube, duck) that can be manipulated using the new tool.

Metadata

Metadata

Assignees

No one assigned

    Labels

    prio:mediumMedium prioritystatus:todoTask identified but not startedtype:featNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions