basic/opengl/GL_Box.cpp

Go to the documentation of this file.
00001 //## begin module%3872901502F0.cm preserve=no
00002 //        %X% %Q% %Z% %W%
00003 //## end module%3872901502F0.cm
00004 
00005 //## begin module%3872901502F0.cp preserve=no
00006 //## end module%3872901502F0.cp
00007 
00008 //## Module: GL_Box%3872901502F0; Pseudo Package body
00009 //## Source file: C:\project\mpk\code\OpenGL\GL_Box.cpp
00010 
00011 //## begin module%3872901502F0.additionalIncludes preserve=no
00012 //## end module%3872901502F0.additionalIncludes
00013 
00014 //## begin module%3872901502F0.includes preserve=yes
00015 #include <assert.h>
00016 #include "glos.h"
00017 #include <gl/gl.h>
00018 //## end module%3872901502F0.includes
00019 
00020 // GL_Box
00021 #include "OpenGL\GL_Box.h"
00022 //## begin module%3872901502F0.additionalDeclarations preserve=yes
00023 //## end module%3872901502F0.additionalDeclarations
00024 
00025 
00026 // Class GL_Box 
00027 
00028 GL_Box::GL_Box (FrameManager* frameManager)
00029   //## begin GL_Box::GL_Box%947024876.hasinit preserve=no
00030   //## end GL_Box::GL_Box%947024876.hasinit
00031   //## begin GL_Box::GL_Box%947024876.initialization preserve=yes
00032   :
00033         MPK_Box( frameManager ) 
00034   //## end GL_Box::GL_Box%947024876.initialization
00035 {
00036   //## begin GL_Box::GL_Box%947024876.body preserve=yes
00037   //## end GL_Box::GL_Box%947024876.body
00038 }
00039 
00040 GL_Box::GL_Box (const GL_Box& right)
00041   //## begin GL_Box::GL_Box%947024877.hasinit preserve=no
00042   //## end GL_Box::GL_Box%947024877.hasinit
00043   //## begin GL_Box::GL_Box%947024877.initialization preserve=yes
00044   :
00045         MPK_Box( right )
00046   //## end GL_Box::GL_Box%947024877.initialization
00047 {
00048   //## begin GL_Box::GL_Box%947024877.body preserve=yes
00049   //## end GL_Box::GL_Box%947024877.body
00050 }
00051 
00052 
00053 GL_Box::~GL_Box()
00054 {
00055   //## begin GL_Box::~GL_Box%.body preserve=yes
00056   //## end GL_Box::~GL_Box%.body
00057 }
00058 
00059 
00060 
00061 //## Other Operations (implementation)
00062 Entity* GL_Box::Clone () const
00063 {
00064   //## begin GL_Box::Clone%947024879.body preserve=yes
00065         return new GL_Box( *this ) ;
00066   //## end GL_Box::Clone%947024879.body
00067 }
00068 
00069 bool GL_Box::DrawExplicit () const
00070 {
00071   //## begin GL_Box::DrawExplicit%950474932.body preserve=yes
00072         GLdouble x = length / 2.0 ;
00073         GLdouble y = width      / 2.0 ;
00074         GLdouble z = height     / 2.0 ;
00075         GLdouble a[ 3 ] =       {       -x,     y, -z   } ;
00076         GLdouble b[ 3 ] =       {       -x, y, z        } ;
00077         GLdouble c[ 3 ] =       {       x,      y, z    } ;
00078         GLdouble d[ 3 ] =       {       x, y, -z        } ;
00079         GLdouble e[ 3 ] =       {       -x,     -y, -z  } ;
00080         GLdouble f[ 3 ] =       {       -x, -y, z       } ;
00081         GLdouble g[ 3 ] =       {       x,      -y, z   } ;
00082         GLdouble h[ 3 ] =       {       x, -y, -z       } ;
00083 
00084         static GLfloat up[ 3 ] =        {       0,      1,      0       } ;
00085         static GLfloat dn[ 3 ] =        {       0,      -1,     0       } ;
00086         static GLfloat fr[ 3 ] =        {       0,      0,      -1      } ;
00087         static GLfloat ba[ 3 ] =        {       0,      0,      1       } ;
00088         static GLfloat le[ 3 ] =        {       -1,     0,      0       } ;
00089         static GLfloat ri[ 3 ] =        {       1,      0,      0       } ;
00090 
00091 
00092         glPushMatrix() ;
00093                 //improve this is the wrong matrix style
00094                 Matrix4x4 intermediate = theFrame ;
00095 //              double oneOverRoot3 = 1.0 / sqrt( 3 ) ;
00096 //              intermediate.Rotate( Vector4( oneOverRoot3, -oneOverRoot3, oneOverRoot3 ), -360.0 / 3.0 ) ;     //need to compensate for the axis disparity
00097 
00098                 Matrix4x4 transpose = intermediate.Transpose() ;
00099                 ::glMultMatrixd( ( const double* )( transpose.values ) ) ;
00100         
00101                 glBegin( GL_QUADS ) ;
00102                         //top
00103                         glNormal3fv( up ) ;
00104                         glVertex3dv( a ) ;
00105                         glVertex3dv( b ) ;
00106                         glVertex3dv( c ) ;
00107                         glVertex3dv( d ) ;
00108 
00109                         //bottom
00110                         glNormal3fv( dn ) ;
00111                         glVertex3dv( e ) ;
00112                         glVertex3dv( h ) ;
00113                         glVertex3dv( g ) ;
00114                         glVertex3dv( f ) ;
00115 
00116                         //front
00117                         glNormal3fv( fr ) ;
00118                         glVertex3dv( a ) ;
00119                         glVertex3dv( d ) ;
00120                         glVertex3dv( h ) ;
00121                         glVertex3dv( e ) ;
00122 
00123                         //back
00124                         glNormal3fv( ba ) ;
00125                         glVertex3dv( b ) ;
00126                         glVertex3dv( f ) ;
00127                         glVertex3dv( g ) ;
00128                         glVertex3dv( c ) ;
00129 
00130                         //left
00131                         glNormal3fv( le ) ;
00132                         glVertex3dv( b ) ;
00133                         glVertex3dv( a ) ;
00134                         glVertex3dv( e ) ;
00135                         glVertex3dv( f ) ;
00136 
00137                         //right
00138                         glNormal3fv( ri ) ;
00139                         glVertex3dv( d ) ;
00140                         glVertex3dv( c ) ;
00141                         glVertex3dv( g ) ;
00142                         glVertex3dv( h ) ;
00143                 glEnd() ;
00144         glPopMatrix() ;
00145         return true ;
00146   //## end GL_Box::DrawExplicit%950474932.body
00147 }
00148 
00149 bool GL_Box::Verify() const
00150 {
00151         return true;
00152 }

Generated on Sat Apr 1 21:30:35 2006 for Motion Planning Kernel by  doxygen 1.4.6-NO