00001 /* +---------------------------------------------------------------------------+ 00002 | The Mobile Robot Programming Toolkit (MRPT) C++ library | 00003 | | 00004 | http://mrpt.sourceforge.net/ | 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 */ 00048 class OPENGL_IMPEXP C3DSScene : public CRenderizableDisplayList 00049 { 00050 DEFINE_SERIALIZABLE( C3DSScene ) 00051 00052 00053 public: 00054 00055 /** Render child objects. 00056 */ 00057 void render_dl() const; 00058 00059 /** 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. 00060 * Previous contents are lost. 00061 * If the file ends in ".gz", it'll be automatically decompressed using gzip (see mrpt::compress::zip). 00062 */ 00063 void loadFrom3DSFile( const std::string &file_name ); 00064 00065 /** Initializes all textures in the scene (See opengl::CTexturedPlane::loadTextureInOpenGL) 00066 */ 00067 void initializeAllTextures(); 00068 00069 /** Empty the object */ 00070 void clear(); 00071 00072 /** Evaluates the scene at a given animation time 00073 */ 00074 void evaluateAnimation( double time_anim ); 00075 00076 /** Enables an extra ambient light */ 00077 void enableExtraAmbientLight(bool enable=true) { m_enable_extra_lighting=enable; CRenderizableDisplayList::notifyChange(); } 00078 00079 /* Simulation of ray-trace. */ 00080 virtual bool traceRay(const mrpt::poses::CPose3D &o,double &dist) const; 00081 00082 private: 00083 /** Default constructor 00084 */ 00085 C3DSScene( ); 00086 00087 /** Private, virtual destructor: only can be deleted from smart pointers */ 00088 virtual ~C3DSScene(); 00089 00090 /** A container for automatic deletion of lib3ds's scene when the last reference of the smart_ptr's is destroyed. 00091 */ 00092 struct TImpl3DS 00093 { 00094 TImpl3DS(); 00095 ~TImpl3DS(); 00096 void *file; //!< Lib3dsFile* 00097 }; 00098 00099 /** An internal pointer to the lib3ds library's object of type "Lib3dsFile" 00100 */ 00101 stlplus::smart_ptr<TImpl3DS> m_3dsfile; 00102 00103 /** Scale of the object */ 00104 //double m_scale_x,m_scale_y,m_scale_z; 00105 00106 bool m_enable_extra_lighting; 00107 00108 //float m_light_cons_attenuation; //!< OpenGL Light attenuation factor (default=1.0) 00109 //float m_light_lin_attenuation; //!< OpenGL Light attenuation factor (default=0.0) 00110 //float m_light_quad_attenuation; //!< OpenGL Light attenuation factor (default=0.0) 00111 }; 00112 00113 00114 } // end namespace 00115 00116 } // End of namespace 00117 00118 00119 #endif
Page generated by Doxygen 1.7.3 for MRPT 0.9.4 SVN:exported at Tue Jan 25 21:56:31 UTC 2011 |