nmwsharp / polyscope

A C++ & Python viewer for 3D data like meshes and point clouds
https://polyscope.run
MIT License
1.76k stars 190 forks source link

Overlaying Mouse-Drawn Sketches on 3D Objects #274

Closed ruanyyyyyyy closed 3 months ago

ruanyyyyyyy commented 3 months ago

Hi,

Thank you for this amazing repository. I'm trying to draw sketches by dragging the mouse and overlay them on the registered 3D objects. In Dear ImGUI, I use ImGui::GetWindowDrawList() to draw in a window. However, I'm unsure how to achieve this in Polyscope, as polyscope::imgui doesn't have the GetWindowDrawList function. Additionally, I want to draw directly on the 3D objects, not in a separate window. Any help would be greatly appreciated.

Thank you!

nmwsharp commented 3 months ago

Hi, there's no built-in support for anything like this. If you want to draw on the 3D scene, you could try using screenCoordsToWorldPosition() (docs) to get the location of the mouse, then constructing a polyscope CurveNetwork object from the sequence of positions to draw the line itself.

I've never done something like this with imgui, so I'm not sure exactly what it supports. I believe you can append to its drawlist even if your desired primitives are outside of a window. However, then they would live in screenspace rather than in 3D.

If Polyscope is missing / blocking any ImGui functions on the C++ side we should fix that. On the Python, not all ImGui functions are available in the bindings because we are adding them lazily, any useful missing ones can be easily added.

ruanyyyyyyy commented 3 months ago

Thank you for the thorough response to my issue. I found a way to work around it, but your detailed explanation and solution were still appreciated!