![]() |
TAPs 0.7.7.3
|
00001 /****************************************************************************** 00002 TAPsExtendedOpenGLPNTriangleVolPresModel.hpp 00003 00004 Class TAPsExtendedOpenGLVolPresPolygonalModel is for a deformable mesh model with 00005 volume preservation. 00006 It memorizes its original shape -- original vertex positions 00007 00008 SUKITTI PUNAK (05/19/2005) 00009 UPDATE (05/25/2005) 00010 ******************************************************************************/ 00011 #ifndef TAPs_EXTENDED_OPENGL_PN_TRIANGLE_VOLPRES_MODEL_HPP 00012 #define TAPs_EXTENDED_OPENGL_PN_TRIANGLE_VOLPRES_MODEL_HPP 00013 00014 #include "TAPsOpenGLPNTriangleVolPresModel.hpp" 00015 00016 BEGIN_NAMESPACE_TAPs__OpenGL 00017 //============================================================================= 00018 template <typename T> 00019 class ExtendedOpenGLPNTriangleVolPresModel : public /*virtual*/ OpenGLPNTriangleVolPresModel<T> { 00020 //------------------------------------------------------------------------- 00021 // put it through ostream 00022 friend std::ostream & operator<< ( std::ostream &output, ExtendedOpenGLPNTriangleVolPresModel<T> const &o ) 00023 { 00024 output << "\n======================\n" 00025 << "TAPs::OpenGL::ExtendedOpenGLPNTriangleVolPresModel<" 00026 << typeid(T).name() << "> Class\n" 00027 << "======================\n"; 00028 //---------------------------------------------------------------- 00029 // Material Node from OpenGLSupport 00030 output << "\nMaterial Node" << "\n{\n" << o.material << "\n}"; 00031 //---------------------------------------------------------------- 00032 // Nodes from XPolygonalModel<T> 00033 output << "\n\nVertices " << o.m_iNoVertices << "\n{"; 00034 for ( int i = 0; i < o.m_iNoVertices; ++i ) { 00035 output << "\n #" << i << "\t" << o.m_prXVertex[i]; 00036 } 00037 output << "\n}"; 00038 //---------------------------------------------------------------- 00039 // Neighbor vertex ring#1 00040 if ( o.m_pviVertexRing1List ) { 00041 std::vector<int>::const_iterator iterator; 00042 output << "\n\nVertexRing1 " << o.m_iNoVertices << "\n{"; 00043 for ( int i = 0; i < o.m_iNoVertices; ++i ) { 00044 output << "\n #" << i; 00045 for ( iterator = o.m_pviVertexRing1List[i].begin(); 00046 iterator != o.m_pviVertexRing1List[i].end(); 00047 ++iterator ) 00048 { 00049 output << "\t" << *iterator; 00050 } 00051 } 00052 output << "\n}"; 00053 } 00054 //---------------------------------------------------------------- 00055 // Faces Node 00056 output << "\n\nFaces " << o.m_iNoFaces << "\n{"; 00057 for ( int i = 0; i < o.m_iNoFaces; ++i ) { 00058 output << "\n #" << i << "\t" << o.m_prFace[i]; 00059 } 00060 output << "\n}"; 00061 return output; 00062 } 00063 //----------------------------------------------------------------------------- 00064 // Member Functions ----------------------------------------------------------- 00065 public: 00066 //------------------------------------------------------------------------- 00067 // default constructor 00068 ExtendedOpenGLPNTriangleVolPresModel(); 00069 //------------------------------------------------------------------------- 00070 // destructor 00071 virtual ~ExtendedOpenGLPNTriangleVolPresModel(); 00072 //------------------------------------------------------------------------- 00073 virtual void Initialize (); // virtual fn from Model class 00074 //------------------------------------------------------------------------- 00075 // A function for bouncing 00076 T FlatCollisionDetectionWithElasticity( T groundHeight ); 00077 //------------------------------------------------------------------------- 00078 // Reset Fn inherited from Model class 00079 virtual void Reset (); 00080 //------------------------------------------------------------------------- 00081 // DisplayGL inherited from OpenGLSupport class 00082 //virtual void DisplayGL ( OpenGL::Enum::DrawMode DM = OpenGL::Enum::POLYGON ); 00083 // Override DisplayGLText 00084 virtual void DisplayGLText ( T x = 0, T y = 0, T z = 0 ); 00085 //------------------------------------------------------------------------- 00086 // PICKING FNs 00087 // Select A Triangle 00088 void SelectATriangle ( 00089 GLuint BUFSIZE, GLuint selectBuf[], GLint &hits, 00090 GLdouble x, GLdouble y, 00091 GLdouble dLeft, GLdouble dRight, 00092 GLdouble dBottom, GLdouble dTop, 00093 GLdouble dNear, GLdouble dFar 00094 ); 00095 void ProcessHits ( GLint hits, GLuint buffer[] ); 00096 protected: 00097 //------------------------------------------------------------------------- 00098 // virtual fns from class VolPresPolygonalModel 00099 //virtual T CalVolume (); 00100 //virtual T CalVolume2 (); 00101 virtual void PreserveVolumeByVertexNormals( T weight[4] ); 00102 //virtual void PreserveVolume ( T weight[4] ); 00103 //------------------------------------------------------------------------- 00104 // Volume Calculation 00105 // calculate volume of PN-Triangles 00106 T CalVolumeOfPNTriangleMesh (); 00107 T CalCubicTriPatchVolume ( 00108 T v[10][3] // I/P: 10 Bezier Ctrl Pts 00109 ); 00110 void CalCubicTriPatchVolume ( 00111 T v[10][3], // I/P: 10 Bezier Ctrl Pts 00112 T dv[10][3], // I/P: 10 Normals 00113 T wgt[4] // O/P: weight 00114 ); 00115 //------------------------------------------------------------------------- 00116 // Volume Calculation 00117 // calculate volume of L2 linear approximation 00118 T CalVolumeOfL2Approximation (); 00119 //------------------------------------------------------------------------- 00120 // Helper Fn: TriBezierDegreeRaiseFrom2to3 00121 void TriBezierDegreeRaiseFrom2to3 ( T deg2In[6][3], T deg3Out[10][3] ); 00122 // Helper Fn: CubicToLinearApproxByL2Tri 00123 void CubicToLinearApproxByL2Tri ( T deg3In[10][3], T deg1Out[3][3] ); 00124 //------------------------------------------------------------------------- 00125 // Override DrawGL 00126 virtual void DrawGL ( GLenum ); 00127 //------------------------------------------------------------------------- 00128 // Protected Fn(s) 00129 void SetOrigVertexPositions (); 00130 void SetFacesToUnFixed (); 00131 void SetVerticesToUnFixed (); 00132 public: 00133 //------------------------------------------------------------------------- 00134 // For Simulation 00135 //----------------------------------------------------------------------------- 00136 // Data Members --------------------------------------------------------------- 00137 protected: 00138 Vector3<T> * m_prOrigVertexPos; // original vertex positions 00139 bool * m_pbFaceFixed; // Status: Fixed/Unfixed status for each face 00140 bool * m_pbVertexFixed; // Status: Fixed/Unfixed status for each vertex 00141 //----------------------------------------------------------------------------- 00142 }; 00143 //============================================================================= 00144 END_NAMESPACE_TAPs__OpenGL 00145 //----------------------------------------------------------------------------- 00146 // Include definition if TAPs_USE_EXPORT is not defined 00147 //#if !defined( TAPs_USE_EXPORT ) 00148 #include "TAPsExtendedOpenGLPNTriangleVolPresModel.cpp" 00149 //#endif 00150 //----------------------------------------------------------------------------- 00151 #endif 00152 //345678901234567890123456789012345678901234567890123456789012345678901234567890 00153 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8