class mrpt::opengl::CTexturedPlane

A 2D plane in the XY plane with a texture image.

Lighting is disabled by default in this class.

See also:

opengl::COpenGLScene

#include <mrpt/opengl/CTexturedPlane.h>

class CTexturedPlane:
    public mrpt::opengl::CRenderizableShaderTexturedTriangles,
    public mrpt::opengl::CRenderizableShaderTriangles
{
public:
    // construction

    CTexturedPlane(
        float x_min = -1,
        float x_max = 1,
        float y_min = -1,
        float y_max = 1
        );

    //
methods

    const auto& shaderTexturedTrianglesBuffer() const;
    virtual void render(const RenderContext& rc) const;
    virtual void renderUpdateBuffers() const;
    virtual void onUpdateBuffers_TexturedTriangles();
    virtual void onUpdateBuffers_Triangles();
    virtual shader_list_t requiredShaders() const;
    virtual void freeOpenGLResources();
    void cullFaces(const TCullFace& cf);
    TCullFace cullFaces() const;
    void setPlaneCorners(float xMin, float xMax, float yMin, float yMax);
    void getPlaneCorners(float& xMin, float& xMax, float& yMin, float& yMax) const;
    virtual bool traceRay(const mrpt::poses::CPose3D& o, double& dist) const;
    virtual mrpt::math::TBoundingBox getBoundingBox() const;
    bool isLightEnabled() const;
    void enableLight(bool enable = true);
    const mrpt::img::CImage& getTextureImage() const;
    const mrpt::img::CImage& getTextureAlphaImage() const;
    bool textureImageHasBeenAssigned() const;
};

Inherited Members

public:
    // structs

    struct RenderContext;
    struct texture_name_unit_t;

    //
methods

    virtual void render(const RenderContext& rc) const = 0;
    virtual void renderUpdateBuffers() const = 0;
    virtual shader_list_t requiredShaders() const;
    virtual auto getBoundingBox() const = 0;
    virtual void freeOpenGLResources() = 0;
    virtual shader_list_t requiredShaders() const;
    virtual void render(const RenderContext& rc) const;
    virtual void renderUpdateBuffers() const;
    virtual void onUpdateBuffers_TexturedTriangles() = 0;
    virtual void freeOpenGLResources();
    void assignImage(const mrpt::img::CImage& img);
    virtual void onUpdateBuffers_Triangles() = 0;

Methods

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 onUpdateBuffers_TexturedTriangles()

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

virtual void onUpdateBuffers_Triangles()

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

virtual shader_list_t requiredShaders() const

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

See also:

DefaultShaderID

virtual void freeOpenGLResources()

Free opengl buffers.

void cullFaces(const TCullFace& cf)

Control whether to render the FRONT, BACK, or BOTH (default) set of faces.

Refer to docs for glCullFace()

void setPlaneCorners(float xMin, float xMax, float yMin, float yMax)

Set the coordinates of the four corners that define the plane on the XY plane.

void getPlaneCorners(float& xMin, float& xMax, float& yMin, float& yMax) const

Get the coordinates of the four corners that define the plane on the XY plane.

virtual bool traceRay(const mrpt::poses::CPose3D& o, double& dist) const

Simulation of ray-trace, given a pose.

Returns true if the ray effectively collisions with the object (returning the distance to the origin of the ray in “dist”), or false in other case. “dist” variable yields undefined behaviour when false is returned

virtual mrpt::math::TBoundingBox getBoundingBox() const

Evaluates the bounding box of this object (including possible children) in the coordinate frame of the object parent.