class mrpt::opengl::CSetOfTriangles

A set of colored triangles, able to draw any solid, arbitrarily complex object without textures.

For textures, see CSetOfTexturedTriangles

See also:

opengl::COpenGLScene, CSetOfTexturedTriangles

#include <mrpt/opengl/CSetOfTriangles.h>

class CSetOfTriangles: public mrpt::opengl::CRenderizableShaderTriangles
{
public:
    // typedefs

    typedef std::vector<TTriangle>::const_iterator const_iterator;
    typedef std::vector<TTriangle>::const_reverse_iterator const_reverse_iterator;

    // construction

    CSetOfTriangles();

    //
methods

    virtual void onUpdateBuffers_Triangles();
    void updatePolygons() const;
    void clearTriangles();
    size_t getTrianglesCount() const;
    void getTriangle(size_t idx, TTriangle& t) const;
    void insertTriangle(const TTriangle& t);

    template <class InputIterator>
    void insertTriangles(
        const InputIterator& begin,
        const InputIterator& end
        );

    void insertTriangles(const CSetOfTriangles::Ptr& p);
    void reserve(size_t t);
    virtual CRenderizable& setColor_u8(const mrpt::img::TColor& c);
    virtual CRenderizable& setColorR_u8(const uint8_t r);
    virtual CRenderizable& setColorG_u8(const uint8_t g);
    virtual CRenderizable& setColorB_u8(const uint8_t b);
    virtual CRenderizable& setColorA_u8(const uint8_t a);
    virtual bool traceRay(const mrpt::poses::CPose3D& o, double& dist) const;
    void getPolygons(std::vector<mrpt::math::TPolygon3D>& polys) const;

    template <class CONTAINER>
    void insertTriangles(const CONTAINER& c);

    const_iterator begin() const;
    const_iterator end() const;
    const_reverse_iterator rbegin() const;
    const_reverse_iterator rend() const;
    virtual mrpt::math::TBoundingBox getBoundingBox() const;
};

Inherited Members

public:
    // structs

    struct RenderContext;

    //
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 void onUpdateBuffers_Triangles() = 0;

Methods

virtual void onUpdateBuffers_Triangles()

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

void updatePolygons() const

Explicitly updates the internal polygon cache, with all triangles as polygons.

See also:

getPolygons()

void clearTriangles()

Clear this object, removing all triangles.

size_t getTrianglesCount() const

Get triangle count.

void getTriangle(size_t idx, TTriangle& t) const

Gets the i-th triangle.

void insertTriangle(const TTriangle& t)

Inserts a triangle into the set.

template <class InputIterator>
void insertTriangles(
    const InputIterator& begin,
    const InputIterator& end
    )

Inserts a set of triangles, bounded by iterators, into this set.

See also:

insertTriangle

void insertTriangles(const CSetOfTriangles::Ptr& p)

Inserts an existing CSetOfTriangles into this one.

void reserve(size_t t)

Reserves memory for certain number of triangles, avoiding multiple memory allocation calls.

virtual CRenderizable& setColor_u8(const mrpt::img::TColor& c)

Overwrite all triangles colors with the one provided.

virtual CRenderizable& setColorR_u8(const uint8_t r)

Overwrite all triangles colors with the one provided.

virtual CRenderizable& setColorG_u8(const uint8_t g)

Overwrite all triangles colors with the one provided.

virtual CRenderizable& setColorB_u8(const uint8_t b)

Overwrite all triangles colors with the one provided.

virtual CRenderizable& setColorA_u8(const uint8_t a)

Overwrite all triangles colors with the one provided.

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

void getPolygons(std::vector<mrpt::math::TPolygon3D>& polys) const

Gets the polygon cache.

See also:

insertTriangles

template <class CONTAINER>
void insertTriangles(const CONTAINER& c)

Inserts a set of triangles, given in a container of either TTriangle ‘s or TPolygon3D.

See also:

insertTriangle

const_iterator begin() const

Gets the beginning iterator to this object.

const_iterator end() const

Gets the ending iterator to this object.

const_reverse_iterator rbegin() const

Gets the reverse beginning iterator to this object, which points to the last triangle.

const_reverse_iterator rend() const

Gets the reverse ending iterator to this object, which points to the beginning of the actual set.

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

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