00001 /* +---------------------------------------------------------------------------+ 00002 | The Mobile Robot Programming Toolkit (MRPT) C++ library | 00003 | | 00004 | http://www.mrpt.org/ | 00005 | | 00006 | Copyright (C) 2005-2011 University of Malaga | 00007 | | 00008 | This software was written by the Machine Perception and Intelligent | 00009 | Robotics Lab, University of Malaga (Spain). | 00010 | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> | 00011 | | 00012 | This file is part of the MRPT project. | 00013 | | 00014 | MRPT is free software: you can redistribute it and/or modify | 00015 | it under the terms of the GNU General Public License as published by | 00016 | the Free Software Foundation, either version 3 of the License, or | 00017 | (at your option) any later version. | 00018 | | 00019 | MRPT is distributed in the hope that it will be useful, | 00020 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 00021 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 00022 | GNU General Public License for more details. | 00023 | | 00024 | You should have received a copy of the GNU General Public License | 00025 | along with MRPT. If not, see <http://www.gnu.org/licenses/>. | 00026 | | 00027 +---------------------------------------------------------------------------+ */ 00028 #ifndef opengl_C3DSScene_H 00029 #define opengl_C3DSScene_H 00030 00031 #include <mrpt/opengl/CRenderizableDisplayList.h> 00032 #include <mrpt/opengl/COpenGLScene.h> 00033 #include <mrpt/utils/CMemoryChunk.h> 00034 00035 namespace mrpt 00036 { 00037 namespace opengl 00038 { 00039 class OPENGL_IMPEXP C3DSScene; 00040 00041 // This must be added to any CSerializable derived class: 00042 DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE_LINKAGE( C3DSScene, CRenderizableDisplayList, OPENGL_IMPEXP ) 00043 00044 /** This element keeps a set of objects imported from a 3DStudio file (.3ds). 00045 * This class uses the opensource library <a href="http://lib3ds.sourceforge.net/" >lib3ds</a> internally. 00046 * \sa opengl::COpenGLScene 00047 * \ingroup mrpt_opengl_grp 00048 */ 00049 class OPENGL_IMPEXP C3DSScene : public CRenderizableDisplayList 00050 { 00051 DEFINE_SERIALIZABLE( C3DSScene ) 00052 00053 00054 public: 00055 00056 /** Render child objects. 00057 */ 00058 void render_dl() const; 00059 00060 /** 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. 00061 * Previous contents are lost. 00062 * If the file ends in ".gz", it'll be automatically decompressed using gzip (see mrpt::compress::zip). 00063 */ 00064 void loadFrom3DSFile( const std::string &file_name ); 00065 00066 /** Initializes all textures in the scene (See opengl::CTexturedPlane::loadTextureInOpenGL) 00067 */ 00068 void initializeAllTextures(); 00069 00070 /** Empty the object */ 00071 void clear(); 00072 00073 /** Evaluates the scene at a given animation time 00074 */ 00075 void evaluateAnimation( double time_anim ); 00076 00077 /** Enables an extra ambient light */ 00078 void enableExtraAmbientLight(bool enable=true) { m_enable_extra_lighting=enable; CRenderizableDisplayList::notifyChange(); } 00079 00080 /* Simulation of ray-trace. */ 00081 virtual bool traceRay(const mrpt::poses::CPose3D &o,double &dist) const; 00082 00083 private: 00084 /** Default constructor 00085 */ 00086 C3DSScene( ); 00087 00088 /** Private, virtual destructor: only can be deleted from smart pointers */ 00089 virtual ~C3DSScene(); 00090 00091 /** A container for automatic deletion of lib3ds's scene when the last reference of the smart_ptr's is destroyed. 00092 */ 00093 struct TImpl3DS 00094 { 00095 TImpl3DS(); 00096 ~TImpl3DS(); 00097 void *file; //!< Lib3dsFile* 00098 }; 00099 00100 /** An internal pointer to the lib3ds library's object of type "Lib3dsFile" 00101 */ 00102 stlplus::smart_ptr<TImpl3DS> m_3dsfile; 00103 00104 /** Scale of the object */ 00105 //double m_scale_x,m_scale_y,m_scale_z; 00106 00107 bool m_enable_extra_lighting; 00108 00109 //float m_light_cons_attenuation; //!< OpenGL Light attenuation factor (default=1.0) 00110 //float m_light_lin_attenuation; //!< OpenGL Light attenuation factor (default=0.0) 00111 //float m_light_quad_attenuation; //!< OpenGL Light attenuation factor (default=0.0) 00112 }; 00113 00114 00115 } // end namespace 00116 00117 } // End of namespace 00118 00119 00120 #endif
| Page generated by Doxygen 1.7.5 for MRPT 0.9.5 SVN: at Thu Oct 13 21:25:36 UTC 2011 |