Class CImGuiSceneView

Class Documentation

class CImGuiSceneView

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.

Camera control

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;

Callbacks

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.

Scene access

inline void setScene(const mrpt::viz::Scene::Ptr &scene)

Set the scene to render. The caller retains ownership.

inline mrpt::viz::Scene::Ptr scene() const

Get the scene being rendered (may be nullptr).

Rendering

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.

Appearance

inline void setBackgroundColor(float r, float g, float b, float a = 1.0f)

Background color (default: dark gray 0.3, 0.3, 0.3)

Public Functions

CImGuiSceneView()
~CImGuiSceneView()
CImGuiSceneView(const CImGuiSceneView&) = delete
CImGuiSceneView &operator=(const CImGuiSceneView&) = delete
CImGuiSceneView(CImGuiSceneView&&) = delete
CImGuiSceneView &operator=(CImGuiSceneView&&) = delete