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;
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  };
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
virtual ~CAssimpModel()
Private, virtual destructor: only can be deleted from smart pointers.
size_t id_idx
indices in m_textureIds.
Definition: CAssimpModel.h:75
void evaluateAnimation(double time_anim)
Evaluates the scene at a given animation time.
STL namespace.
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.
Definition: CAssimpModel.h:98
bool traceRay(const mrpt::poses::CPose3D &o, double &dist) const override
Simulation of ray-trace, given a pose.
std::shared_ptr< CImage > Ptr
Definition: img/CImage.h:132
A renderizable object suitable for rendering with OpenGL&#39;s display lists.
std::map< std::string, TInfoPerTexture > m_textureIdMap
Definition: CAssimpModel.h:104
mrpt::math::TPoint3D m_bbox_max
Definition: CAssimpModel.h:98
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.
GLsizei const GLchar ** string
Definition: glext.h:4101
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:88
void render_dl() const override
Render child objects.
Lightweight 3D point.
A container for automatic deletion of assimp scene when the last reference of the smart_ptr&#39;s is dest...
Definition: CAssimpModel.h:88
This class can load & render 3D models in a number of different formats (requires the library assimp)...
Definition: CAssimpModel.h:42
std::vector< unsigned int > m_textureIds
Definition: CAssimpModel.h:102
std::shared_ptr< TImplAssimp > m_assimp_scene
Definition: CAssimpModel.h:95



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at lun oct 28 00:14:14 CET 2019