Main MRPT website > C++ reference for MRPT 1.4.0
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-2016, 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
17namespace mrpt
18{
19 namespace opengl
20 {
21
22
23 // This must be added to any CSerializable derived class:
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.
70 TInfoPerTexture() : id_idx(std::string::npos) {}
71 };
72
73 private:
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 */
80 {
83 void *scene; //!< aiScene*
84 };
86
87 mrpt::math::TPoint3D m_bbox_min, m_bbox_max; //!< Bounding box
88
89 mutable bool m_textures_loaded;
90 std::string m_modelPath;
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 DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
#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...
This class can load & render 3D models in a number of different formats (requires the library assimp)...
Definition: CAssimpModel.h:43
void render_dl() const MRPT_OVERRIDE
Render child objects.
mrpt::math::TPoint3D m_bbox_max
Bounding box.
Definition: CAssimpModel.h:87
std::vector< unsigned int > m_textureIds
Definition: CAssimpModel.h:91
virtual ~CAssimpModel()
Private, virtual destructor: only can be deleted from smart pointers.
std::map< std::string, TInfoPerTexture > m_textureIdMap
Definition: CAssimpModel.h:93
stlplus::smart_ptr< TImplAssimp > m_assimp_scene
Definition: CAssimpModel.h:85
A renderizable object suitable for rendering with OpenGL's display lists.
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
Definition: mrpt_macros.h:28
struct BASE_IMPEXP CImagePtr
Definition: CImage.h:52
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
STL namespace.
Lightweight 3D point.
A container for automatic deletion of lib3ds's scene when the last reference of the smart_ptr's is de...
Definition: CAssimpModel.h:80
size_t id_idx
indices in m_textureIds. string::npos for non-initialized ones.
Definition: CAssimpModel.h:68



Page generated by Doxygen 1.9.6 for MRPT 1.4.0 SVN: at Wed Feb 15 01:46:32 UTC 2023