Main MRPT website > C++ reference for MRPT 1.5.6
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 
22 
23  // This must be added to any CSerializable derived class:
24  DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE( CAssimpModel, CRenderizableDisplayList, OPENGL_IMPEXP )
25 
26  /** This class can load & render 3D models in a number of different formats (requires the library assimp).
27  * - All supported formats: http://assimp.sourceforge.net/main_features_formats.html
28  * - Most common ones: AutoCAD DXF ( .dxf ), Collada ( .dae ), Blender 3D ( .blend ), 3ds Max 3DS ( .3ds ), 3ds Max ASE ( .ase ), Quake I ( .mdl ), Quake II ( .md2 ), Quake III Mesh ( .md3 ), etc.
29  *
30  * Models are loaded via CAssimpModel::loadScene()
31  *
32  * <div align="center">
33  * <table border="0" cellspan="4" cellspacing="4" style="border-width: 1px; border-style: solid;">
34  * <tr> <td> mrpt::opengl::CAssimpModel </td> <td> \image html 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  void render_dl() const MRPT_OVERRIDE; //!< Render child objects
48 
49  /** Evaluates the bounding box of this object (including possible children) in the coordinate frame of the object parent. */
50  void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max) const MRPT_OVERRIDE;
51 
52  /** Loads a scene from a file in any supported file.
53  * \exception std::runtime_error On any error during loading or importing the file.
54  */
55  void loadScene( const std::string &file_name );
56 
57  /** Empty the object */
58  void clear();
59 
60  /** Evaluates the scene at a given animation time */
61  void evaluateAnimation( double time_anim );
62 
63  /* Simulation of ray-trace. */
64  bool traceRay(const mrpt::poses::CPose3D &o,double &dist) const MRPT_OVERRIDE;
65 
67  {
68  size_t id_idx; //!< indices in \a m_textureIds. string::npos for non-initialized ones.
69  mrpt::utils::CImagePtr img_rgb, img_alpha;
70  TInfoPerTexture() : id_idx(std::string::npos) {}
71  };
72 
73  private:
74  CAssimpModel( );
75  virtual ~CAssimpModel(); //!< Private, virtual destructor: only can be deleted from smart pointers
76 
77  /** A container for automatic deletion of lib3ds's scene when the last reference of the smart_ptr's is destroyed.
78  */
79  struct TImplAssimp
80  {
81  TImplAssimp();
82  ~TImplAssimp();
83  void *scene; //!< aiScene*
84  };
85  stlplus::smart_ptr<TImplAssimp> m_assimp_scene;
86 
87  mrpt::math::TPoint3D m_bbox_min, m_bbox_max; //!< Bounding box
88 
89  mutable bool m_textures_loaded;
91  mutable std::vector<unsigned int> m_textureIds;
92 
93  mutable std::map<std::string,TInfoPerTexture> m_textureIdMap;
94 
95  };
97 
98  } // end namespace
99 } // End of namespace
100 
101 #endif
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
bool BASE_IMPEXP traceRay(const std::vector< TPolygonWithPlane > &vec, const mrpt::poses::CPose3D &pose, double &dist)
Fast ray tracing method using polygons&#39; properties.
Definition: geometry.cpp:1996
size_t id_idx
indices in m_textureIds. string::npos for non-initialized ones.
Definition: CAssimpModel.h:68
STL namespace.
mrpt::math::TPoint3D m_bbox_min
Definition: CAssimpModel.h:87
void clear()
Clear the contents of this container.
Definition: ts_hash_map.h:113
A renderizable object suitable for rendering with OpenGL&#39;s display lists.
#define DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
This declaration must be inserted in all CSerializable classes definition, before the class declarati...
GLsizei const GLchar ** string
Definition: glext.h:3919
std::map< std::string, TInfoPerTexture > m_textureIdMap
Definition: CAssimpModel.h:93
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...
stlplus::smart_ptr< TImplAssimp > m_assimp_scene
Definition: CAssimpModel.h:85
Lightweight 3D point.
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
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:79
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:91



Page generated by Doxygen 1.8.14 for MRPT 1.5.6 Git: 4c65e8431 Tue Apr 24 08:18:17 2018 +0200 at lun oct 28 01:35:26 CET 2019