![]() |
TAPs 0.7.7.3
|
00001 /****************************************************************************** 00002 STAPsRegularPolyhedra.hpp 00003 ******************************************************************************/ 00013 /****************************************************************************** 00014 SUKITTI PUNAK (09/09/2010) 00015 UPDATE (03/28/2011) 00016 ******************************************************************************/ 00017 #ifndef STAPs_REGULAR_POLYTOPES_HPP 00018 #define STAPs_REGULAR_POLYTOPES_HPP 00019 00020 //#include "../OpenGL/STAPsGLSupport.hpp" 00021 #include "../OpenGL/STAPsGLObj.hpp" 00022 #include "../Support/TAPsTransformationSupport.hpp" 00023 00024 BEGIN_NAMESPACE_TAPs 00025 //============================================================================= 00026 template <typename T> 00027 class RegularPolyhedra { //: public /*virtual*/ OpenGLModel { 00028 //============================================================================= 00029 public: 00030 // Member Functions ------------------------------------------------------- 00032 friend std::ostream & operator<< ( std::ostream &output, RegularPolyhedra const &obj ) 00033 { 00034 output << obj.StrInfo(); 00035 return output; 00036 } 00037 //------------------------------------------------------------------------- 00039 RegularPolyhedra (); 00041 virtual ~RegularPolyhedra (); 00042 //------------------------------------------------------------------------- 00044 virtual std::string StrInfo () const; 00045 //------------------------------------------------------------------------- 00046 // Data Members ----------------------------------------------------------- 00047 //============================================================================= 00048 protected: 00049 // Member Functions ------------------------------------------------------- 00050 // Data Members ----------------------------------------------------------- 00051 TransformationSupport<T> m_Trx; 00052 //============================================================================= 00053 private: 00054 // Member Functions ------------------------------------------------------- 00055 bool Init (); 00056 void Clear (); 00057 // Data Members ----------------------------------------------------------- 00058 //============================================================================= 00059 00060 00061 //============================================================================= 00062 // OpenGL 00063 #if defined(__gl_h_) || defined(__GL_H__) 00064 //----------------------------------------------------------------------------- 00065 public: 00066 00067 // Member Functions ------------------------------------------------------- 00068 00070 virtual void Draw (); 00071 00073 virtual void DrawTetrahedron ( Matrix4x4<T> MVP = Matrix4x4<T>(), Vector3<T> LightDirection = Vector3<T>(0,0,-1) ); 00075 virtual void DrawHexahedron ( Matrix4x4<T> MVP = Matrix4x4<T>(), Vector3<T> LightDirection = Vector3<T>(0,0,-1) ); 00077 virtual void DrawOctahedron ( Matrix4x4<T> MVP = Matrix4x4<T>(), Vector3<T> LightDirection = Vector3<T>(0,0,-1) ); 00078 00079 00081 OpenGL::GLObj & GL () { return mGL_Obj; } 00082 00083 // Data Members ----------------------------------------------------------- 00084 00085 protected: 00086 00087 // Member Functions ------------------------------------------------------- 00088 00089 // Data Members ----------------------------------------------------------- 00090 GLuint mGL_VAO; 00091 GLuint mGL_VBO_Positions; 00092 GLuint mGL_VBO_Colors; 00093 GLuint mGL_VBO_Normals; 00094 GLuint mGL_VBO_Indices; 00095 GLuint mGL_VertexAttribIdx_Positions; 00096 GLuint mGL_VertexAttribIdx_Colors; 00097 GLuint mGL_VertexAttribIdx_Normals; 00098 00099 //GLint m_Uniform_MVP; //!< uniform for MVP 00100 GLint m_Uniform_LightDir; 00101 00102 GLuint m_Uniform_Block_BO; 00103 00104 struct GLSL_S_Transform { 00105 GLfloat ModelViewMatrix[16]; 00106 GLfloat NormalMatrix[9]; 00107 }; 00108 00109 GLuint m_ModelViewMatrix_Uniform; 00110 GLuint g_BindingIndex; 00111 00112 00113 OpenGL::GLObj mGL_Obj; 00114 00115 private: 00116 00117 // Member Functions ------------------------------------------------------- 00118 00120 bool InitGL ( 00121 const int faces[], int sizeOfFaces, 00122 const float vertices[], int sizeOfVertices 00123 ); 00124 00126 bool InitGLSL (); 00127 00129 void ClearGL (); 00130 00131 // Data Members ----------------------------------------------------------- 00132 int * m__pFaces; 00133 int m__pFacesSize; 00134 float * m__pVertices; 00135 int m__pVerticesSize; 00136 00137 //----------------------------------------------------------------------------- 00138 #endif // OpenGL 00139 //============================================================================= 00140 00141 00142 //============================================================================= 00143 }; // END CLASS RegularPolyhedra 00144 //============================================================================= 00145 END_NAMESPACE_TAPs 00146 //----------------------------------------------------------------------------- 00148 #include "STAPsRegularPolyhedra.cpp" 00149 00151 // Include definition if TAPs_USE_EXPORT is not defined 00152 //#if !defined( TAPs_USE_EXPORT ) 00153 // #include "STAPsRegularPolyhedra.cpp" 00154 //#endif 00155 //----------------------------------------------------------------------------- 00156 #endif 00157 //34567890123456789012345678901234567890123456789012345678901234567890123456789 00158 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----