planners/PL_OpenGL.cpp

Go to the documentation of this file.
00001 #include "paths/pa_points.h"
00002 #include "Planners/PL_OpenGL.h"
00003 #include "opengl/glos.h"
00004 #include <gl/gl.h>
00005 
00006 
00007 
00008 // Class PL_OpenGL 
00009 
00010 PL_OpenGL::~PL_OpenGL()
00011 {
00012   //## begin PL_OpenGL::~PL_OpenGL%.body preserve=yes
00013   //## end PL_OpenGL::~PL_OpenGL%.body
00014 }
00015 
00016 void PL_OpenGL::Draw( const Configuration& config )
00017 {
00018     float x = 0.0f;
00019     float y = 0.0f;
00020     float z = 0.0f;
00021     const unsigned int DOF = config.DOF();
00022     if( DOF > 0 )
00023     {
00024         x = config[ 0 ];
00025     }
00026     if( DOF > 1 )
00027     {
00028         y = config[ 1 ];
00029     }
00030     if( DOF > 2 )
00031     {
00032         z = config[ 2 ];
00033     }
00034     glVertex3f( x, y, z );
00035 }
00036 
00037 //=============================================================================
00038 // PL_OpenGL::DrawArrow
00039 //
00040 // draw an arrow
00041 //=============================================================================
00042 void PL_OpenGL::DrawArrow( const VectorN& point, const VectorN& direction )
00043 {
00044     //
00045     // draw the point
00046     //
00047     glBegin( GL_POINTS );
00048         Draw( point );
00049     glEnd();
00050 
00051     //
00052     // draw the arrow portion
00053     //
00054     glBegin( GL_LINE );
00055         Draw( point );
00056         Draw( point + direction );
00057     glEnd();
00058 }
00059 
00060 //=============================================================================
00061 // PL_OpenGL::DrawArrorOverlay
00062 //
00063 // draw an arrow
00064 //=============================================================================
00065 void PL_OpenGL::DrawArrorOverlay( const VectorN& point, const VectorN& direction )
00066 {
00067     //
00068     // draw the point
00069     //
00070     glBegin( GL_POINTS );
00071         DrawOverlay( point );
00072     glEnd();
00073 
00074     //
00075     // draw the arrow portion
00076     //
00077     glBegin( GL_LINES );
00078         DrawOverlay( point );
00079         DrawOverlay( point + direction );
00080     glEnd();
00081 }
00082 
00083 
00084 void PL_OpenGL::DrawOverlay( const Configuration& config )
00085 {
00086     float x = 0.0f;
00087     float y = 0.0f;
00088     float z = 0.0f;
00089     const unsigned int DOF = config.DOF();
00090     if( DOF > 0 )
00091     {
00092         x = config[ 0 ];
00093     }
00094     if( DOF > 1 )
00095     {
00096         y = config[ 1 ];
00097     }
00098     if( DOF > 2 )
00099     {
00100         z = config[ 2 ];
00101     }
00102     glVertex3f( y, -x, z );
00103 }
00104 
00105 //=============================================================================
00106 // PL_OpenGL::Draw
00107 //
00108 // draw the path
00109 //=============================================================================
00110 void PL_OpenGL::Draw( const PA_Points& path )
00111 {
00112     unsigned int size = path.Size();
00113     int i;
00114     glBegin( GL_LINE_STRIP );
00115     for( i = 0; i < size; ++i )
00116     {
00117         const Configuration& config = path[ i ];
00118         Draw( config );
00119     }
00120     glEnd();
00121 
00122     glBegin( GL_POINTS );
00123     for( i = 0; i < size; ++i )
00124     {
00125         const Configuration& config = path[ i ];
00126         Draw( config );
00127     }
00128     glEnd();
00129 }
00130 
00131 void PL_OpenGL::DrawOverlay( const PA_Points& path )
00132 {
00133     unsigned int size = path.Size();
00134     int i;
00135     glBegin( GL_LINE_STRIP );
00136     for( i = 0; i < size; ++i )
00137     {
00138         const Configuration& config = path[ i ];
00139         DrawOverlay( config );
00140     }
00141     glEnd();
00142 
00143     glBegin( GL_POINTS );
00144     for( i = 0; i < size; ++i )
00145     {
00146         const Configuration& config = path[ i ];
00147         DrawOverlay( config );
00148     }
00149     glEnd();
00150 }
00151 
00152 
00153 //## Other Operations (implementation)
00154 bool PL_OpenGL::DrawExplicit () const
00155 {
00156   //## begin PL_OpenGL::DrawExplicit%964739311.body preserve=yes
00157 
00158         //by default this should do virtually nothing
00159         glClearColor( 0.0f, 0.0f, 0.5, 1.0 );
00160         glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
00161         return true;
00162   //## end PL_OpenGL::DrawExplicit%964739311.body
00163 }
00164 
00165 void PL_OpenGL::DrawUniversePortion() const
00166 {
00167         // nothing
00168 }
00169 
00170 void PL_OpenGL::GLDraw () const
00171 {
00172   //## begin PL_OpenGL::GLDraw%964739312.body preserve=yes
00173         this->DrawExplicit();
00174   //## end PL_OpenGL::GLDraw%964739312.body
00175 }
00176 
00177 // Additional Declarations
00178   //## begin PL_OpenGL%3980C19B0168.declarations preserve=yes
00179   //## end PL_OpenGL%3980C19B0168.declarations
00180 
00181 //## begin module%3980C19B0168.epilog preserve=yes
00182 //## end module%3980C19B0168.epilog

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