TAPs 0.7.7.3
TAPsWallBasic.cpp
Go to the documentation of this file.
00001 /******************************************************************************
00002 TAPsWallBasic.cpp
00003 ******************************************************************************/
00007 /******************************************************************************
00008 SUKITTI PUNAK   (08/30/2010)
00009 UPDATE          (09/03/2010)
00010 ******************************************************************************/
00011 #include "TAPsWallBasic.hpp"
00012 // Using Inclusion Model (i.e. definitions are included in declarations)
00013 //                       (this name.cpp is included in name.hpp)
00014 // Each friend is defined directly inside its declaration.
00015 
00016 BEGIN_NAMESPACE_TAPs
00017 //=============================================================================
00018 // Constructors
00019 //-----------------------------------------------------------------------------
00020 template <typename T>
00021 WallBasic<T>::WallBasic ()
00022     : HalfWidth( T(0.5) )
00023     , HalfHeight( T(0.5) )
00024     , Color( 0.55f, 0.55, 0.55f )
00025 {}
00026 //-----------------------------------------------------------------------------
00027 template <typename T>
00028 WallBasic<T>::WallBasic ( WallBasic<T> const &orig )
00029     : Center( orig.Center )
00030     , HalfWidth( orig.HalfWidth )
00031     , HalfHeight( orig.HalfHeight )
00032     , Transform( orig.Transform )
00033     , Color( orig.Color )
00034 {}
00035 //-----------------------------------------------------------------------------
00036 template <typename T>
00037 WallBasic<T>::~WallBasic ()
00038 {}
00039 //-----------------------------------------------------------------------------
00040 template <typename T>
00041 std::string WallBasic<T>::StrInfo () const
00042 {
00043     std::ostringstream ss;
00044     ss << "WallBasic<" << typeid(T).name() << ">";
00045     ss << "is centered at " << Center;
00046     ss << " with width and height of " << Width*2 << " and " << Height*2;
00047     ss << " and transformation of " << Transform;
00048     ss << "\n";
00049     return ss.str();
00050 }
00051 //-----------------------------------------------------------------------------
00052 //=============================================================================
00053 // Assignment Operator
00054 //-----------------------------------------------------------------------------
00055 template <typename T>
00056 WallBasic<T> & WallBasic<T>::operator= ( WallBasic<T> const &orig )
00057 {   
00058     Center = orig.Center;
00059     HalfWidth = orig.HalfWidth;
00060     HalfHeight = orig.HalfHeight;
00061     Transform = orig.Transform;
00062     Color = orig.Color;
00063     return *this;
00064 }
00065 //-----------------------------------------------------------------------------
00066 //=============================================================================
00067 
00068 
00069 //=============================================================================
00070 // OpenGL
00071 #if defined(__gl_h_) || defined(__GL_H__)
00072 template <typename T>
00073 void WallBasic<T>::Draw () const
00074 {
00075     Transform.TransformByOpenGLForDrawing();
00076     glPushAttrib( GL_ALL_ATTRIB_BITS );
00077     glPushMatrix();
00078     glTranslatef( Center[0], Center[1], Center[2] );
00079     glEnable( GL_COLOR_MATERIAL );
00080     glBegin( GL_QUADS );
00081         glColor4f( Color[0], Color[1], Color[2], Color[3] );
00082         glVertex3f( -HalfWidth, -HalfHeight,  0 );
00083         glVertex3f(  HalfWidth, -HalfHeight,  0 );
00084         glVertex3f(  HalfWidth,  HalfHeight,  0 );
00085         glVertex3f( -HalfWidth,  HalfHeight,  0 );
00086     glEnd();
00087     glPopMatrix();
00088     glPopAttrib();
00089 }
00090 //-----------------------------------------------------------------------------
00091 #endif  // OpenGL
00092 //=============================================================================
00093 
00094 
00095 //=============================================================================
00096 END_NAMESPACE_TAPs
00097 //34567890123456789012345678901234567890123456789012345678901234567890123456789
00098 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines