TAPs 0.7.7.3
TAPsOpenGLPNTriangleModel.hpp
Go to the documentation of this file.
00001 /******************************************************************************
00002 TAPsOpenGLPNTriangleModel.hpp
00003 
00004 (X <==> Extra)
00005 Class TAPsOpenGLPNTriangleModel is for creating an OpenGL PN-Triangle Model.
00006 
00007 See class XTrigonalModel (in "../Model/TAPsXTrigonalModel.hpp") and
00008 class OpenGLSupport ("../OpenGL/TAPsOpenGLSupport.hpp") for detail.
00009 
00010 SUKITTI PUNAK   (03/25/2005)
00011 UPDATE          (05/29/2005)
00012 ******************************************************************************/
00013 #ifndef TAPs_OPENGL_PN_TRIANGLE_MODEL_HPP
00014 #define TAPs_OPENGL_PN_TRIANGLE_MODEL_HPP
00015 
00016 extern bool gbUseGPU;
00017 
00018 #include <ctime>
00019 #include "TAPsXTrigonalModel.hpp"
00020 
00021 BEGIN_NAMESPACE_TAPs__OpenGL
00022 //=============================================================================
00023 template <typename T>
00024 class OpenGLPNTriangleModel : public /*virtual*/ XTrigonalModel<T> {
00025     //-------------------------------------------------------------------------
00026     // put it through ostream
00027     friend std::ostream & operator<< ( std::ostream &output, OpenGLPNTriangleModel<T> const &o )
00028     {
00029         output  << "\n======================\n"
00030                 <<   "TAPs::OpenGL::OpenGLPNTriangleModel<"
00031                 << typeid(T).name() << "> Class\n"
00032                 <<   "======================\n";
00033         //----------------------------------------------------------------
00034         // Material Node from OpenGLSupport
00035         output  << "\nMaterial Node" << "\n{\n" << o.material << "\n}";
00036         //----------------------------------------------------------------
00037         // Nodes from XPolygonalModel<T>
00038         output  << "\n\nVertices " << o.m_iNoVertices << "\n{";
00039         for ( int i = 0; i < o.m_iNoVertices; ++i ) {
00040             output << "\n  #" << i << "\t" << o.m_prXVertex[i];
00041         }
00042         output  << "\n}";
00043         //----------------------------------------------------------------
00044         // Neighbor vertex ring#1
00045         if ( o.m_pviVertexRing1List ) {
00046             std::vector<int>::const_iterator iterator;
00047             output  << "\n\nVertexRing1 " << o.m_iNoVertices << "\n{";
00048             for ( int i = 0; i < o.m_iNoVertices; ++i ) {
00049                 output << "\n  #" << i;
00050                 for (   iterator = o.m_pviVertexRing1List[i].begin(); 
00051                         iterator != o.m_pviVertexRing1List[i].end();
00052                         ++iterator )
00053                 {
00054                     output << "\t" << *iterator;
00055                 }
00056             }
00057             output  << "\n}";
00058         }
00059         //----------------------------------------------------------------
00060         // Faces Node
00061         output  << "\n\nFaces " << o.m_iNoFaces  << "\n{";
00062         for ( int i = 0; i < o.m_iNoFaces; ++i ) {
00063             output << "\n  #" << i << "\t" << o.m_prFace[i];
00064         }
00065         output  << "\n}";
00066         return output;
00067     }
00068 //-----------------------------------------------------------------------------
00069 // Member Functions  -----------------------------------------------------------
00070 public:
00071     //-------------------------------------------------------------------------
00072     // default constructor
00073     OpenGLPNTriangleModel ();
00074     //-------------------------------------------------------------------------
00075     // destructor
00076     virtual ~OpenGLPNTriangleModel ();
00077     //-------------------------------------------------------------------------
00078     // Initialize (virtual fn from Model class)
00079     // (override Initialize fn from XPolygonalModel class)
00080     virtual void Initialize ();
00081 private:
00082     // Helper Fn for creating and calculating PN-Triangles
00083     void CreateAndCalPNTriangles ();
00084     bool AllocatePNTriangleCoefficients ();     // 10 coefficients/face
00085     bool AllocatePNTriangleNormals  ();         //  6 normals/face
00086     void InitializePNTriangleCoefficients ();   // b300, b030, and b003
00087     void InitializePNTriangleNormals  ();       // n200, n020, and n002
00088     void CalculatePNTriangleCoefficients ();    // all (10-3) coefficients
00089     void CalculatePNTriangleNormals  ();        // all  (6-3) coefficients
00090     void DrawTriBezierPatchNo(int f, int smoothness);
00091 public:
00092     //-------------------------------------------------------------------------
00093     //void DisplayGL()
00094     //virtual void DisplayGL( OpenGL::Enum::DrawMode DM = OpenGL::Enum::POLYGON );
00095 protected:
00096     //-------------------------------------------------------------------------
00097     // Helper Fn
00098     // void DrawGL()
00099     virtual void DrawGL( GLenum );
00100 // Data Members  ---------------------------------------------------------------
00101 //protected:
00102 public:
00103     float * m_prPNTriCoef;      // PNTriCoef pointer   (#faces * 10 * 3)
00104     float * m_prPNTriNormal;    // PNTriNormal pointer (#faces *  6 * 3)
00105 //-----------------------------------------------------------------------------
00106 };
00107 //=============================================================================
00108 END_NAMESPACE_TAPs__OpenGL
00109 //-----------------------------------------------------------------------------
00110 // Include definition if TAPs_USE_EXPORT is not defined
00111 //#if !defined( TAPs_USE_EXPORT )
00112     #include "TAPsOpenGLPNTriangleModel.cpp"
00113 //#endif
00114 //-----------------------------------------------------------------------------
00115 #endif
00116 //345678901234567890123456789012345678901234567890123456789012345678901234567890
00117 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines