18 #if defined(MRPT_ASSIMP_VERSION_MAJOR) && MRPT_ASSIMP_VERSION_MAJOR < 3    19 #include <aiPostProcess.h>    23 #include <assimp/cimport.h>    24 #include <assimp/postprocess.h>    25 #include <assimp/scene.h>    26 #include <assimp/DefaultLogger.hpp>    27 #include <assimp/LogStream.hpp>    44     std::vector<mrpt::math::TPoint3Df>* lines_vbd = 
nullptr;
    45     std::vector<mrpt::img::TColor>* lines_cbd = 
nullptr;
    46     std::vector<mrpt::math::TPoint3Df>* pts_vbd = 
nullptr;
    47     std::vector<mrpt::img::TColor>* pts_cbd = 
nullptr;
    48     std::vector<mrpt::opengl::TTriangle>* tris = 
nullptr;
    51 #if MRPT_HAS_OPENGL_GLUT && MRPT_HAS_ASSIMP    54 static void recursive_render(
    60 static void get_bounding_box(
    61     const aiScene* sc, aiVector3D* min, aiVector3D* max);
    62 static void get_bounding_box_for_node(
    63     const aiScene* sc, 
const aiNode* nd, aiVector3D* min, aiVector3D* max,
    65 #endif  // MRPT_HAS_OPENGL_GLUT && MRPT_HAS_ASSIMP   109     if (!m_assimp_scene->scene) 
return;  
   118 #if MRPT_HAS_OPENGL_GLUT && MRPT_HAS_ASSIMP   119     auto* scene = 
reinterpret_cast<aiScene*
>(m_assimp_scene->scene);
   123     recursive_render(scene, scene->mRootNode, transf, re);
   135     writeToStreamRender(
out);
   137     const bool empty = m_assimp_scene->scene != 
nullptr;
   142 #if MRPT_HAS_OPENGL_GLUT && MRPT_HAS_ASSIMP   160             readFromStreamRender(in);
   187 #if MRPT_HAS_OPENGL_GLUT   189     if (!m_textureIds.empty())
   191         glDeleteTextures(m_textureIds.size(), &m_textureIds[0]);
   192         m_textureIds.clear();
   194     m_textureIdMap.clear();
   201 #if MRPT_HAS_OPENGL_GLUT && MRPT_HAS_ASSIMP   208         filepath.c_str(), aiProcessPreset_TargetRealtime_MaxQuality);
   213         aiVector3D scene_min, scene_max;
   215         get_bounding_box(scene, &scene_min, &scene_max);
   243 #if MRPT_HAS_OPENGL_GLUT && MRPT_HAS_ASSIMP   249         aiReleaseImport((aiScene*)
scene);
   261 #if MRPT_HAS_OPENGL_GLUT && MRPT_HAS_ASSIMP   263 static void get_bounding_box_for_node(
   264     const aiScene* scene, 
const aiNode* nd, aiVector3D* min, aiVector3D* max,
   268     unsigned int n = 0, t;
   271     aiMultiplyMatrix4(trafo, &nd->mTransformation);
   273     for (; n < nd->mNumMeshes; ++n)
   275         const aiMesh* mesh = scene->mMeshes[nd->mMeshes[n]];
   276         for (t = 0; t < mesh->mNumVertices; ++t)
   278             aiVector3D tmp = mesh->mVertices[t];
   279             aiTransformVecByMatrix4(&tmp, trafo);
   281             min->x = std::min(min->x, tmp.x);
   282             min->y = std::min(min->y, tmp.y);
   283             min->z = std::min(min->z, tmp.z);
   285             max->x = std::max(max->x, tmp.x);
   286             max->y = std::max(max->y, tmp.y);
   287             max->z = std::max(max->z, tmp.z);
   291     for (n = 0; n < nd->mNumChildren; ++n)
   293         get_bounding_box_for_node(scene, nd->mChildren[n], min, max, trafo);
   298 static void get_bounding_box(
   299     const aiScene* scene, aiVector3D* min, aiVector3D* max)
   302     aiIdentityMatrix4(&trafo);
   304     min->x = min->y = min->z = 1e10f;
   305     max->x = max->y = max->z = -1e10f;
   306     get_bounding_box_for_node(scene, scene->mRootNode, min, max, &trafo);
   318         aiGetMaterialColor(mtl, AI_MATKEY_COLOR_DIFFUSE, &diffuse))
   320         return color4_to_TColor(diffuse);
   325         return {0xa0, 0xa0, 0xa0, 0xff};
   356     return {v.
x, v.y, v.z};
   359 static void recursive_render(
   363     aiMatrix4x4 m = nd->mTransformation;
   370     for (
unsigned int n = 0; n < nd->mNumMeshes; ++n)
   372         const struct aiMesh* mesh = sc->mMeshes[nd->mMeshes[n]];
   375             apply_material(sc->mMaterials[mesh->mMaterialIndex]);
   377         for (
unsigned int t = 0; t < mesh->mNumFaces; ++t)
   379             const struct aiFace* face = &mesh->mFaces[t];
   381             switch (face->mNumIndices)
   385                     for (
unsigned int i = 0; i < face->mNumIndices; i++)
   388                         int vertexIndex = face->mIndices[i];
   389                         if (mesh->mColors[0] != 
nullptr)
   391                                 color4_to_TColor(mesh->mColors[0][vertexIndex]);
   394                             to_mrpt(mesh->mVertices[vertexIndex])));
   395                         re.
