basic/opengl/GL_Universe.cpp

Go to the documentation of this file.
00001 //## begin module%372F643901B8.cm preserve=no
00002 //        %X% %Q% %Z% %W%
00003 //## end module%372F643901B8.cm
00004 
00005 //## begin module%372F643901B8.cp preserve=no
00006 //## end module%372F643901B8.cp
00007 
00008 //## Module: GL_Universe%372F643901B8; Pseudo Package body
00009 //## Source file: C:\project\mpk\code\OpenGL\GL_Universe.cpp
00010 
00011 //## begin module%372F643901B8.additionalIncludes preserve=no
00012 //## end module%372F643901B8.additionalIncludes
00013 
00014 //## begin module%372F643901B8.includes preserve=yes
00015 //#include "glos.h"
00016 //#include "stdafx.h"           //IAN IMPROVE: this is platform dependant
00017 #include <windows.h>
00018 #include <gl\gl.h>
00019 #include <assert.h>
00020 //## end module%372F643901B8.includes
00021 
00022 // Entity
00023 #include "Universe\Entity.h"
00024 // GL_Frame
00025 #include "OpenGL\GL_Frame.h"
00026 #include "OpenGL\GL_Material.h"
00027 // GL_Universe
00028 #include "OpenGL\GL_Universe.h"
00029 //## begin module%372F643901B8.additionalDeclarations preserve=yes
00030 //## end module%372F643901B8.additionalDeclarations
00031 
00032 
00033 // Class GL_Universe 
00034 
00035 GL_Universe::GL_Universe()
00036 :Universe(), OpenGLInterface()
00037 {
00038         showFrame = false;
00039 }
00040 
00041 GL_Universe::~GL_Universe()
00042 {
00043   //## begin GL_Universe::~GL_Universe%.body preserve=yes
00044   //## end GL_Universe::~GL_Universe%.body
00045 }
00046 
00047 //==============================================================================
00048 // GlDraw
00049 //
00050 // Description: Draws the universe using OpenGL
00051 //==============================================================================
00052 void GL_Universe::GLDraw () const
00053 {
00054         SetupState();
00055 
00056         GL_Material::matGrayPlastic.GLDraw() ;
00057         DrawFrame0();
00058 
00059         GL_Material::matRedPlastic.GLDraw() ;
00060         DrawNotFrame0();
00061 }
00062 
00063 void GL_Universe::DrawFrame0 () const
00064 {
00065   //## begin GL_Universe::DrawFrame0%940546748.body preserve=yes
00066         //draw all the entities in the universe
00067         for( int i = 0; i < entities.size(); i++ )
00068         {
00069                 Entity* entity = entities[ i ] ;
00070                 OpenGLInterface* drawMe = dynamic_cast< OpenGLInterface* >( entity ) ;
00071                 if( drawMe != NULL )
00072                 {
00073                         if( entity->BaseFrame() == 0 )
00074                         {
00075                                 Matrix4x4 matrix = entity->GetTransform() ;
00076                                 GL_Frame theFrame ( matrix, showFrame );
00077                                 glPushMatrix() ;
00078                                 theFrame.GLDraw() ;     //IMPROVE: this is a big deal just to get the transform right
00079                                 drawMe->GLDraw() ;
00080                                 glPopMatrix() ;
00081                         }
00082                 }
00083         }
00084 
00085   //## end GL_Universe::DrawFrame0%940546748.body
00086 }
00087 
00088 void GL_Universe::DrawNotFrame0 () const
00089 {
00090         //draw all the entities in the universe
00091         for( int i = 0; i < entities.size(); i++ )
00092         {
00093                 Entity* entity = entities[ i ] ;
00094                 if( entity->BaseFrame() != 0 )
00095                 {
00096                         OpenGLInterface* drawMe = dynamic_cast< OpenGLInterface* >( entity ) ;
00097                         if( drawMe != NULL )
00098                         {
00099                                 Matrix4x4 matrix = entity->GetTransform() ;
00100                                 GL_Frame theFrame ( matrix, showFrame );
00101                                 glPushMatrix() ;
00102                                 theFrame.GLDraw() ;     //IMPROVE: this is a big deal just to get the transform right
00103                                 drawMe->GLDraw() ;
00104                                 glPopMatrix() ;
00105                         }
00106                         else
00107                         {
00108                         }
00109                 }
00110         }
00111 }
00112 
00113 bool GL_Universe::DrawExplicit () const
00114 {
00115         assert( false ) ;
00116         return false ;
00117 }
00118 
00119 void GL_Universe::SetDrawFrame(bool bShow) 
00120 {
00121         showFrame = bShow;
00122 }
00123 
00124 //==============================================================================
00125 // SetupState
00126 //
00127 // Description: Sets the lighting, depth buffer, etc state before drawing
00128 //==============================================================================
00129 void GL_Universe::SetupState() const
00130 {
00131         //
00132         // Set the color to white
00133         //
00134         ::glColor3d( 1.0, 1.0, 1.0 );
00135 
00136         //
00137         // Enable lighting and depth test
00138         //
00139         glEnable( GL_LIGHTING );
00140         glEnable( GL_DEPTH_TEST );
00141 
00142 }

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