class mrpt::viz::CMesh3D
Overview
A 3D mesh composed of triangles and/or quads.
A typical usage example would be a 3D model of an object.
See also:
opengl::Scene,opengl::CMesh,opengl::CAssimpModel
#include <mrpt/viz/CMesh3D.h> class CMesh3D: public mrpt::viz::CVisualObject, public mrpt::viz::VisualObjectParams_Lines, public mrpt::viz::VisualObjectParams_Triangles { public: // typedefs typedef std::shared_ptr<mrpt::viz ::CMesh3D> Ptr; typedef std::shared_ptr<const mrpt::viz ::CMesh3D> ConstPtr; typedef std::unique_ptr<mrpt::viz ::CMesh3D> UniquePtr; typedef std::unique_ptr<const mrpt::viz ::CMesh3D> ConstUniquePtr; // fields static constexpr const char* className = "mrpt::viz" "::" "CMesh3D"; // construction CMesh3D(); // methods static constexpr auto getClassName(); static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic(); static std::shared_ptr<CObject> CreateObject(); template <typename... Args> static Ptr Create(Args&&... args); template <typename Alloc, typename... Args> static Ptr CreateAlloc( const Alloc& alloc, Args&&... args ); template <typename... Args> static UniquePtr CreateUnique(Args&&... args); virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const; virtual mrpt::rtti::CObject* clone() const; void enableShowEdges(bool v); void enableShowFaces(bool v); void enableShowVertices(bool v); void enableFaceNormals(bool v); void loadMesh( unsigned int num_verts, unsigned int num_faces, int* verts_per_face, int* face_verts, float* vert_coords ); void loadMesh( unsigned int num_verts, unsigned int num_faces, const mrpt::math::CMatrixDynamic<bool>& is_quad, const mrpt::math::CMatrixDynamic<int>& face_verts, const mrpt::math::CMatrixDynamic<float>& vert_coords ); void setEdgeColor( float r, float g, float b, float a = 1.f ); void setFaceColor( float r, float g, float b, float a = 1.f ); void setVertColor( float r, float g, float b, float a = 1.f ); virtual void updateBuffers() const; virtual mrpt::math::TBoundingBoxf internalBoundingBoxLocal() const; };
Inherited Members
public: // typedefs typedef std::shared_ptr<CObject> Ptr; typedef std::shared_ptr<const CObject> ConstPtr; typedef std::shared_ptr<CSerializable> Ptr; typedef std::shared_ptr<const CSerializable> ConstPtr; typedef std::shared_ptr<CVisualObject> Ptr; typedef std::shared_ptr<const CVisualObject> ConstPtr; typedef std::unique_ptr<CObject> UniquePtr; typedef std::unique_ptr<const CObject> ConstUniquePtr; // structs struct PoseAndScale; struct State; // methods static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic(); virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const; virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const; static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic(); virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const; const auto& shaderLinesVertexPointBuffer() const; const auto& shaderLinesVertexColorBuffer() const; auto& shaderLinesBufferMutex() const; void setLineWidth(float w); float getLineWidth() const; void enableAntiAliasing(bool enable = true); bool isAntiAliasingEnabled() const; const auto& shaderTrianglesBuffer() const; auto& shaderTrianglesBufferMutex() const; static const mrpt::rtti::TRuntimeClassId& GetRuntimeClassIdStatic(); PoseAndScale getPoseAndScale() const; virtual CVisualObject& setColor_u8(const mrpt::img::TColor& c); bool isLightEnabled() const; void enableLight(bool enable = true); TCullFace cullFaces() const; void notifyBBoxChange() const; auto getBoundingBoxLocalf() const;
Typedefs
typedef std::shared_ptr<mrpt::viz ::CMesh3D> Ptr
A type for the associated smart pointer.
Methods
virtual const mrpt::rtti::TRuntimeClassId* GetRuntimeClass() const
Returns information about the class of an object in runtime.
virtual mrpt::rtti::CObject* clone() const
Returns a deep copy (clone) of the object, indepently of its class.
void loadMesh( unsigned int num_verts, unsigned int num_faces, int* verts_per_face, int* face_verts, float* vert_coords )
Load a 3D mesh.
The arguments indicate:
num_verts: Number of vertices of the mesh
num_faces: Number of faces of the mesh
verts_per_face: An array (pointer) with the number of vertices of each face. The elements must be set either to 3 (triangle) or 4 (quad).
face_verts: An array (pointer) with the vertices of each face. The vertices of each face must be consecutive in this array.
vert_coords: An array (pointer) with the coordinates of each vertex. The xyz coordinates of each vertex must be consecutive in this array.
void loadMesh( unsigned int num_verts, unsigned int num_faces, const mrpt::math::CMatrixDynamic<bool>& is_quad, const mrpt::math::CMatrixDynamic<int>& face_verts, const mrpt::math::CMatrixDynamic<float>& vert_coords )
Load a 3D mesh.
The arguments indicate:
num_verts: Number of vertices of the mesh
num_faces: Number of faces of the mesh
is_quad: A binary array saying whether the face is a quad (1) or a triangle (0)
face_verts: An array with the vertices of each face. For every column (face), each row contains the num of a vertex. The fourth does not need to be filled if the face is a triangle.
vert_coords: An array with the coordinates of each vertex. For every column (vertex), each row contains the xyz coordinates of the vertex.
virtual void updateBuffers() const
Called by the rendering system to update internal geometry buffers.
Derived classes should override this to populate their data buffers (triangles, points, lines) when the object geometry changes.
This is called automatically when hasToUpdateBuffers() returns true, which happens after notifyChange() was called.
The base implementation does nothing; derived classes should override.
Thread safety: implementations should lock the appropriate mutexes when writing to shared buffers.
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()