pts_cbd->emplace_back(color);
   401                     for (
unsigned int i = 0; i < face->mNumIndices; i++)
   404                         int vertexIndex = face->mIndices[i];
   405                         if (mesh->mColors[0] != 
nullptr)
   407                                 color4_to_TColor(mesh->mColors[0][vertexIndex]);
   410                             to_mrpt(mesh->mVertices[vertexIndex])));
   418                     const unsigned int nTri = face->mNumIndices / 3;
   421                     for (
unsigned int iTri = 0; iTri < nTri; iTri++)
   424                         for (
unsigned int v = 0; v < 3; v++)
   426                             unsigned int i = iTri * 3 + v;
   428                             int vertexIndex = face->mIndices[i];
   429                             if (mesh->mColors[0] != 
nullptr)
   430                                 color = color4_to_TColor(
   431                                     mesh->mColors[0][vertexIndex]);
   439                             if (mesh->HasTextureCoords(0))
   442                                     mesh->mTextureCoords[0][vertexIndex].x;
   444                                     mesh->mTextureCoords[0][vertexIndex].y;
   449                                     to_mrpt(mesh->mNormals[vertexIndex]));
   452                                 to_mrpt(mesh->mVertices[vertexIndex]));
   458                         re.
tris->emplace_back(std::move(tri));
   471     for (
unsigned int n = 0; n < nd->mNumChildren; ++n)
   472         recursive_render(sc, nd->mChildren[n], curTf, re);
   475 #endif  // MRPT_HAS_OPENGL_GLUT && MRPT_HAS_ASSIMP A compile-time fixed-size numeric matrix container. 
 
const uint8_t & b(size_t i) const
 
std::vector< mrpt::math::TPoint3Df > m_vertex_buffer_data
 
#define THROW_EXCEPTION(msg)
 
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive. 
 
void onUpdateBuffers_all()
 
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
To be added to all CSerializable-classes implementation files. 
 
void onUpdateBuffers_Triangles() override
Must be implemented in derived classes to update the geometric entities to be drawn in "m_*_buffer" f...
 
const uint8_t & r(size_t i) const
 
void notifyChange() const
Call to enable calling renderUpdateBuffers() before the next render() rendering iteration. 
 
const float & x(size_t i) const
 
std::vector< mrpt::img::TColor > * lines_cbd
 
std::vector< mrpt::math::TPoint3Df > * pts_vbd
 
A triangle (float coordinates) with RGBA colors (u8) and UV (texture coordinates) for each vertex...
 
mrpt::opengl::shader_id_t shader_id
 
The base class of 3D objects that can be directly rendered through OpenGL. 
 
void onUpdateBuffers_Points() override
Must be implemented in derived classes to update the geometric entities to be drawn in "m_*_buffer" f...
 
const uint8_t & g(size_t i) const
 
void loadScene(const std::string &file_name)
Loads a scene from a file in any supported file. 
 
