[mrpt-opengl]

Visualization helpers for 3D rendering of all kind of primitives

Library mrpt-opengl

This library is part of MRPT and can be installed in Debian-based systems with:

sudo apt install libmrpt-opengl-dev

Read also how to import MRPT into your CMake scripts.

This library includes several data classes that represent objects that can be inserted into a 3D scene, which can be then rendered or streamed to disk or whatever.

A good starting point to explore this library is the base class for all the 3D objects: mrpt::opengl::CRenderizable

A 3D scene is represented by an object of the type mrpt::opengl::Scene, which in turn can contain one or several “viewports” in such a way that the rendering area is divided into several spaces, each displaying the same or different objects. See the tutorial: Tutorial: 3D scenes

See the full list of classes in mrpt::opengl.

Next follows a list with the preview of most rendering primitive classes:

Also, pose PDF classes can be converted into OpenGL objects with CSetOfObjects::posePDF2opengl() :

Note: The following extra OpenGL classes are provided by other libraries:

Library contents

// typedefs

typedef Scene mrpt::opengl::COpenGLScene;
typedef Viewport mrpt::opengl::COpenGLViewport;
typedef std::map<shader_id_t, std::multimap<float, RenderQueueElement>> mrpt::opengl::RenderQueue;
typedef uint8_t mrpt::opengl::shader_id_t;

// enums

enum mrpt::opengl::CUBE_TEXTURE_FACE;
enum mrpt::opengl::TCullFace;

// structs

struct mrpt::opengl::FrameBufferBinding;
struct mrpt::opengl::RenderQueueElement;
struct mrpt::opengl::RenderQueueStats;
struct mrpt::opengl::T2DTextData;
struct mrpt::opengl::TLightParameters;
struct mrpt::opengl::TRenderMatrices;
struct mrpt::opengl::TTriangle;
struct mrpt::opengl::texture_name_unit_t;

// classes

class mrpt::opengl::Buffer;
class mrpt::opengl::CArrow;
class mrpt::opengl::CAssimpModel;
class mrpt::opengl::CAxis;
class mrpt::opengl::CBox;
class mrpt::opengl::CCamera;
class mrpt::opengl::CColorBar;
class mrpt::opengl::CCylinder;
class mrpt::opengl::CDisk;
class mrpt::opengl::CEllipsoid2D;
class mrpt::opengl::CEllipsoid3D;
class mrpt::opengl::CEllipsoidInverseDepth2D;
class mrpt::opengl::CEllipsoidInverseDepth3D;
class mrpt::opengl::CEllipsoidRangeBearing2D;
class mrpt::opengl::CFBORender;
class mrpt::opengl::CFrustum;

template <int DIM>
class mrpt::opengl::CGeneralizedEllipsoidTemplate;

class mrpt::opengl::CGridPlaneXY;
class mrpt::opengl::CGridPlaneXZ;
class mrpt::opengl::CMesh;
class mrpt::opengl::CMesh3D;
class mrpt::opengl::CMeshFast;
class mrpt::opengl::COctoMapVoxels;

template <class Derived>
class mrpt::opengl::COctreePointRenderer;

class mrpt::opengl::CPointCloud;
class mrpt::opengl::CPointCloudColoured;
class mrpt::opengl::CPolyhedron;
class mrpt::opengl::CRenderizable;
class mrpt::opengl::CRenderizableShaderPoints;
class mrpt::opengl::CRenderizableShaderText;
class mrpt::opengl::CRenderizableShaderTexturedTriangles;
class mrpt::opengl::CRenderizableShaderTriangles;
class mrpt::opengl::CRenderizableShaderWireFrame;
class mrpt::opengl::CSetOfLines;
class mrpt::opengl::CSetOfObjects;
class mrpt::opengl::CSetOfTexturedTriangles;
class mrpt::opengl::CSetOfTriangles;
class mrpt::opengl::CSimpleLine;
class mrpt::opengl::CSkyBox;
class mrpt::opengl::CSphere;
class mrpt::opengl::CText;
class mrpt::opengl::CText3D;
class mrpt::opengl::CTextMessageCapable;
class mrpt::opengl::CTexturedPlane;
class mrpt::opengl::CVectorField2D;
class mrpt::opengl::CVectorField3D;
class mrpt::opengl::FrameBuffer;

template <int DEPTH_LUT_NUM_BITS = 18>
class mrpt::opengl::OpenGLDepth2LinearLUTs;

class mrpt::opengl::PLY_Importer;
class mrpt::opengl::Program;
class mrpt::opengl::Scene;
class mrpt::opengl::Shader;
class mrpt::opengl::Texture;
class mrpt::opengl::VertexArrayObject;
class mrpt::opengl::Viewport;
class mrpt::opengl::Visualizable;

// global functions

