class mrpt::opengl::CAssimpModel

Overview

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 mrpt::opengl::CAssimpModel mrpt::opengl::CAssimpModel mrpt::opengl::CAssimpModel

See also:

opengl::Scene

#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 enqueueForRenderRecursive(
        const mrpt::opengl::TRenderMatrices& state,
        RenderQueue& rq,
        bool wholeInView,
        bool is1stShadowMapPass
        ) const;

    virtual bool isCompositeObject() 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::TBoundingBoxf internalBoundingBoxLocal() const;
    auto texturedObjects();
    void setPointSize(float p);
    void enableVariablePointSize(bool enable = true);
    void setVariablePointSize_k(float v);
    void setVariablePointSize_DepthScale(float v);
};

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_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.

virtual bool isCompositeObject() const

Should return true if enqueueForRenderRecursive() is defined since the object has inner children.

Examples: CSetOfObjects, CAssimpModel.

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

auto texturedObjects()

Read-only access to textured objects.

[New in MRPT 2.6.0]

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.