Main MRPT website > C++ reference for MRPT 1.9.9
CAssimpModel.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #ifndef opengl_CAssimpModel_H
10 #define opengl_CAssimpModel_H
11 
14 #include <map>
15 
16 namespace mrpt
17 {
18 namespace opengl
19 {
20 /** This class can load & render 3D models in a number of different formats
21  * (requires the library assimp).
22  * - All supported formats:
23  * http://assimp.sourceforge.net/main_features_formats.html
24  * - Most common ones: AutoCAD DXF ( .dxf ), Collada ( .dae ), Blender 3D (
25  * .blend ), 3ds Max 3DS ( .3ds ), 3ds Max ASE ( .ase ), Quake I ( .mdl ), Quake
26  * II ( .md2 ), Quake III Mesh ( .md3 ), etc.
27  *
28  * Models are loaded via CAssimpModel::loadScene()
29  *
30  * <div align="center">
31  * <table border="0" cellspan="4" cellspacing="4" style="border-width: 1px;
32  * border-style: solid;">
33  * <tr> <td> mrpt::opengl::CAssimpModel </td> <td> \image html
34  * preview_CAssimpModel.png </td> </tr>
35  * </table>
36  * </div>
37  *
38  * \sa opengl::COpenGLScene
39  * \ingroup mrpt_opengl_grp
40  * \note Class introduced in MRPT 1.2.2
41  */
43 {
45 
46  public:
47  /** Render child objects */
48  void render_dl() const override;
49 
50  /** Evaluates the bounding box of this object (including possible children)
51  * in the coordinate frame of the object parent. */
52  void getBoundingBox(
53  mrpt::math::TPoint3D& bb_min,
54  mrpt::math::TPoint3D& bb_max) const override;
55 
56  /** Loads a scene from a file in any supported file.
57  * \exception std::runtime_error On any error during loading or importing
58  * the file.
59  */
60  void loadScene(const std::string& file_name);
61 
62  /** Empty the object */
63  void clear();
64 
65  /** Evaluates the scene at a given animation time */
66  void evaluateAnimation(double time_anim);
67 
68  /* Simulation of ray-trace. */
69  bool traceRay(const mrpt::poses::CPose3D& o, double& dist) const override;
70 
72  {
73  /** indices in \a m_textureIds. string::npos for non-initialized ones.
74  */
75  size_t id_idx;
77  TInfoPerTexture() : id_idx(std::string::npos) {}
78  };
79 
80  CAssimpModel();
81  /** Private, virtual destructor: only can be deleted from smart pointers */
82  virtual ~CAssimpModel();
83 
84  private:
85  /** A container for automatic deletion of assimp scene when the last
86  * reference of the smart_ptr's is destroyed.
87  */
88  struct TImplAssimp
89  {
90  TImplAssimp();
91  ~TImplAssimp();
92  /** aiScene* */
93  void* scene;
94  };
95  std::shared_ptr<TImplAssimp> m_assimp_scene;
96 
97  /** Bounding box */
99 
100  mutable bool m_textures_loaded;
102  mutable std::vector<unsigned int> m_textureIds;
103 
104  mutable std::map<std::string, TInfoPerTexture> m_textureIdMap;
105 };
106 
107 } // namespace opengl
108 } // namespace mrpt
109 
110 #endif
mrpt::opengl::CAssimpModel::m_bbox_max
mrpt::math::TPoint3D m_bbox_max
Definition: CAssimpModel.h:98
mrpt::opengl::CAssimpModel::TImplAssimp::TImplAssimp
TImplAssimp()
Definition: CAssimpModel.cpp:215
mrpt::opengl::CAssimpModel::TInfoPerTexture::TInfoPerTexture
TInfoPerTexture()
Definition: CAssimpModel.h:77
mrpt::opengl::CAssimpModel::TInfoPerTexture::img_alpha
mrpt::img::CImage::Ptr img_alpha
Definition: CAssimpModel.h:76
CRenderizableDisplayList.h
mrpt::opengl::CAssimpModel::m_textures_loaded
bool m_textures_loaded
Definition: CAssimpModel.h:100
mrpt::opengl::CAssimpModel
This class can load & render 3D models in a number of different formats (requires the library assimp)...
Definition: CAssimpModel.h:42
mrpt::opengl::CAssimpModel::m_modelPath
std::string m_modelPath
Definition: CAssimpModel.h:101
mrpt::opengl::CRenderizableDisplayList
A renderizable object suitable for rendering with OpenGL's display lists.
Definition: CRenderizableDisplayList.h:39
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::opengl::CAssimpModel::evaluateAnimation
void evaluateAnimation(double time_anim)
Evaluates the scene at a given animation time.
Definition: CAssimpModel.cpp:193
mrpt::opengl::CAssimpModel::TInfoPerTexture::img_rgb
mrpt::img::CImage::Ptr img_rgb
Definition: CAssimpModel.h:76
mrpt::opengl::CAssimpModel::TImplAssimp::~TImplAssimp
~TImplAssimp()
Definition: CAssimpModel.cpp:216
mrpt::opengl::CAssimpModel::TImplAssimp
A container for automatic deletion of assimp scene when the last reference of the smart_ptr's is dest...
Definition: CAssimpModel.h:88
mrpt::opengl::CAssimpModel::m_assimp_scene
std::shared_ptr< TImplAssimp > m_assimp_scene
Definition: CAssimpModel.h:95
mrpt::opengl::CAssimpModel::getBoundingBox
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...
Definition: CAssimpModel.cpp:204
mrpt::opengl::CAssimpModel::render_dl
void render_dl() const override
Render child objects.
Definition: CAssimpModel.cpp:66
COpenGLScene.h
mrpt::opengl::CAssimpModel::CAssimpModel
CAssimpModel()
Definition: CAssimpModel.cpp:136
mrpt::opengl::CAssimpModel::m_textureIdMap
std::map< std::string, TInfoPerTexture > m_textureIdMap
Definition: CAssimpModel.h:104
mrpt::poses::CPose3D
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
mrpt::opengl::CAssimpModel::~CAssimpModel
virtual ~CAssimpModel()
Private, virtual destructor: only can be deleted from smart pointers.
Definition: CAssimpModel.cpp:142
mrpt::opengl::CAssimpModel::TInfoPerTexture::id_idx
size_t id_idx
indices in m_textureIds.
Definition: CAssimpModel.h:75
mrpt::opengl::CAssimpModel::TImplAssimp::scene
void * scene
aiScene*
Definition: CAssimpModel.h:93
mrpt::opengl::CAssimpModel::m_textureIds
std::vector< unsigned int > m_textureIds
Definition: CAssimpModel.h:102
mrpt::math::TPoint3D
Lightweight 3D point.
Definition: lightweight_geom_data.h:378
mrpt::opengl::CAssimpModel::traceRay
bool traceRay(const mrpt::poses::CPose3D &o, double &dist) const override
Simulation of ray-trace, given a pose.
Definition: CAssimpModel.cpp:230
mrpt::img::CImage::Ptr
std::shared_ptr< CImage > Ptr
Definition: img/CImage.h:132
DEFINE_SERIALIZABLE
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
Definition: CSerializable.h:102
string
GLsizei const GLchar ** string
Definition: glext.h:4101
mrpt::opengl::CAssimpModel::TInfoPerTexture
Definition: CAssimpModel.h:71
mrpt::opengl::CAssimpModel::clear
void clear()
Empty the object.
Definition: CAssimpModel.cpp:146
mrpt::opengl::CAssimpModel::m_bbox_min
mrpt::math::TPoint3D m_bbox_min
Bounding box.
Definition: CAssimpModel.h:98
mrpt::opengl::CAssimpModel::loadScene
void loadScene(const std::string &file_name)
Loads a scene from a file in any supported file.
Definition: CAssimpModel.cpp:163



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST