![]() |
TAPs 0.7.7.3
|
00001 /****************************************************************************** 00002 PolygonalModel.hpp 00003 00004 A (Generic) Polygonal Model contains: 00005 char * m_pcObjectName; // object name 00006 int m_iNoVertices; // # of vertices 00007 int m_iNoFaces; // # of faces 00008 int m_iNoTexCoords; // # of texture coordinates 00009 Vertex<T> * m_prVertex; // Vertex pointers 00010 Face<T> * m_prFace; // Face pointers 00011 00012 Each property should be set explicitly 00013 including the NORMAL of each m_prVertex and m_prFace 00014 except the following: 00015 - m_pcObjectName (is for identification, not important) 00016 - m_iNoTexCoords (must be set if use with texture) 00017 00018 SUKITTI PUNAK (10/31/2004) 00019 UPDATE (02/12/2006) 00020 ******************************************************************************/ 00021 #ifndef TAPs_POLYGONAL_MODEL_HPP 00022 #define TAPs_POLYGONAL_MODEL_HPP 00023 00024 #include "TAPsOpenGLMeshModel.hpp" 00025 #include "../GeometricDataStructure/TAPsVertex.hpp" 00026 #include "../GeometricDataStructure/TAPsFace.hpp" 00027 00028 BEGIN_NAMESPACE_TAPs__OpenGL 00029 //============================================================================= 00030 template <typename T> 00031 class PolygonalModel : public /*virtual*/ OpenGLMeshModel<T> { 00032 //------------------------------------------------------------------------- 00033 // (Friend Fn) put it through ostream 00034 friend std::ostream & operator<< ( std::ostream &output, PolygonalModel<T> const &o ) 00035 { 00036 output << "\n======================\n" 00037 << "TAPs::PolygonalModel<" 00038 << typeid(T).name() << "> Class:\n" 00039 << "======================\n"; 00040 //---------------------------------------------------------------- 00041 // Material Node 00042 output << "\nMaterial Node" << "\n{\n" << o.material << "\n}"; 00043 //---------------------------------------------------------------- 00044 // Vertices Node 00045 output << "\n\nVertices " << o.m_iNoVertices << "\n{"; 00046 for ( int i = 0; i < o.m_iNoVertices; ++i ) { 00047 output << "\n #" << i << "\t" << o.m_prVertex[i]; 00048 } 00049 output << "\n}"; 00050 //---------------------------------------------------------------- 00051 // Faces Node 00052 output << "\n\nFaces " << o.m_iNoFaces << "\n{"; 00053 for ( int i = 0; i < o.m_iNoFaces; ++i ) { 00054 output << "\n #" << i << "\t" << o.m_prFace[i]; 00055 } 00056 output << "\n}"; 00057 return output; 00058 } 00059 //----------------------------------------------------------------------------- 00060 // Member Functions ------------------------------------------------------------ 00061 public: 00062 //------------------------------------------------------------------------- 00063 // default constructor 00064 PolygonalModel (); 00065 //------------------------------------------------------------------------- 00066 // destructor 00067 virtual ~PolygonalModel (); 00068 //------------------------------------------------------------------------- 00069 // Virtual Fns from Model class 00070 virtual void Initialize (); 00071 virtual T GetMaxHalfLength () const; // get half length 00072 virtual void ApplyAndResetTransform (); 00073 //------------------------------------------------------------------------- 00074 // Calculate and set the normals 00075 virtual void CalAndSetNormals(); 00076 protected: 00077 //------------------------------------------------------------------------- 00078 // Helper Fn(s) 00079 virtual inline void CalAndSetFaceNormalsNotNormalized (); 00080 virtual inline void NormalizeFaceNormals (); 00081 //------------------------------------------------------------------------- 00082 // Virtual Fns from Collision Detection from ColDetSupport class 00083 virtual void CalBoundingAABB (); 00084 virtual void CalBoundingEllipsoid (); 00085 virtual void CalBoundingSphere (); 00086 //------------------------------------------------------------------------- 00087 public: 00088 //------------------------------------------------------------------------- 00089 // Get/Set Fn(s) 00090 inline Vertex<T> * const GetVertexList() const { return m_prVertex; } 00091 inline Face<T> * const GetFaceList() const { return m_prFace; } 00092 inline void SetVertexList( Vertex<T> *p ) { m_prVertex = p; } 00093 inline void SetFaceList( Face<T> *p ) { m_prFace = p; } 00094 //------------------------------------------------------------------------- 00095 // New/Delete Fn(s) 00096 inline void NewVertexListByNoVertices (); 00097 inline void NewFaceListByNoFaces (); 00098 //----------------------------------------------------------------------------- 00099 // Data Members --------------------------------------------------------------- 00100 protected: 00101 Vertex<T> * m_prVertex; // Vertex pointers 00102 Face<T> * m_prFace; // Face pointers 00103 }; 00104 //============================================================================= 00105 END_NAMESPACE_TAPs__OpenGL 00106 //----------------------------------------------------------------------------- 00107 // Include definition if TAPs_USE_EXPORT is not defined 00108 //#if !defined( TAPs_USE_EXPORT ) 00109 #include "TAPsPolygonalModel.cpp" 00110 //#endif 00111 //----------------------------------------------------------------------------- 00112 #endif 00113 //345678901234567890123456789012345678901234567890123456789012345678901234567890 00114 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8