![]() |
TAPs 0.7.7.3
|
00001 /******************************************************************************* 00002 TAPsOpenGLModelSutureMath.hpp 00003 00004 Class OpenGLModelSutureMath is for creating an OpenGL Suture Model. 00005 00006 See class ModelSutureMath (in "../Model/TAPsModelSutureMath.hpp") and 00007 class OpenGLSupport ("../OpenGL/TAPsOpenGLSupport.hpp") for detail. 00008 00009 SUKITTI PUNAK (01/30/2006) 00010 UPDATE (06/15/2006) 00011 *******************************************************************************/ 00012 #ifndef TAPs_OPENGL_SUTURE_MATH_MODEL_HPP 00013 #define TAPs_OPENGL_SUTURE_MATH_MODEL_HPP 00014 00015 #include "TAPsModelSutureMath.hpp" 00016 #include "../OpenGL/TAPsOpenGLUsefulObjs.hpp" 00017 00018 BEGIN_NAMESPACE_TAPs__OpenGL 00019 //============================================================================== 00020 template <typename T> 00021 class OpenGLModelSutureMath : public /*virtual*/ ModelSutureMath<T> { 00022 //------------------------------------------------------------------------- 00023 // put it through ostream 00024 friend std::ostream & operator<< ( std::ostream &output, OpenGLModelSutureMath<T> const &o ) 00025 { 00026 output << "\n======================\n" 00027 << "TAPs::OpenGL::OpenGLModelSutureMath<" 00028 << typeid(T).name() << "> Class\n" 00029 << "======================\n"; 00030 //---------------------------------------------------------------- 00031 output << "\n# of Links " << o.m_iNoLinks 00032 << "\nEach link has length " << o.m_tLinkLength 00033 << " and weight " << o.m_tPointWeight << "\n"; 00034 return output; 00035 } 00036 //------------------------------------------------------------------------------ 00037 // Member Functions ----------------------------------------------------------- 00038 public: 00039 //------------------------------------------------------------------------- 00040 // Constructor(s) 00041 OpenGLModelSutureMath (); 00042 OpenGLModelSutureMath ( int iNoLinks, T tLength, T tWeight, 00043 Vector3<T> & posOfVertex0 = Vector3<T>(), 00044 T radius = 0.05, int numSlices = 12, int numStacks = 3 ); 00045 OpenGLModelSutureMath ( int iNoLinks, T tLength, T tWeight, 00046 Vector3<T> & posOfVertex0, 00047 T radius, 00048 const char * needle1, // Type of Needle (read from file) 00049 int numSlices = 12, int numStacks = 3 ); 00050 /* 00051 OpenGLModelSutureMath ( int iNoLinks, T tLength, T tWeight, 00052 Vector3<T> & posOfVertex0, 00053 T radius, 00054 T tKRatioOfStretchingAllowed, 00055 T tKRatioOfCompressionAllowed, 00056 T tKStratching, 00057 T tKBending, 00058 T tKTwisting, 00059 T tKFriction, 00060 T tKContact, 00061 T tKGravity, 00062 const char * needle1, // Type of Needle (read from file) 00063 int numSlices = 12, int numStacks = 3 ); 00064 //*/ 00065 //------------------------------------------------------------------------- 00066 // Destructor 00067 virtual ~OpenGLModelSutureMath (); 00068 00069 virtual void StrDebug() 00070 { 00071 std::cout << "ModelStrandMath - Vertices:\n"; 00072 for ( int i = 0; i < 4; ++i ) { 00073 std::cout << "\t#" << i; 00074 std::cout << "\t" << m_prVertex[i][0]; 00075 std::cout << "\t" << m_prVertex[i][1]; 00076 std::cout << "\t" << m_prVertex[i][2]; 00077 std::cout << "\n"; 00078 } 00079 00080 std::cout << "ModelStrandMath - Display Vertices:\n"; 00081 for ( int i = 0; i < 4; ++i ) { 00082 std::cout << "\t#" << i; 00083 std::cout << "\t" << m_prDispVertex[i][0]; 00084 std::cout << "\t" << m_prDispVertex[i][1]; 00085 std::cout << "\t" << m_prDispVertex[i][2]; 00086 std::cout << "\n"; 00087 } 00088 } 00089 00090 //------------------------------------------------------------------------- 00091 // Abstract Virtual Fn(s) from OpenGLSupport 00092 // void DisplayGL() 00093 virtual void DisplayGL( OpenGL::Enum::DrawMode DM = OpenGL::Enum::LINES ); 00094 //------------------------------------------------------------------------- 00095 void DisplayGLWithBVHTrees( OpenGL::Enum::DrawMode DM ); 00096 //------------------------------------------------------------------------- 00097 // Abstract Virtual Fn(s) from Model<T> 00098 virtual T GetMaxHalfLength () const { return m_iNoLinks * m_tLinkLength; } 00099 virtual void Initialize () {}; 00100 //------------------------------------------------------------------------- 00101 // Abstract Virtual Fn(s) from ColDetSupport<T> 00102 // Collision Detection Fn(s) 00103 virtual void CalBoundingAABB () {}; 00104 virtual void CalBoundingEllipsoid () {}; 00105 virtual void CalBoundingSphere () {}; 00106 //------------------------------------------------------------------------- 00107 //------------------------------------------------------------------------------ 00108 protected: 00109 //------------------------------------------------------------------------- 00110 // Helper Fn 00111 // void DrawGL() 00112 void DrawNeedles ( OpenGL::Enum::DrawMode ); 00113 void DrawNeedlesWithBVHTrees ( OpenGL::Enum::DrawMode ); 00114 virtual void DrawGL ( GLenum ); 00115 //void DrawTorsions (); 00116 //void DrawOrigShape (); 00117 void SetUpOpenGLDisplayList (); 00118 void DrawBezierCurve (); 00119 // For DEBUG 00120 //void DrawBB (); 00121 //------------------------------------------------------------------- 00122 // Data Members 00123 GLuint m_uiDisplayList; // For drawing Glut Cylinder & Sphere 00124 int m_iNumSlices; // around the cylinder radius 00125 int m_iNumStacks; // along the cylinder body 00126 00127 //------------------------------------------------------------------------------ 00128 }; 00129 //============================================================================== 00130 END_NAMESPACE_TAPs__OpenGL 00131 //------------------------------------------------------------------------------ 00132 // Include definition if TAPs_USE_EXPORT is not defined 00133 //#if !defined( TAPs_USE_EXPORT ) 00134 #include "TAPsOpenGLModelSutureMath.cpp" 00135 //#endif 00136 //------------------------------------------------------------------------------ 00137 #endif 00138 //345678901234567890123456789012345678901234567890123456789012345678901234567890 00139 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8