TAPs 0.7.7.3
TAPsOpenGLModelManager.cpp
Go to the documentation of this file.
00001 /******************************************************************************
00002 TAPsOpenGLModelManager.cpp
00003 
00004 Inherited from class BaseOpenGLModelManager
00005 
00006 SUKITTI PUNAK   (05/07/2006)
00007 UPDATE          (05/07/2006)
00008 ******************************************************************************/
00009 #include "TAPsOpenGLModelManager.hpp"
00010 // Using Inclusion Model (i.e. definitions are included in declarations)
00011 //                       (this name.cpp is included in name.hpp)
00012 // Each friend is defined directly inside its declaration.
00013 
00014 //-----------------------------------------------------------------------------
00015 // DEBUG ENABLE
00016 #ifdef TAPs_ENABLE_DEBUG
00017     #define DEBUG_MESSAGE_TAPs_OPENGL_MODEL_MANAGER
00018 #endif
00019 //-----------------------------------------------------------------------------
00020 BEGIN_NAMESPACE_TAPs__OpenGL
00021 //=============================================================================
00022 //-----------------------------------------------------------------------------
00023 // Default Constructor
00024 template <typename T>
00025 OpenGLModelManager<T>::OpenGLModelManager ()
00026     : BaseOpenGLModelManager<T>(), 
00027       m_uiDisplayList( 0 )
00028 {}
00029 //-----------------------------------------------------------------------------
00030 // Destructor
00031 template <typename T>
00032 OpenGLModelManager<T>::~OpenGLModelManager ()
00033 {}
00034 //-----------------------------------------------------------------------------
00035 // Setup
00036 // creates a random cloud of points with random colors within a canonical view.
00037 template <typename T>
00038 void OpenGLModelManager<T>::Setup ( BaseOpenGLViewManager<T> * pOpenGLViewManager )
00039 {
00040     m_pOpenGLViewManager = pOpenGLViewManager;
00041 }
00042 //-----------------------------------------------------------------------------
00043 // Cleanup
00044 template <typename T>
00045 void OpenGLModelManager<T>::Cleanup ()
00046 {}
00047 //-----------------------------------------------------------------------------
00048 // DrawModel
00049 // draws model
00050 template <typename T>
00051 void OpenGLModelManager<T>::DrawModel ( Enum::DrawMode DM = Enum::LINES )
00052 {
00053     static GLfloat rotX = 0, rotY = 0, rotZ = 0;
00054     //---------------------------------------------------------------
00055     glRotatef( rotX, 1, 0, 0 );
00056     glRotatef( rotY, 0, 1, 0 );
00057     glRotatef( rotZ, 0, 0, 1 );
00058     //---------------------------------------------------------------
00059     rotX += 0.3;
00060     rotY += 0.6;
00061     rotZ += 0.9;
00062     //---------------------------------------------------------------
00063     glPushAttrib( GL_LIGHTING_BIT );
00064     //---------------------------------------------------------------
00065     glEnable( GL_LIGHTING );
00066     //---------------------------------------------------------------
00067     // Draw Objects
00068     if ( m_uiDisplayList == 0 ) {
00069         m_uiDisplayList = glGenLists( 1 );
00070         glNewList( m_uiDisplayList, GL_COMPILE_AND_EXECUTE );
00071         //-------------------------------------------------
00072         // Draw six faces of a cube
00073         glEnable( GL_LIGHTING );
00074         glBegin( GL_QUADS );
00075             glColor3f( 1, 0, 0 );
00076             glNormal3f( 0.0f, 0.0f, 1.0f);
00077             glVertex3f( 0.5f, 0.5f, 0.5f); glVertex3f(-0.5f, 0.5f, 0.5f);
00078             glVertex3f(-0.5f,-0.5f, 0.5f); glVertex3f( 0.5f,-0.5f, 0.5f);
00079 
00080             glColor3f( 0, 1, 0 );
00081             glNormal3f( 0.0f, 0.0f,-1.0f);
00082             glVertex3f(-0.5f,-0.5f,-0.5f); glVertex3f(-0.5f, 0.5f,-0.5f);
00083             glVertex3f( 0.5f, 0.5f,-0.5f); glVertex3f( 0.5f,-0.5f,-0.5f);
00084 
00085             glColor3f( 0, 0, 1 );
00086             glNormal3f( 0.0f, 1.0f, 0.0f);
00087             glVertex3f( 0.5f, 0.5f, 0.5f); glVertex3f( 0.5f, 0.5f,-0.5f);
00088             glVertex3f(-0.5f, 0.5f,-0.5f); glVertex3f(-0.5f, 0.5f, 0.5f);
00089 
00090             glColor3f( 0, 1, 1 );
00091             glNormal3f( 0.0f,-1.0f, 0.0f);
00092             glVertex3f(-0.5f,-0.5f,-0.5f); glVertex3f( 0.5f,-0.5f,-0.5f);
00093             glVertex3f( 0.5f,-0.5f, 0.5f); glVertex3f(-0.5f,-0.5f, 0.5f);
00094 
00095             glColor3f( 1, 1, 1 );
00096             glNormal3f( 1.0f, 0.0f, 0.0f);
00097             glVertex3f( 0.5f, 0.5f, 0.5f); glVertex3f( 0.5f,-0.5f, 0.5f);
00098             glVertex3f( 0.5f,-0.5f,-0.5f); glVertex3f( 0.5f, 0.5f,-0.5f);
00099 
00100             glColor3f( 1, 0, 1 );
00101             glNormal3f(-1.0f, 0.0f, 0.0f);
00102             glVertex3f(-0.5f,-0.5f,-0.5f); glVertex3f(-0.5f,-0.5f, 0.5f);
00103             glVertex3f(-0.5f, 0.5f, 0.5f); glVertex3f(-0.5f, 0.5f,-0.5f);
00104         glEnd();
00105         glEndList();
00106     }
00107     else {
00108         glCallList( m_uiDisplayList );
00109     }
00110     //----------------------------------------------------------------
00111     glPopAttrib();
00112 }
00113 //-----------------------------------------------------------------------------
00114 // Initialization
00115 template <typename T>
00116 void OpenGLModelManager<T>::Init ()
00117 {}
00118 //-----------------------------------------------------------------------------
00119 //=============================================================================
00120 END_NAMESPACE_TAPs__OpenGL
00121 //-----------------------------------------------------------------------------
00122 //345678901234567890123456789012345678901234567890123456789012345678901234567890
00123 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines