00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef opengl_COpenGLScene_H
00029 #define opengl_COpenGLScene_H
00030
00031 #include <mrpt/opengl/CRenderizable.h>
00032 #include <mrpt/opengl/COpenGLViewport.h>
00033
00034 namespace mrpt
00035 {
00038 namespace opengl
00039 {
00040
00041 DEFINE_SERIALIZABLE_PRE( COpenGLScene )
00042
00043
00065 class MRPTDLLIMPEXP COpenGLScene : public mrpt::utils::CSerializable
00066 {
00067 DEFINE_SERIALIZABLE( COpenGLScene )
00068 public:
00071 COpenGLScene();
00072
00075 virtual ~COpenGLScene();
00076
00079 COpenGLScene & operator =( const COpenGLScene &obj );
00080
00083 COpenGLScene( const COpenGLScene &obj );
00084
00090 void insert( const CRenderizablePtr &newObject, const std::string &viewportName = std::string("main") );
00091
00096 COpenGLViewportPtr createViewport( const std::string &viewportName );
00097
00100 COpenGLViewportPtr getViewport( const std::string &viewportName ) const;
00101
00104 void render() const;
00105
00106 size_t viewportsCount() const { return m_viewports.size(); }
00107
00110 void clear( bool createMainViewport = true );
00111
00115 void enableFollowCamera( bool enabled ) { m_followCamera = enabled; }
00116
00120 bool followCamera() const { return m_followCamera; }
00121
00124 CRenderizablePtr getByName( const std::string &str, const std::string &viewportName = std::string("main") );
00125
00133 template <typename T>
00134 typename T::SmartPtr getByClass( const size_t &ith = 0 ) const
00135 {
00136 MRPT_TRY_START;
00137 for (TListViewports::const_iterator it = m_viewports.begin();it!=m_viewports.end();it++)
00138 {
00139 typename T::SmartPtr o = (*it)->getByClass<T>(ith);
00140 if (o.present()) return o;
00141 }
00142 return typename T::SmartPtr();
00143 MRPT_TRY_END;
00144 }
00145
00146
00149 void removeObject( const CRenderizablePtr &obj, const std::string &viewportName = std::string("main") );
00150
00153 void initializeAllTextures();
00154
00157 void dumpListOfObjects( utils::CStringList &lst );
00158
00163 bool saveToFile(const std::string &fil) const;
00164
00169 bool loadFromFile(const std::string &fil);
00170
00173 bool traceRay(const mrpt::poses::CPose3D&o,float &dist) const;
00174
00175 protected:
00176 bool m_followCamera;
00177
00178 typedef std::vector<COpenGLViewportPtr> TListViewports;
00179
00182 TListViewports m_viewports;
00183 };
00184
00185 }
00186
00187 }
00188
00189
00190 #endif