class mrpt::opengl::CMeshFast

A planar (XY) grid where each cell has an associated height and, optionally, a texture map.

To make it faster to render, instead of drawing lines and triangles it draws a point at each gridcell. A typical usage example would be an elevation map or a 3D model of a terrain.

mrpt::opengl::CMeshFast mrpt::opengl::CMeshFast mrpt::opengl::CMeshFast mrpt::opengl::CMeshFast

See also:

opengl::Scene

#include <mrpt/opengl/CMeshFast.h>

class CMeshFast: public mrpt::opengl::CRenderizableShaderPoints
{
public:
    // construction

    CMeshFast(
        bool enableTransparency = false,
        float xMin_p = -1.0f,
        float xMax_p = 1.0f,
        float yMin_p = -1.0f,
        float yMax_p = 1.0f
        );

    //
methods

    virtual void onUpdateBuffers_Points();

    void setGridLimits(
        float xmin,
        float xmax,
        float ymin,
        float ymax
        );

    void getGridLimits(
        float& xmin,
        float& xmax,
        float& ymin,
        float& ymax
        ) const;

    void enableTransparency(bool v);

    void enableColorFromZ(
        bool v,
        mrpt::img::TColormap colorMap = mrpt::img::cmJET
        );

    void setZ(const mrpt::math::CMatrixDynamic<float>& in_Z);
    void getZ(mrpt::math::CMatrixFloat& out) const;
    float getXMin() const;
    float getXMax() const;
    float getYMin() const;
    float getYMax() const;
    void setXMin(float nxm);
    void setXMax(float nxm);
    void setYMin(float nym);
    void setYMax(float nym);

    void getXBounds(
        float& min,
        float& max
        ) const;

    void getYBounds(
        float& min,
        float& max
        ) const;

    void setXBounds(
        float min,
        float max
        );

    void setYBounds(
        float min,
        float max
        );

    virtual mrpt::math::TBoundingBoxf internalBoundingBoxLocal() const;
    void assignImage(const mrpt::img::CImage& img);
    void assignImageAndZ(const mrpt::img::CImage& img, const mrpt::math::CMatrixDynamic<float>& in_Z);
    void adjustGridToImageAR();
    virtual shader_list_t requiredShaders() const;
    virtual void render(const RenderContext& rc) const;
    virtual void renderUpdateBuffers() const;
    virtual void freeOpenGLResources();
};

Inherited Members

public:
    // structs

    struct OutdatedState;
    struct RenderContext;
    struct State;

    //
methods

    virtual void render(const RenderContext& rc) const = 0;
    virtual void renderUpdateBuffers() const = 0;
    virtual shader_list_t requiredShaders() const;
    virtual void freeOpenGLResources() = 0;
    virtual void onUpdateBuffers_Points() = 0;

Construction

CMeshFast(
    bool enableTransparency = false,
    float xMin_p = -1.0f,
    float xMax_p = 1.0f,
    float yMin_p = -1.0f,
    float yMax_p = 1.0f
    )

Constructor.

Methods

virtual void onUpdateBuffers_Points()

Must be implemented in derived classes to update the geometric entities to be drawn in “m_*_buffer” fields.

void setZ(const mrpt::math::CMatrixDynamic<float>& in_Z)

This method sets the matrix of heights for each position (cell) in the mesh grid.

void getZ(mrpt::math::CMatrixFloat& out) const

Returns a reference to the internal Z matrix, allowing changing it efficiently.

virtual mrpt::math::TBoundingBoxf internalBoundingBoxLocal() const

Must be implemented by derived classes to provide the updated bounding box in the object local frame of coordinates.

This will be called only once after each time the derived class reports to notifyChange() that the object geometry changed.

See also:

getBoundingBox(), getBoundingBoxLocal(), getBoundingBoxLocalf()

void assignImage(const mrpt::img::CImage& img)

Assigns a texture image, and disable transparency.

void assignImageAndZ(const mrpt::img::CImage& img, const mrpt::math::CMatrixDynamic<float>& in_Z)

Assigns a texture image and Z simultaneously, and disable transparency.

void adjustGridToImageAR()

Adjust grid limits according to the image aspect ratio, maintaining the X limits and resizing in the Y direction.

virtual shader_list_t requiredShaders() const

Returns the ID of the OpenGL shader program required to render this class.

See also:

DefaultShaderID

virtual void render(const RenderContext& rc) const

Implements the rendering of 3D objects in each class derived from CRenderizable.

This can be called more than once (one per required shader program) if the object registered several shaders.

See also:

renderUpdateBuffers

virtual void renderUpdateBuffers() const

Called whenever m_outdatedBuffers is true: used to re-generate OpenGL vertex buffers, etc.

before they are sent for rendering in render()

virtual void freeOpenGLResources()

Free opengl buffers.