![]() |
TAPs 0.7.7.3
|
00001 /****************************************************************************** 00002 TAPsReadModels.hpp 00003 ******************************************************************************/ 00007 /****************************************************************************** 00008 SUKITTI PUNAK (11/11/2004) 00009 UPDATE (04/29/2007) 00010 ******************************************************************************/ 00011 #ifndef TAPs_READ_MODELS_HPP 00012 #define TAPs_READ_MODELS_HPP 00013 //----------------------------------------------------------------------------- 00014 // Model Headers 00015 // All models should be included here! 00016 // !!!Base models are the model that must be read by a model reader!!! 00017 // Model Hierarchy (base model first then its derive classes) 00018 // PolygonalModel 00019 // (Actually, base classes are the ones that have to be included, 00020 // but all models are included here so that include TAPsReadModels.hpp alone 00021 // does include all of them. Bad effect is the code is bulky if not all 00022 // types 00023 #include "../OpenGLModel/TAPsOpenGLModelList.hpp" 00024 //----------------------------------------------------------------------------- 00025 #include "../Misc/TAPsUsefulFns.hpp" 00026 //----------------------------------------------------------------------------- 00027 // File Manipulations 00028 #include <iomanip> 00029 #include <cmath> 00030 #include <fstream> 00031 #include <cstring> // for string token strtok 00032 #include <cstdlib> // for converting string to numeric (strtod, strtol, strtoul) 00033 //----------------------------------------------------------------------------- 00034 00035 BEGIN_NAMESPACE_TAPs 00036 //============================================================================= 00037 // Class MeshData 00038 //----------------------------------------------------------------------------- 00044 template <typename T> 00045 class MeshData { 00046 public: 00047 //------------------------------------------------------------------- 00048 // Data Members 00049 // Vertex: position and normal 00050 std::vector< Vertex<T> * > VertexList; 00051 // XVertex: position, normal, and first ring vertices 00052 std::vector< XVertex<T> * > XVertexList; 00053 // Face: vertex list, vertex texture coordinate list, face normal 00054 std::vector< Face<T> * > FaceList; 00055 //--------------------------------------- 00056 std::vector< Vector3<T> > PositionList; 00057 std::vector< Vector3<T> > NormalList; 00058 //--------------------------------------- 00059 // Texture Coordinates: 00060 std::vector< T > TextureCoor1DList; 00061 std::vector< Vector2<T> > TextureCoor2DList; 00062 std::vector< Vector3<T> > TextureCoor3DList; 00063 //------------------------------------------------------------------- 00064 // Member Functions 00068 void ClearAll () { 00069 VertexList.clear(); 00070 XVertexList.clear(); 00071 FaceList.clear(); 00072 //--------------------------------------- 00073 PositionList.clear(); 00074 NormalList.clear(); 00075 //--------------------------------------- 00076 TextureCoor1DList.clear(); 00077 TextureCoor2DList.clear(); 00078 TextureCoor3DList.clear(); 00079 //--------------------------------------- 00080 //VertexList.~vector<T>(); 00081 //XVertexList.~vector<T>(); 00082 //FaceList.~vector<T>(); 00083 //--------------------------------------- 00084 //PositionList.~vector(); 00085 //NormalList.~vector(); 00086 //--------------------------------------- 00087 //textureCoor1DList.~vector<T>(); 00088 //textureCoor2DList.~vector<T>(); 00089 //textureCoor3DList.~vector<T>(); 00090 } 00091 }; 00092 //----------------------------------------------------------------------------- 00093 //============================================================================= 00094 END_NAMESPACE_TAPs 00095 00096 //============================================================================= 00097 //----------------------------------------------------------------------------- 00098 // File Readers 00099 // Need to be included last since they require Model Headers 00100 // and File Manipulations. 00101 #include "../OpenGLModelFromFile/TAPsReadDot10.hpp" 00102 #include "../OpenGLModelFromFile/TAPsReadTAPs.hpp" 00103 #include "../OpenGLModelFromFile/TAPsRead3dsMaxASC.hpp" 00104 #include "../OpenGLModelFromFile/TAPsRead3dsMaxASE.hpp" 00105 #include "../OpenGLModelFromFile/TAPsReadPly.hpp" 00106 #include "../OpenGLModelFromFile/TAPsReadOff.hpp" 00107 #include "../OpenGLModelFromFile/TAPsReadObj.hpp" 00108 //----------------------------------------------- 00109 // For Class MultiMeshModelWithMBV 00110 #include "../IO/TAPsReadTAPsMBV.hpp" // To read .MBV call ReadTAPsMBV<T>::ReadFile( ... ) 00111 //----------------------------------------------- 00112 // For 3D Volume Data 00113 #include "../IO/TAPsRead3DRaw.hpp" // To read .raw call Read3DRaw<T>::ReadFile( ... ) 00114 //----------------------------------------------------------------------------- 00115 //============================================================================= 00116 00117 BEGIN_NAMESPACE_TAPs 00118 //============================================================================= 00119 // CLASS: ReadModels ********************************************************** 00120 //----------------------------------------------------------------------------- 00121 template <typename T> 00122 class ReadModels { 00123 // Member Functions ---------------------------------------------------------- 00124 public: 00125 //------------------------------------------------------------------------- 00135 static bool readFile ( const char * fileName, OpenGL::OpenGLModel<T> * const prModel ); 00136 static bool readFile ( const char * fileName, OpenGL::MultiMeshModel<T> * const prModel, 00137 TAPs::Enum::ModelType eModelType = TAPs::Enum::MODEL_TYPE_XPOLYGONAL ); 00138 static bool readFile ( const char * fileName, OpenGL::MultiMeshModelWithMBV<T> * const prModel, 00139 TAPs::Enum::ModelType eModelType = TAPs::Enum::MODEL_TYPE_XPOLYGONAL ); 00140 //------------------ 00141 #if defined(__gl_h_) || defined(__GL_H__) 00142 static bool readFile ( const char * fileName, std::vector< OpenGL::OpenGLHETriMeshOneModelMultiParts<T> * > & modelList ); 00143 #endif 00144 //------------------------------------------- 00145 static bool ReadFile ( std::string fileName, OpenGL::OpenGLModel<T> * const prModel ) 00146 { return readFile( fileName.c_str(), prModel ); } 00147 static bool ReadFile ( std::string fileName, OpenGL::MultiMeshModel<T> * const prModel, 00148 TAPs::Enum::ModelType eModelType = TAPs::Enum::MODEL_TYPE_XPOLYGONAL ) 00149 { return readFile( fileName.c_str(), prModel, eModelType ); } 00150 static bool ReadFile ( std::string fileName, OpenGL::MultiMeshModelWithMBV<T> * const prModel, 00151 TAPs::Enum::ModelType eModelType = TAPs::Enum::MODEL_TYPE_XPOLYGONAL ) 00152 { return readFile( fileName.c_str(), prModel, eModelType ); } 00153 00154 static bool ReadFile ( const char * fileName, OpenGL::OpenGLModel<T> * const prModel ) 00155 { return readFile( fileName, prModel ); } 00156 static bool ReadFile ( const char * fileName, OpenGL::MultiMeshModel<T> * const prModel, 00157 TAPs::Enum::ModelType eModelType = TAPs::Enum::MODEL_TYPE_XPOLYGONAL ) 00158 { return readFile( fileName, prModel, eModelType ); } 00159 static bool ReadFile ( const char * fileName, OpenGL::MultiMeshModelWithMBV<T> * const prModel, 00160 TAPs::Enum::ModelType eModelType = TAPs::Enum::MODEL_TYPE_XPOLYGONAL ) 00161 { return readFile( fileName, prModel, eModelType ); } 00162 //------------------ 00163 #if defined(__gl_h_) || defined(__GL_H__) 00164 static bool ReadFile ( const char * fileName, std::vector< OpenGL::OpenGLHETriMeshOneModelMultiParts<T> * > & modelList ) 00165 { return readFile( fileName, modelList ); } 00166 #endif 00167 //------------------------------------------- 00168 //------------------------------------------- 00169 // Data Members --------------------------------------------------------------- 00170 public: 00171 private: 00172 }; // CLASS END: ReadModels *************************************************** 00173 //============================================================================= 00174 //----------------------------------------------------------------------------- 00175 //============================================================================= 00176 END_NAMESPACE_TAPs 00177 //----------------------------------------------------------------------------- 00178 // Include definition if TAPs_USE_EXPORT is not defined 00179 //#if !defined( TAPs_USE_EXPORT ) 00180 #include "TAPsReadModels.cpp" 00181 //#endif 00182 //----------------------------------------------------------------------------- 00183 #endif 00184 //34567890123456789012345678901234567890123456789012345678901234567890123456789 00185 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----