class mrpt::opengl::CAssimpModel

This class can load & render 3D models in a number of different formats (requires the library assimp).

Models are loaded via CAssimpModel::loadScene()

mrpt::opengl::CAssimpModel

See also:

opengl::COpenGLScene

#include <mrpt/opengl/CAssimpModel.h>

class CAssimpModel:
    public mrpt::opengl::CRenderizableShaderTriangles,
    public mrpt::opengl::CRenderizableShaderWireFrame,
    public mrpt::opengl::CRenderizableShaderPoints
{
public:
    // typedefs

    typedef std::string filepath_t;

    // structs

    struct Impl;
    struct LoadFlags;
    struct TInfoPerTexture;

    // construction

    CAssimpModel();

    //
methods

    virtual void render(const RenderContext& rc) const;
    virtual void renderUpdateBuffers() const;
    virtual shader_list_t requiredShaders() const;
    virtual void onUpdateBuffers_Wireframe();
    virtual void onUpdateBuffers_Triangles();
    virtual void onUpdateBuffers_Points();
    void onUpdateBuffers_all();
    virtual void freeOpenGLResources();

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

    void loadScene(const std::string& file_name, const int flags = LoadFlags::RealTimeMaxQuality|LoadFlags::FlipUVs|LoadFlags::Verbose);
    void clear();
    virtual bool traceRay(const mrpt::poses::CPose3D& o, double& dist) const;
    virtual mrpt::math::TBoundingBox getBoundingBox() const;
    void setPointSize(float p);
    void enableVariablePointSize(bool enable = true);
    void setVariablePointSize_k(float v);
    void setVariablePointSize_DepthScale(float v);
};

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;
    virtual void onUpdateBuffers_Wireframe() = 0;
    virtual void onUpdateBuffers_Points() = 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 shader_list_t requiredShaders() const

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

See also:

DefaultShaderID

virtual void onUpdateBuffers_Wireframe()

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 void onUpdateBuffers_Points()

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

virtual void freeOpenGLResources()

Free opengl buffers.

void loadScene(const std::string& file_name, const int flags = LoadFlags::RealTimeMaxQuality|LoadFlags::FlipUVs|LoadFlags::Verbose)

Loads a scene from a file in any supported file.

Parameters:

std::runtime_error

On any error during loading or importing the file.

void clear()

Empty the object.

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.

void setPointSize(float p)

By default is 1.0.

See also:

enableVariablePointSize()

void enableVariablePointSize(bool enable = true)

Enable/disable variable eye distance-dependent point size (default=true)

void setVariablePointSize_k(float v)

see CRenderizableShaderPoints for a discussion of this parameter.

void setVariablePointSize_DepthScale(float v)

see CRenderizableShaderPoints for a discussion of this parameter.