00001 /* +---------------------------------------------------------------------------+ 00002 | The Mobile Robot Programming Toolkit (MRPT) C++ library | 00003 | | 00004 | http://mrpt.sourceforge.net/ | 00005 | | 00006 | Copyright (C) 2005-2009 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/CRenderizable.h> 00032 #include <mrpt/opengl/COpenGLScene.h> 00033 #include <mrpt/utils/CMemoryChunk.h> 00034 00035 namespace mrpt 00036 { 00037 namespace opengl 00038 { 00039 class MRPTDLLIMPEXP C3DSScene; 00040 00041 // This must be added to any CSerializable derived class: 00042 DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE( C3DSScene, CRenderizable ) 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 MRPTDLLIMPEXP C3DSScene : public CRenderizable 00049 { 00050 DEFINE_SERIALIZABLE( C3DSScene ) 00051 00052 public: 00053 00054 /** Render child objects. 00055 */ 00056 void render() const; 00057 00058 /** 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. 00059 * Previous contents are lost. 00060 * If the file ends in ".gz", it'll be automatically decompressed using gzip (see mrpt::compress::zip). 00061 */ 00062 void loadFrom3DSFile( const std::string &file_name ); 00063 00064 /** Initializes all textures in the scene (See opengl::CTexturedPlane::loadTextureInOpenGL) 00065 */ 00066 void initializeAllTextures(); 00067 00068 /** Empty the object */ 00069 void clear(); 00070 00071 /** Evaluates the scene at a given animation time 00072 */ 00073 void evaluateAnimation( double time_anim ); 00074 00075 /** Changes the scale of the 3DS object (X,Y and Z with the same scale) Default=1 */ 00076 void setScale( double s ) { m_scale_x = m_scale_y = m_scale_z = s; } 00077 00078 /** Changes the scale of the 3DS object (X,Y and Z with different scales) */ 00079 void setScale( double sx,double sy, double sz ) { m_scale_x = sx; m_scale_y = sy; m_scale_z = sz; } 00080 00081 /** Enables an extra ambient light */ 00082 void enableExtraAmbientLight(bool enable=true) { m_enable_extra_lighting=enable; } 00083 00084 /* Simulation of ray-trace. */ 00085 virtual bool traceRay(const mrpt::poses::CPose3D &o,double &dist) const; 00086 00087 00088 00089 00090 private: 00091 /** Default constructor 00092 */ 00093 C3DSScene( ); 00094 00095 /** Private, virtual destructor: only can be deleted from smart pointers */ 00096 virtual ~C3DSScene(); 00097 00098 /** A container for automatic deletion of lib3ds's scene when the last reference of the smart_ptr's is destroyed. 00099 */ 00100 struct TImpl3DS 00101 { 00102 TImpl3DS(); 00103 ~TImpl3DS(); 00104 void *file; //!< Lib3dsFile* 00105 }; 00106 00107 /** An internal pointer to the lib3ds library's object of type "Lib3dsFile" 00108 */ 00109 stlplus::smart_ptr<TImpl3DS> m_3dsfile; 00110 00111 /** Scale of the object */ 00112 double m_scale_x,m_scale_y,m_scale_z; 00113 00114 bool m_enable_extra_lighting; 00115 }; 00116 00117 00118 } // end namespace 00119 00120 } // End of namespace 00121 00122 00123 #endif
Page generated by Doxygen 1.5.7.1 for MRPT 0.7.1 SVN: at Mon Aug 17 23:10:56 EDT 2009 |