TAPs 0.7.7.3
TAPsExtendedOpenGLVolPresPolygonalModel.hpp
Go to the documentation of this file.
00001 /******************************************************************************
00002 TAPsExtendedOpenGLVolPresPolygonalModel.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   (04/25/2005)
00009 UPDATE          (05/15/2005)
00010 ******************************************************************************/
00011 #ifndef TAPs_EXTENDED_OPENGL_VOL_PRES_POLYGONAL_MODEL_HPP
00012 #define TAPs_EXTENDED_OPENGL_VOL_PRES_POLYGONAL_MODEL_HPP
00013 
00014 #include "TAPsOpenGLVolPresPolygonalModel.hpp"
00015 
00016 BEGIN_NAMESPACE_TAPs__OpenGL
00017 //=============================================================================
00018 template <typename T>
00019 class ExtendedOpenGLVolPresPolygonalModel : public /*virtual*/ OpenGLVolPresPolygonalModel<T> {
00020     //-------------------------------------------------------------------------
00021     // put it through ostream
00022     friend std::ostream & operator<< ( std::ostream &output, ExtendedOpenGLVolPresPolygonalModel<T> const &o )
00023     {
00024         output  << "\n======================\n"
00025                 <<   "TAPs::OpenGL::ExtendedOpenGLVolPresPolygonalModel<"
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     ExtendedOpenGLVolPresPolygonalModel();
00069     //-------------------------------------------------------------------------
00070     // destructor
00071     virtual ~ExtendedOpenGLVolPresPolygonalModel();
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     void DisplayGLText ( T x = 0, T y = 0, T z = 0 );
00085     //-------------------------------------------------------------------------
00086     // PICKING FNs
00087     //---------------------------------------------------------------
00088     // Fix/Unfix vertices in a box
00089     inline void FixVerticesInABox    ( T minX, T maxX, T minY, T maxY, T minZ, T maxZ )
00090     {  FixUnFixVerticesInABox( true, minX, maxX, minY, maxY, minZ, maxZ ); }
00091     inline void UnfixVerticesInABox ( T minX, T maxX, T minY, T maxY, T minZ, T maxZ )
00092     {  FixUnFixVerticesInABox( false, minX, maxX, minY, maxY, minZ, maxZ ); }
00093 protected:
00094     void FixUnFixVerticesInABox ( bool isToFix, T minX, T maxX, T minY, T maxY, T minZ, T maxZ );
00095 public:
00096     // Select A Triangle
00097     void SelectATriangle ( 
00098         bool isSelect,  // true --> select; false --> deselect the hit triangle
00099         GLuint BUFSIZE, GLuint selectBuf[], GLint &hits, 
00100         GLdouble x, GLdouble y, 
00101         GLdouble dLeft,     GLdouble dRight, 
00102         GLdouble dBottom,   GLdouble dTop, 
00103         GLdouble dNear,     GLdouble dFar,
00104         GLdouble pickSize = 1.0, 
00105         const GLdouble * const worldRotation = NULL, 
00106         const GLdouble * const modelRotation = NULL 
00107     );
00108     void ProcessHits ( GLint hits, GLuint buffer[], bool isSelect );
00109 protected:
00110     //-------------------------------------------------------------------------
00111     // Override DrawGL
00112     virtual void DrawGL ( GLenum );
00113     //-------------------------------------------------------------------------
00114     // Protected Fn(s)
00115     void SetOrigVertexPositions ();
00116     void SetFacesToUnFixed ();
00117     void SetVerticesToUnFixed ();
00118 public:
00119     //-------------------------------------------------------------------------
00120     // For Simulation
00121 //-----------------------------------------------------------------------------
00122 // Data Members  ---------------------------------------------------------------
00123 protected:
00124     Vector3<T> *    m_prOrigVertexPos;  // original vertex positions
00125     bool *  m_pbFaceFixed;      // Status: Fixed/Unfixed status for each face
00126     bool *  m_pbVertexFixed;    // Status: Fixed/Unfixed status for each vertex
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 "TAPsExtendedOpenGLVolPresPolygonalModel.cpp"
00135 //#endif
00136 //-----------------------------------------------------------------------------
00137 #endif
00138 //345678901234567890123456789012345678901234567890123456789012345678901234567890
00139 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines