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



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019