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::opengl
17 {
18 /** This class can load & render 3D models in a number of different formats
19  * (requires the library assimp).
20  * - All supported formats:
21  * http://assimp.sourceforge.net/main_features_formats.html
22  * - Most common ones: AutoCAD DXF ( .dxf ), Collada ( .dae ), Blender 3D (
23  * .blend ), 3ds Max 3DS ( .3ds ), 3ds Max ASE ( .ase ), Quake I ( .mdl ), Quake
24  * II ( .md2 ), Quake III Mesh ( .md3 ), etc.
25  *
26  * Models are loaded via CAssimpModel::loadScene()
27  *
28  * <div align="center">
29  * <table border="0" cellspan="4" cellspacing="4" style="border-width: 1px;
30  * border-style: solid;">
31  * <tr> <td> mrpt::opengl::CAssimpModel </td> <td> \image html
32  * preview_CAssimpModel.png </td> </tr>
33  * </table>
34  * </div>
35  *
36  * \sa opengl::COpenGLScene
37  * \ingroup mrpt_opengl_grp
38  * \note Class introduced in MRPT 1.2.2
39  */
41 {
43 
44  public:
45  /** Render child objects */
46  void render_dl() const override;
47 
48  /** Evaluates the bounding box of this object (including possible children)
49  * in the coordinate frame of the object parent. */
50  void getBoundingBox(
51  mrpt::math::TPoint3D& bb_min,
52  mrpt::math::TPoint3D& bb_max) const override;
53 
54  /** Loads a scene from a file in any supported file.
55  * \exception std::runtime_error On any error during loading or importing
56  * the file.
57  */
58  void loadScene(const std::string& file_name);
59 
60  /** Empty the object */
61  void clear();
62 
63  /** Evaluates the scene at a given animation time */
64  void evaluateAnimation(double time_anim);
65 
66  /* Simulation of ray-trace. */
67  bool traceRay(const mrpt::poses::CPose3D& o, double& dist) const override;
68 
70  {
71  /** indices in \a m_textureIds. string::npos for non-initialized ones.
72  */
73  size_t id_idx;
76  };
77 
78  CAssimpModel();
79  /** Private, virtual destructor: only can be deleted from smart pointers */
80  virtual ~CAssimpModel();
81 
82  private:
83  /** A container for automatic deletion of assimp scene when the last
84  * reference of the smart_ptr's is destroyed.
85  */
86  struct TImplAssimp
87  {
88  TImplAssimp();
89  ~TImplAssimp();
90  /** aiScene* */
91  void* scene;
92  };
94 
95  /** Bounding box */
97 
98  mutable bool m_textures_loaded;
100  mutable std::vector<unsigned int> m_textureIds;
101 
102  mutable std::map<std::string, TInfoPerTexture> m_textureIdMap;
103 };
104 
105 }
106 #endif
107 
108 
virtual ~CAssimpModel()
Private, virtual destructor: only can be deleted from smart pointers.
size_t id_idx
indices in m_textureIds.
Definition: CAssimpModel.h:73
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:96
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:102
mrpt::math::TPoint3D m_bbox_max
Definition: CAssimpModel.h:96
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
#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:86
The namespace for 3D scene representation and rendering.
Definition: CGlCanvasBase.h:15
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:86
This class can load & render 3D models in a number of different formats (requires the library assimp)...
Definition: CAssimpModel.h:40
std::vector< unsigned int > m_textureIds
Definition: CAssimpModel.h:100
std::shared_ptr< TImplAssimp > m_assimp_scene
Definition: CAssimpModel.h:93



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020