class mrpt::opengl::CSetOfObjects

A set of object, which are referenced to the coordinates framework established in this object.

It can be established a hierarchy of “CSetOfObjects”, where the coordinates framework of each one will be referenced to the parent’s one. The list of child objects is accessed directly as in the class COpenGLScene

See also:

opengl::COpenGLScene

#include <mrpt/opengl/CSetOfObjects.h>

class CSetOfObjects: public mrpt::opengl::CRenderizable
{
public:
    // typedefs

    typedef CListOpenGLObjects::const_iterator const_iterator;
    typedef CListOpenGLObjects::iterator iterator;

    //
methods

    static CSetOfObjects::Ptr posePDF2opengl(const mrpt::poses::CPosePDF& o);
    static CSetOfObjects::Ptr posePDF2opengl(const mrpt::poses::CPointPDF& o);
    static CSetOfObjects::Ptr posePDF2opengl(const mrpt::poses::CPose3DPDF& o);
    static CSetOfObjects::Ptr posePDF2opengl(const mrpt::poses::CPose3DQuatPDF& o);
    const_iterator begin() const;
    const_iterator end() const;
    iterator begin();
    iterator end();

    template <class T>
    void insertCollection(const T& objs);

    void insert(const CRenderizable::Ptr& newObject);

    template <class T_it>
    void insert(const T_it& begin, const T_it& end);

    virtual shader_list_t requiredShaders() const;
    virtual void render(const RenderContext& rc) const;
    virtual void renderUpdateBuffers() const;

    void enqueForRenderRecursive(
        const mrpt::opengl::TRenderMatrices& state,
        RenderQueue& rq
        ) const;

    virtual void freeOpenGLResources();
    virtual void initializeTextures() const;
    void clear();
    size_t size();
    bool empty() const;
    CRenderizable::Ptr getByName(const std::string& str);

    template <typename T>
    T::Ptr getByClass(size_t ith = 0) const;

    void removeObject(const CRenderizable::Ptr& obj);
    void dumpListOfObjects(std::vector<std::string>& lst) const;
    mrpt::containers::yaml asYAML() const;
    virtual bool traceRay(const mrpt::poses::CPose3D& o, double& dist) const;
    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);
    bool contains(const CRenderizable::Ptr& obj) 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;

Methods

static CSetOfObjects::Ptr posePDF2opengl(const mrpt::poses::CPosePDF& o)

Returns a representation of a the PDF - this is just an auxiliary function, it’s more natural to call mrpt::poses::CPosePDF::getAs3DObject.

static CSetOfObjects::Ptr posePDF2opengl(const mrpt::poses::CPointPDF& o)

Returns a representation of a the PDF - this is just an auxiliary function, it’s more natural to call mrpt::poses::CPointPDF::getAs3DObject.

static CSetOfObjects::Ptr posePDF2opengl(const mrpt::poses::CPose3DPDF& o)

Returns a representation of a the PDF - this is just an auxiliary function, it’s more natural to call mrpt::poses::CPose3DPDF::getAs3DObject.

static CSetOfObjects::Ptr posePDF2opengl(const mrpt::poses::CPose3DQuatPDF& o)

Returns a representation of a the PDF - this is just an auxiliary function, it’s more natural to call mrpt::poses::CPose3DQuatPDF::getAs3DObject.

template <class T>
void insertCollection(const T& objs)

Inserts a set of objects into the list.

void insert(const CRenderizable::Ptr& newObject)

Insert a new object to the list.

template <class T_it>
void insert(const T_it& begin, const T_it& end)

Inserts a set of objects, bounded by iterators, into the list.

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.

virtual void initializeTextures() const

Initializes all textures (loads them into opengl memory).

void clear()

Clear the list of objects in the scene, deleting objects’ memory.

size_t size()

Returns number of objects.

bool empty() const

Returns true if there are no objects.

CRenderizable::Ptr getByName(const std::string& str)

Returns the first object with a given name, or a nullptr pointer if not found.

template <typename T>
T::Ptr getByClass(size_t ith = 0) const

Returns the i’th object of a given class (or of a descendant class), or nullptr (an empty smart pointer) if not found.

Example:

CSphere::Ptr obs = myscene.getByClass<CSphere>();

By default (ith=0), the first observation is returned.

void removeObject(const CRenderizable::Ptr& obj)

Removes the given object from the scene (it also deletes the object to free its memory).

void dumpListOfObjects(std::vector<std::string>& lst) const

Retrieves a list of all objects in text form.

Deprecated Prefer asYAML() (since MRPT 2.1.3)

mrpt::containers::yaml asYAML() const

Prints all objects in human-readable YAML form.

(New in MRPT 2.1.3)

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 CRenderizable& setColorR_u8(const uint8_t r)

Color components in the range [0,255].

Returns:

a ref to this

virtual CRenderizable& setColorG_u8(const uint8_t g)

Color components in the range [0,255].

Returns:

a ref to this

virtual CRenderizable& setColorB_u8(const uint8_t b)

Color components in the range [0,255].

Returns:

a ref to this

virtual CRenderizable& setColorA_u8(const uint8_t a)

Color components in the range [0,255].

Returns:

a ref to this

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

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