class mrpt::imgui::CImGuiSceneView
Overview
Renders an mrpt::viz::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 mrpt::viz::COrbitCameraController cameraController; std::function<void()> onOverlayGui; std::function<void(float, float)> onLeftClick; // construction CImGuiSceneView(); CImGuiSceneView(const CImGuiSceneView&); CImGuiSceneView(CImGuiSceneView&&); // methods void setScene(const mrpt::viz::Scene::Ptr& scene); mrpt::viz::Scene::Ptr scene() const; void render(); void setBackgroundColor(float r, float g, float b, float a = 1.0f); CImGuiSceneView& operator = (const CImGuiSceneView&); CImGuiSceneView& operator = (CImGuiSceneView&&); };
Fields
mrpt::viz::COrbitCameraController cameraController
The orbit camera controller.
Use this to read/write azimuth, elevation, zoom distance, pointing-at position, and interaction sensitivities.
Example:
view.cameraController.setZoomDistance(20.0f); view.cameraController.setAzimuthDegrees(-135.0f); view.cameraController.orbitSensitivity = 0.5f;
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 without dragging.
Arguments: (pixel_x, pixel_y) in widget-local coordinates.
Methods
void setScene(const mrpt::viz::Scene::Ptr& scene)
Set the scene to render.
The caller retains ownership.
mrpt::viz::Scene::Ptr scene() const
Get the scene being rendered (may be nullptr).
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 override.
If never called, the scene’s own viewport background (typically a vertical gradient set up by mrpt::viz::Scene) is preserved.