Main MRPT website > C++ reference for MRPT 1.5.9
C3DSScene.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_C3DSScene_H
10 #define opengl_C3DSScene_H
11 
15 #include <memory>
16 
17 namespace mrpt
18 {
19  namespace opengl
20  {
21  // This must be added to any CSerializable derived class:
22  DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE( C3DSScene, CRenderizableDisplayList, OPENGL_IMPEXP )
23 
24  /** This element keeps a set of objects imported from a 3DStudio file (.3ds).
25  * This class uses the opensource library <a href="http://lib3ds.sourceforge.net/" >lib3ds</a> internally.
26  * \sa opengl::COpenGLScene
27  * \ingroup mrpt_opengl_grp
28  */
30  {
32 
33 
34  public:
35 
36  /** Render child objects.
37  */
38  void render_dl() const MRPT_OVERRIDE;
39 
40  /** Evaluates the bounding box of this object (including possible children) in the coordinate frame of the object parent. */
41  void getBoundingBox(mrpt::math::TPoint3D &bb_min, mrpt::math::TPoint3D &bb_max) const MRPT_OVERRIDE;
42 
43  /** Loads a scene from a 3DS file (3D Studio format) into this object, from either plain .3ds format, or in gzip compressed .3ds.gz format.
44  * Previous contents are lost.
45  * If the file ends in ".gz", it'll be automatically decompressed using gzip (see mrpt::compress::zip).
46  */
47  void loadFrom3DSFile( const std::string &file_name );
48 
49  /** Initializes all textures in the scene (See opengl::CTexturedPlane::loadTextureInOpenGL)
50  */
51  void initializeAllTextures();
52 
53  /** Empty the object */
54  void clear();
55 
56  /** Evaluates the scene at a given animation time
57  */
58  void evaluateAnimation( double time_anim );
59 
60  /** Enables an extra ambient light */
61  void enableExtraAmbientLight(bool enable=true) { m_enable_extra_lighting=enable; CRenderizableDisplayList::notifyChange(); }
62 
63  /* Simulation of ray-trace. */
64  bool traceRay(const mrpt::poses::CPose3D &o,double &dist) const MRPT_OVERRIDE;
65 
66  private:
67  /** Default constructor
68  */
69  C3DSScene( );
70 
71  /** Private, virtual destructor: only can be deleted from smart pointers */
72  virtual ~C3DSScene();
73 
74  /** A container for automatic deletion of lib3ds's scene when the last reference of the smart_ptr's is destroyed.
75  */
76  struct TImpl3DS
77  {
78  TImpl3DS();
79  ~TImpl3DS();
80  void *file; //!< Lib3dsFile*
81  };
82 
83  /** An internal pointer to the lib3ds library's object of type "Lib3dsFile"
84  */
85  std::shared_ptr<TImpl3DS> m_3dsfile;
86 
87  /** Scale of the object */
88  //double m_scale_x,m_scale_y,m_scale_z;
89  mrpt::math::TPoint3D m_bbox_min, m_bbox_max; //!< Bounding box
90 
92 
93  //float m_light_cons_attenuation; //!< OpenGL Light attenuation factor (default=1.0)
94  //float m_light_lin_attenuation; //!< OpenGL Light attenuation factor (default=0.0)
95  //float m_light_quad_attenuation; //!< OpenGL Light attenuation factor (default=0.0)
96  };
98 
99 
100  } // end namespace
101 
102 } // End of namespace
103 
104 
105 #endif
#define MRPT_OVERRIDE
C++11 "override" for virtuals:
std::shared_ptr< TImpl3DS > m_3dsfile
An internal pointer to the lib3ds library&#39;s object of type "Lib3dsFile".
Definition: C3DSScene.h:85
void * file
Lib3dsFile*.
Definition: C3DSScene.h:80
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:1989
EIGEN_STRONG_INLINE void notifyChange() const
Must be called to notify that the object has changed (so, the display list must be updated) ...
STL namespace.
mrpt::math::TPoint3D m_bbox_min
Scale of the object.
Definition: C3DSScene.h:89
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...
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 container for automatic deletion of lib3ds&#39;s scene when the last reference of the smart_ptr&#39;s is de...
Definition: C3DSScene.h:76
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
Definition: CPose3D.h:72
Lightweight 3D point.
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE_LINKAGE(class_name, base_name, _LINKAGE_)
This element keeps a set of objects imported from a 3DStudio file (.3ds).
Definition: C3DSScene.h:29



Page generated by Doxygen 1.8.14 for MRPT 1.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020