TAPs 0.7.7.3
TAPsPNTriangle.hpp
Go to the documentation of this file.
00001 /******************************************************************************
00002 TAPsPNTriangle.hpp
00003 
00004 A static class for PNTriangle (with option drawing by OpenGL).
00005 
00006 SUKITTI PUNAK   (06/12/2007)
00007 UPDATE          (06/12/2007)
00008 ******************************************************************************/
00009 /******************************************************************************
00010 A PN-Triangle
00011 =============
00012 // Coefficients or Control Points
00013 // ------------------------------
00014 //                    b003                              9
00015 //                    /  \
00016 //                  /      \
00017 //               b102      b012                       7   8
00018 //              /              \           <===>    
00019 //            /                  \
00020 //         b201       b111       b021               4   5   6
00021 //        /                          \
00022 //      /                              \
00023 //     b300 ---- b210 ---- b120 ---- b030         0   1   2   3
00024 //
00025 // Normals
00026 // -------
00027 //              n002                       5
00028 //              /  \
00029 //            /      \
00030 //         n101      n011        <===>   3   4
00031 //        /              \
00032 //      /                  \
00033 //    n200 ---- n110 ---- n020         0   1   2
00034 ******************************************************************************/
00035 #ifndef TAPs_PNTRIANGLE_HPP
00036 #define TAPs_PNTRIANGLE_HPP
00037 
00038 #include "../Core/TAPsCGMath.hpp"
00039 
00040 BEGIN_NAMESPACE_TAPs
00041 //=============================================================================
00042 template <typename T>
00043 class PNTriangle {
00044     //-------------------------------------------------------------------------
00045     // (Friend Fn) put it through ostream
00046     friend std::ostream & operator<< ( std::ostream &output, PNTriangle<T> const &o )
00047     {
00048         output  << "\n======================\n"
00049                 <<   "TAPs::PNTriangle<"
00050                 << typeid(T).name() << "> Class:\n"
00051                 <<   "======================\n";
00052         return output;
00053     }
00054 //-----------------------------------------------------------------------------
00055 // Member Functions -----------------------------------------------------------
00056 public:
00057     //-------------------------------------------------------------------------
00058     // Fn(s)
00059     /*
00060     static void CalculatePNTriangle ( 
00061         Vector3<T> const & P1, 
00062         Vector3<T> const & P2, 
00063         Vector3<T> const & P3, 
00064         Vector3<T> const & N1, 
00065         Vector3<T> const & N2, 
00066         Vector3<T> const & N3, 
00067         Vector3<T> & outCoeffs[10], 
00068         Vector3<T> & outNormals[6] 
00069     )
00070     {
00071         CalculatePNTriangleCoefficients( 
00072             P1, P2, P3, N1, N2, N3, outCoeffs, outNormals );
00073         CalculatePNTriangleNormals( 
00074             P1, P2, P3, N1, N2, N3, outCoeffs, outNormals );
00075     }
00076 protected:
00077     static void CalculatePNTriangleCoefficients ( 
00078         Vector3<T> const & P1, 
00079         Vector3<T> const & P2, 
00080         Vector3<T> const & P3, 
00081         Vector3<T> const & N1, 
00082         Vector3<T> const & N2, 
00083         Vector3<T> const & N3, 
00084         Vector3<T> & outCoeffs[10], 
00085         Vector3<T> & outNormals[6] 
00086     );
00087     static void CalculatePNTriangleNormals ( 
00088         Vector3<T> const & P1, 
00089         Vector3<T> const & P2, 
00090         Vector3<T> const & P3, 
00091         Vector3<T> const & N1, 
00092         Vector3<T> const & N2, 
00093         Vector3<T> const & N3, 
00094         Vector3<T> & outCoeffs[10], 
00095         Vector3<T> & outNormals[6] 
00096     );
00097     //*/
00098     //===========================================
00099     // PN-Triangle without Texture Coordinates
00100     //-------------------------------------------
00101 public:
00102     static void CalculatePNTriangle ( 
00103         Vector3<T> const & P1, 
00104         Vector3<T> const & P2, 
00105         Vector3<T> const & P3, 
00106         Vector3<T> const & N1, 
00107         Vector3<T> const & N2, 
00108         Vector3<T> const & N3 
00109     )
00110     {
00111         CalculatePNTriangleCoefficients( 
00112             P1, P2, P3, N1, N2, N3 );
00113         CalculatePNTriangleNormals( 
00114             P1, P2, P3, N1, N2, N3 );
00115     }
00116 protected:
00117     static void CalculatePNTriangleCoefficients ( 
00118         Vector3<T> const & P1, 
00119         Vector3<T> const & P2, 
00120         Vector3<T> const & P3, 
00121         Vector3<T> const & N1, 
00122         Vector3<T> const & N2, 
00123         Vector3<T> const & N3 
00124     );
00125     static void CalculatePNTriangleNormals ( 
00126         Vector3<T> const & P1, 
00127         Vector3<T> const & P2, 
00128         Vector3<T> const & P3, 
00129         Vector3<T> const & N1, 
00130         Vector3<T> const & N2, 
00131         Vector3<T> const & N3 
00132     );
00133     //-------------------------------------------
00134     //===========================================
00135     // PN-Triangle with Texture Coordinates
00136     //-------------------------------------------
00137 public:
00138     static void CalculatePNTriangle ( 
00139         Vector3<T> const & P1, 
00140         Vector3<T> const & P2, 
00141         Vector3<T> const & P3, 
00142         Vector3<T> const & N1, 
00143         Vector3<T> const & N2, 
00144         Vector3<T> const & N3, 
00145         Vector3<T> const & TC1, 
00146         Vector3<T> const & TC2, 
00147         Vector3<T> const & TC3 
00148     )
00149     {
00150         CalculatePNTriangleCoefficients( 
00151             P1, P2, P3, N1, N2, N3, TC1, TC2, TC3 );
00152         CalculatePNTriangleNormals( 
00153             P1, P2, P3, N1, N2, N3 );
00154     }
00155 protected:
00156     static void CalculatePNTriangleCoefficients ( 
00157         Vector3<T> const & P1, 
00158         Vector3<T> const & P2, 
00159         Vector3<T> const & P3, 
00160         Vector3<T> const & N1, 
00161         Vector3<T> const & N2, 
00162         Vector3<T> const & N3, 
00163         Vector3<T> const & TC1, 
00164         Vector3<T> const & TC2, 
00165         Vector3<T> const & TC3 
00166     );
00167     //-------------------------------------------
00168     //===========================================
00169     //-------------------------------------------------------------------------
00170 #if defined(__gl_h_) || defined(__GL_H__)
00171     //-------------------------------------------------------------------------
00172     // OpenGL Fn(s)
00173 public:
00174     // DrawByOpenGL without Texture Coordinates
00175     static void DrawByOpenGL ( 
00176         Vector3<T> const & P1, 
00177         Vector3<T> const & P2, 
00178         Vector3<T> const & P3, 
00179         Vector3<T> const & N1, 
00180         Vector3<T> const & N2, 
00181         Vector3<T> const & N3, 
00182         int smoothness = 4 
00183     );
00184     // DrawByOpenGL with Texture Coordinates
00185     static void DrawByOpenGL ( 
00186         Vector3<T> const & P1, 
00187         Vector3<T> const & P2, 
00188         Vector3<T> const & P3, 
00189         Vector3<T> const & N1, 
00190         Vector3<T> const & N2, 
00191         Vector3<T> const & N3, 
00192         Vector3<T> const & TC1, 
00193         Vector3<T> const & TC2, 
00194         Vector3<T> const & TC3, 
00195         int smoothness = 4 
00196     );
00197 #endif
00198     //-------------------------------------------------------------------------
00199 //-----------------------------------------------------------------------------
00200 // Data Members  --------------------------------------------------------------
00201 protected:
00202     static Vector3<T>   m_coeffs[10];
00203     static Vector3<T>   m_normals[6];
00204     static Vector3<T>   m_texcoords[10];
00205 };
00206 //=============================================================================
00207 END_NAMESPACE_TAPs
00208 //-----------------------------------------------------------------------------
00209 // Include definition if TAPs_USE_EXPORT is not defined
00210 //#if !defined( TAPs_USE_EXPORT )
00211     #include "TAPsPNTriangle.cpp"
00212 //#endif
00213 //-----------------------------------------------------------------------------
00214 #endif
00215 //34567890123456789012345678901234567890123456789012345678901234567890123456789
00216 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines