class mrpt::imgui::CImGuiSceneView
Overview
Renders an mrpt::opengl::Scene into an OpenGL FBO texture and displays it as a Dear ImGui image widget, with built-in orbit camera controls.
Usage:
// In your ImGui frame loop: if (ImGui::Begin("3D View")) { sceneView.render(); } ImGui::End();
The class assumes an OpenGL 3.3+ context is already current (as provided by the Dear ImGui GLFW/SDL backend). No EGL context is created.
#include <mrpt/imgui/CImGuiSceneView.h> class CImGuiSceneView { public: // fields std::function<void()> onOverlayGui; std::function<void(float, float)> onLeftClick; // construction CImGuiSceneView(); CImGuiSceneView(const CImGuiSceneView&); CImGuiSceneView(CImGuiSceneView&&); // methods void setScene(const mrpt::opengl::Scene::Ptr& scene); mrpt::opengl::Scene::Ptr scene() const; mrpt::opengl::CCamera& camera(); const mrpt::opengl::CCamera& camera() const; void render(); void setBackgroundColor(float r, float g, float b, float a = 1.0f); void setOrbitSensitivity(float s); void setPanSensitivity(float s); void setZoomSensitivity(float s); CImGuiSceneView& operator = (const CImGuiSceneView&); CImGuiSceneView& operator = (CImGuiSceneView&&); };
Fields
std::function<void()> onOverlayGui
Called after the MRPT scene is rendered but before ImGui::Image().
Useful for drawing overlay ImGui widgets on top.
std::function<void(float, float)> onLeftClick
Called when the user left-clicks on the 3D view.
Arguments: (pixel_x, pixel_y) in widget-local coordinates.
Methods
void setScene(const mrpt::opengl::Scene::Ptr& scene)
Set the scene to render.
The caller retains ownership.
mrpt::opengl::Scene::Ptr scene() const
Get the scene being rendered (may be nullptr).
mrpt::opengl::CCamera& camera()
Direct access to the camera used for rendering.
Modify orbit parameters (azimuth, elevation, distance, pointing-at) directly through this reference.
void render()
Renders the scene into the FBO and displays it via ImGui::Image().
Call this inside an ImGui window (between Begin/End).
The widget fills the available content region. If the region size changed since the last call, the FBO is recreated automatically.
void setBackgroundColor(float r, float g, float b, float a = 1.0f)
Background color (default: dark gray 0.3, 0.3, 0.3)