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



Page generated by Doxygen 1.8.14 for MRPT 1.5.5 Git: e06b63dbf Fri Dec 1 14:41:11 2017 +0100 at lun oct 28 01:31:35 CET 2019