void mrpt::global_settings::OCTREE_RENDER_MAX_DENSITY_POINTS_PER_SQPIXEL(float value);
size_t mrpt::global_settings::OCTREE_RENDER_MAX_POINTS_PER_NODE();
Program::Ptr mrpt::opengl::LoadDefaultShader(const shader_id_t id);
void mrpt::opengl::registerAllClasses_mrpt_opengl();

std::tuple<double, bool, bool> mrpt::opengl::depthAndVisibleInView(
    const CRenderizable* obj,
    const mrpt::opengl::TRenderMatrices& objState,
    const bool skipCullChecks
    );

template <class GRAPH_T>
CSetOfObjects::Ptr mrpt::opengl::graph_tools::graph_visualize(const GRAPH_T& g, const mrpt::containers::yaml& extra_params = {});

Typedefs

typedef Scene mrpt::opengl::COpenGLScene

Alias for Scene for backwards compatibility with MRPT <2.7.0.

typedef Viewport mrpt::opengl::COpenGLViewport

Alias for Scene for backwards compatibility with MRPT <2.7.0.

typedef std::map<shader_id_t, std::multimap<float, RenderQueueElement>> mrpt::opengl::RenderQueue

A queue for rendering, sorted by shader program to minimize changes of OpenGL shader programs while rendering a scene.

Within each shader, objects are sorted by eye-to-object distance, so we can later render them from back to front to render transparencies properly Filled by sortRenderObjectsByShader()

typedef uint8_t mrpt::opengl::shader_id_t

Type for IDs of shaders.

See also:

DefaultShaderID, LoadDefaultShader()

Global Functions

void mrpt::global_settings::OCTREE_RENDER_MAX_DENSITY_POINTS_PER_SQPIXEL(float value)

Default value = 0.01 points/px^2.

Affects to these classes (read their docs for further details):

size_t mrpt::global_settings::OCTREE_RENDER_MAX_POINTS_PER_NODE()

Default value = 1e5.

Maximum number of elements in each octree node before spliting. Affects to these classes (read their docs for further details):

Program::Ptr mrpt::opengl::LoadDefaultShader(const shader_id_t id)

Loads a set of OpenGL Vertex+Fragment shaders from the default library available in mrpt::opengl.

See also:

CRenderizable

void mrpt::opengl::registerAllClasses_mrpt_opengl()

Forces manual RTTI registration of all serializable classes in this namespace.

Should never be required to be explicitly called by users, except if building MRPT as a static library.

std::tuple<double, bool, bool> mrpt::opengl::depthAndVisibleInView(
    const CRenderizable* obj,
    const mrpt::opengl::TRenderMatrices& objState,
    const bool skipCullChecks
    )

Computes the eye-view depth of an object, and whether any part of its bounding box is visible by the camera in the current state.

Return:

  • double: Depth of representative point.

  • bool: visible (at least in part)

  • bool: the whole bbox is visible (only checked for CSetOfObjects)

template <class GRAPH_T>
CSetOfObjects::Ptr mrpt::opengl::graph_tools::graph_visualize(
    const GRAPH_T& g,
    const mrpt::containers::yaml& extra_params = {}
    )

Returns an opengl objects representation of an arbitrary graph, as a network of 3D pose frames.

Note that the “global” coordinates of each node are taken from mrpt::graphs::CNetworkOfPoses::nodes, so if a node appears in “edges” but not in “nodes” it will be not displayed.

List of accepted extra parameters:

Parameter name

Type

Description

Default

show_ID_labels bool Show poses ID labels false show_ground_grid bool Creates a gray grid on the ground level ( true show_edges bool Draw lines between nodes with at least one edge between them. true show_node_corners bool Draw a small 3D corner frame at each node (see true show_edge_rel_poses bool Draw the relative poses stored in each edge as a small extra 3D corner frame at each “node pose oplus edge pose” false nodes_point_size double If set to !=0, draw a point of the given size (glPointSize) at each node. 0.0 nodes_corner_scale double If show_node_corners==true, the size (length) of the corner lines. 0.7 nodes_edges_corner_scale double If show_edge_rel_poses==true, the size of the corners at the end of each drawn edge 0.4 nodes_point_color int If nodes_point_size>0, set this value to a hexadecimal int value 0xRRGGBBAA with the desired RGB+Alpha color of points. 0xA0A0A0FF edge_color int If show_edges==true, the color of those edges as a hexadecimal int value 0xRRGGBBAA with RGB+Alpha color. 0x0000FF40 edge_rel_poses_color int If show_edge_rel_poses==true, the color of those edges as a hexadecimal int value 0xRRGGBBAA with RGB+Alpha color. 0xFF800040 edge_width double If show_edges==true, the width of edge lines. 1 ======================== ====== ======================================================================================================================= ==========

Implemented as headers-only in graph_tools_impl.h

Parameters:

g

The graph

extra_params

An extra set of optional parameters (see below).

See also:

mrpt::graphs::CNetworkOfPoses2D, mrpt::graphs::CNetworkOfPoses3D, mrpt::graphs::CNetworkOfPoses2DInf, mrpt::graphs::CNetworkOfPoses3DInf