mrpt::math::TPoint3D m_bbox_min
Bounding box. 
 
mrpt::poses::CPose3D m_pose
6D pose wrt the parent coordinate reference. 
 
void renderUpdateBuffers() const override
Called whenever m_outdatedBuffers is true: used to re-generate OpenGL vertex buffers, etc. 
 
bool traceRay(const mrpt::poses::CPose3D &o, double &dist) const override
Simulation of ray-trace, given a pose. 
 
void renderUpdateBuffers() const override
Called whenever m_outdatedBuffers is true: used to re-generate OpenGL vertex buffers, etc. 
 
Context for calls to render() 
 
mrpt::math::TVector3D rotateVector(const mrpt::math::TVector3D &local) const
Rotates a vector (i.e. 
 
std::vector< mrpt::math::TPoint3Df > m_vertex_buffer_data
 
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations. 
 
const uint8_t & a(size_t i) const
 
std::vector< mrpt::img::TColor > m_color_buffer_data
 
std::array< Vertex, 3 > vertices
 
void onUpdateBuffers_Wireframe() override
Must be implemented in derived classes to update the geometric entities to be drawn in "m_*_buffer" f...
 
This base provides a set of functions for maths stuff. 
 
mrpt::math::TPoint3D m_bbox_max
 
void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max) const override
Evaluates the bounding box of this object (including possible children) in the coordinate frame of th...
 
void clear()
Empty the object. 
 
#define ASSERT_EQUAL_(__A, __B)
Assert comparing two values, reporting their actual values upon failure. 
 
std::vector< mrpt::math::TPoint3Df > * lines_vbd
 
static constexpr shader_id_t WIREFRAME
 
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object. 
 
virtual ~CAssimpModel() override
 
void renderUpdateBuffers() const override
Called whenever m_outdatedBuffers is true: used to re-generate OpenGL vertex buffers, etc. 
 
static constexpr shader_id_t TRIANGLES
 
std::vector< mrpt::img::TColor > * pts_cbd
 
void render(const RenderContext &rc) const override
Implements the rendering of 3D objects in each class derived from CRenderizable. 
 
std::vector< mrpt::img::TColor > m_color_buffer_data
 
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries. 
 
std::vector< mrpt::opengl::TTriangle > * tris
 
const float & y(size_t i) const
 
Virtual base class for "archives": classes abstracting I/O streams. 
 
std::vector< mrpt::opengl::TTriangle > m_triangles
List of triangles. 
 
A class used to store a 3D pose (a 3D translation + a rotation in 3D). 
 
mrpt::vision::TStereoCalibResults out
 
const float & z(size_t i) const
 
An RGBA color - floats in the range [0,1]. 
 
The namespace for 3D scene representation and rendering. 
 
void render(const RenderContext &rc) const override
Implements the rendering of 3D objects in each class derived from CRenderizable. 
 
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive. 
 
void composePoint(double lx, double ly, double lz, double &gx, double &gy, double &gz, mrpt::optional_ref< mrpt::math::CMatrixDouble33 > out_jacobian_df_dpoint=std::nullopt, mrpt::optional_ref< mrpt::math::CMatrixDouble36 > out_jacobian_df_dpose=std::nullopt, mrpt::optional_ref< mrpt::math::CMatrixDouble36 > out_jacobian_df_dse3=std::nullopt, bool use_small_rot_approx=false) const
An alternative, slightly more efficient way of doing  with G and L being 3D points and P this 6D pose...
 
TColor asTColor() const
Returns the 0-255 integer version of this color: RGBA_u8. 
 
void render(const RenderContext &rc) const override
Implements the rendering of 3D objects in each class derived from CRenderizable. 
 
void clear()
Clear the contents of this container. 
 
This class can load & render 3D models in a number of different formats (requires the library assimp)...
 
static constexpr shader_id_t POINTS
 
std::shared_ptr< TImplAssimp > m_assimp_scene
 
void render(const RenderContext &rc) const override
Implements the rendering of 3D objects in each class derived from CRenderizable. 
 
void renderUpdateBuffers() const override
Called whenever m_outdatedBuffers is true: used to re-generate OpenGL vertex buffers, etc.