Changeset 20227

Show
Ignore:
Timestamp:
05/15/07 16:14:57 (2 years ago)
Author:
patrick
Message:

Cleaned up code formatting, fixed coding standard violations, and improved
const usage/correctness.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • juggler/trunk/modules/vrjuggler/vrj/Draw/OGL/GlBasicSimulator.cpp

    r20137 r20227  
    173173 
    174174/**  Update internal simulator data */ 
    175 void GlBasicSimulator::updateInternalData(float positionScale) 
     175void GlBasicSimulator::updateInternalData(const float positionScale) 
    176176{ 
    177177   mHeadPos = mSimViewport->getUser()->getHeadPosProxy()->getData(positionScale); 
     
    209209} 
    210210 
    211  
    212211/** 
    213212 * Draw the projections. 
     
    217216 *       If !withApex, then just draws the surfaces in all white. 
    218217 */ 
    219 void GlBasicSimulator::drawProjections(bool drawFrustum, gmtl::Vec3f surfColor, const float scaleFactor) 
     218void GlBasicSimulator::drawProjections(const bool drawFrustum, 
     219                                       const gmtl::Vec3f& surfColor, 
     220                                       const float scaleFactor) 
    220221{ 
    221222   const float ALPHA_VALUE(0.25f); 
    222223 
    223    DisplayManager* display_man = vrj::GlDrawManager::instance()->getDisplayManager(); 
     224   DisplayManager* display_man =  
     225      vrj::GlDrawManager::instance()->getDisplayManager(); 
    224226   display_man->updateProjections(scaleFactor);                     // Update all projections for drawing 
    225227 
     
    229231   ProjectionPtr proj; 
    230232 
    231    for (unsigned int i=0;i<disps.size();i++
     233   for ( unsigned int i = 0; i < disps.size(); ++i
    232234   { 
    233       for (unsigned int v=0;v<disps[i]->getNumViewports();v++
     235      for ( unsigned int v = 0; v < disps[i]->getNumViewports(); ++v
    234236      { 
    235237         ViewportPtr view_port = disps[i]->getViewport(v); 
    236238 
    237          if (view_port->isSurface()
     239         if ( view_port->isSurface()
    238240         { 
    239             for(unsigned proj_num=0;proj_num<2;++proj_num) 
     241            // Get a pointer to the surface viewport. 
     242            SurfaceViewportPtr surf_vp = 
     243               boost::dynamic_pointer_cast<SurfaceViewport>(view_port); 
     244            vprASSERT(surf_vp.get() != NULL); 
     245 
     246            for ( unsigned int proj_num = 0; proj_num < 2; ++proj_num ) 
    240247            { 
    241                // Get a pointer to the surface 
    242                SurfaceViewportPtr surf_vp = 
    243                   boost::dynamic_pointer_cast<SurfaceViewport>(view_port); 
    244                vprASSERT(surf_vp.get() != NULL); 
    245  
    246                if(0 == proj_num) 
     248               if ( 0 == proj_num ) 
    247249               { 
    248250                  proj = surf_vp->getLeftProj(); 
     
    254256 
    255257               // Create color values that are unique 
    256                // Basically count in binary (skipping 0), and use the first 3 digits.  That will give six colors 
    257                int red_on = (i & 0x1); int green_on = ((i >> 1) & 0x1); int blue_on = ((i >> 2) & 0x1); 
     258               // Basically count in binary (skipping 0), and use the first 3 
     259               // digits.  That will give six colors 
     260               const int red_on = i & 0x1; 
     261               const int green_on = (i >> 1) & 0x1; 
     262               const int blue_on = (i >> 2) & 0x1; 
    258263 
    259264               float red(0.0f), green(0.0f), blue(0.0f); 
    260                if (red_on > 0) red = 1.0f; 
    261                if (green_on > 0) green = 1.0f; 
    262                if (blue_on > 0) blue = 1.0f; 
    263  
    264                if ((!red_on) && (!blue_on) && (!green_on))      // Case of 0's (black is bad) 
     265               if ( red_on > 0 ) 
     266               { 
     267                  red = 1.0f; 
     268               } 
     269               if ( green_on > 0 ) 
     270               { 
     271                  green = 1.0f; 
     272               } 
     273               if ( blue_on > 0 ) 
     274               { 
     275                  blue = 1.0f; 
     276               } 
     277 
     278               if ( ! red_on && ! blue_on && ! green_on )      // Case of 0's (black is bad) 
     279               { 
    265280                  red = blue = green = 0.75f; 
     281               } 
    266282 
    267283               gmtl::Vec3f surf_color; 
    268                gmtl::Vec3f apex_color; 
    269                if (drawFrustum) 
    270                { 
    271                   surf_color = gmtl::Vec3f(red,blue,green); 
     284               if ( drawFrustum ) 
     285               { 
     286                  surf_color = gmtl::Vec3f(red, blue, green); 
    272287               } 
    273288               else 
     
    275290                  surf_color = surfColor; 
    276291               } 
    277                apex_color = surf_color; 
    278                if(1 == proj_num)  // Right eye 
     292 
     293               gmtl::Vec3f apex_color(surf_color); 
     294 
     295               if ( 1 == proj_num )  // Right eye 
    279296               { 
    280297                  apex_color = gmtl::Vec3f(1.0f, 1.0f, 1.0f) - apex_color;    // Invert it 
    281298               } 
    282299 
    283                // Compute scaled colors for the corners 
    284                // ll is going to be lighter and upper right is going to be darker 
     300               // Compute scaled colors for the corners. 
     301               // The lower left is going to be lighter, and the upper right 
     302               // is going to be darker. 
    285303               const float ll_scale(0.10f); 
    286304               const float ul_scale(0.55f); 
    287305               const float ur_scale(1.0f); 
    288                gmtl::Vec4f ll_clr(ll_scale*surf_color[0],ll_scale*surf_color[1],ll_scale*surf_color[2],ALPHA_VALUE); 
    289                gmtl::Vec4f ul_clr(ul_scale*surf_color[0],ul_scale*surf_color[1],ul_scale*surf_color[2],ALPHA_VALUE); 
    290                gmtl::Vec4f lr_clr(ul_scale*surf_color[0],ul_scale*surf_color[1],ul_scale*surf_color[2],ALPHA_VALUE); 
    291                gmtl::Vec4f ur_clr(ur_scale*surf_color[0],ur_scale*surf_color[1],ur_scale*surf_color[2],ALPHA_VALUE); 
     306               const gmtl::Vec4f ll_clr(ll_scale * surf_color[0], 
     307                                        ll_scale * surf_color[1], 
     308                                        ll_scale * surf_color[2], 
     309                                        ALPHA_VALUE); 
     310               const gmtl::Vec4f ul_clr(ul_scale * surf_color[0], 
     311                                        ul_scale * surf_color[1], 
     312                                        ul_scale * surf_color[2], 
     313                                        ALPHA_VALUE); 
     314               const gmtl::Vec4f lr_clr(ul_scale * surf_color[0], 
     315                                        ul_scale * surf_color[1], 
     316                                        ul_scale * surf_color[2], 
     317                                        ALPHA_VALUE); 
     318               const gmtl::Vec4f ur_clr(ur_scale * surf_color[0], 
     319                                        ur_scale * surf_color[1], 
     320                                        ur_scale * surf_color[2], 
     321                                        ALPHA_VALUE); 
    292322 
    293323               // Draw the thingy 
    294324               proj->getFrustumApexAndCorners(apex, ur, lr, ul, ll); 
    295                vprDEBUG(vrjDBG_DRAW_MGR, vprDBG_STATE_LVL) << "apex: " << apex 
    296                                                           << std::endl << vprDEBUG_FLUSH; 
    297  
    298                glColor4fv(&(apex_color[0])); 
     325               vprDEBUG(vrjDBG_DRAW_MGR, vprDBG_STATE_LVL) 
     326                  << "apex: " << apex << std::endl << vprDEBUG_FLUSH; 
     327 
     328               glColor4fv(&apex_color[0]); 
    299329               glPushMatrix(); 
    300                   if (drawFrustum
     330                  if ( drawFrustum
    301331                  { 
    302                      drawLine(apex, ur); drawLine(apex, lr); drawLine(apex, ul); drawLine(apex, ll); 
     332                     drawLine(apex, ur); 
     333                     drawLine(apex, lr); 
     334                     drawLine(apex, ul); 
     335                     drawLine(apex, ll); 
    303336                  } 
    304337 
    305                   glColor4fv(&(ur_clr[0])); 
     338                  glColor4fv(&ur_clr[0]); 
    306339                  // Draw the outline 
    307                   drawLine(ur, lr); drawLine(lr, ll); drawLine(ll, ul); drawLine(ul, ur); 
     340                  drawLine(ur, lr); 
     341                  drawLine(lr, ll); 
     342                  drawLine(ll, ul); 
     343                  drawLine(ul, ur); 
    308344 
    309345                  // Draw the surface 
     
    435471} 
    436472 
    437 void GlBasicSimulator::drawLine(gmtl::Vec3f& start, gmtl::Vec3f& end) 
     473void GlBasicSimulator::drawLine(const gmtl::Vec3f& start, 
     474                                const gmtl::Vec3f& end) 
    438475{ 
    439476   glBegin(GL_LINES); 
     
    443480} 
    444481 
    445 void GlBasicSimulator::drawBox(float size, GLenum type) 
     482void GlBasicSimulator::drawBox(const float size, const GLenum type) 
    446483{ 
    447484  static GLfloat n[6][3] = 
     
    486523 
    487524 
    488 void GlBasicSimulator::drawWireCube(float size) 
     525void GlBasicSimulator::drawWireCube(const float size) 
    489526{ 
    490527  drawBox(size, GL_LINE_LOOP); 
    491528} 
    492529 
    493 void GlBasicSimulator::drawSolidCube(float size) 
     530void GlBasicSimulator::drawSolidCube(const float size) 
    494531{ 
    495532  drawBox(size, GL_QUADS); 
  • juggler/trunk/modules/vrjuggler/vrj/Draw/OGL/GlBasicSimulator.h

    r20080 r20227  
    9999 
    100100public: 
    101    const gmtl::Matrix44f& getCameraPos() 
     101   const gmtl::Matrix44f& getCameraPos() const 
    102102   { 
    103103      return mCameraPos; 
    104104   } 
    105105 
    106    const gmtl::Matrix44f& getHeadPos() 
     106   const gmtl::Matrix44f& getHeadPos() const 
    107107   { 
    108108      return mHeadPos; 
    109109   } 
    110110 
    111    const gmtl::Matrix44f& getWandPos() 
     111   const gmtl::Matrix44f& getWandPos() const 
    112112   { 
    113113      return mWandPos; 
     
    119119 
    120120   /**  Update internal simulator data */ 
    121    void updateInternalData(float positionScale); 
     121   void updateInternalData(const float positionScale); 
    122122 
    123123public:  // Sim Drawing parameters 
    124    bool shouldDrawProjections() 
     124   bool shouldDrawProjections() const 
    125125   { 
    126126      return mDrawProjections; 
    127127   } 
    128128 
    129    gmtl::Vec3f getSurfaceColor() 
     129   const gmtl::Vec3f& getSurfaceColor() const 
    130130   { 
    131131      return mSurfaceColor; 
     
    140140 
    141141   /** Draws projections in OpenGL. */ 
    142    void drawProjections(bool drawFrustum, gmtl::Vec3f surfColor, 
     142   void drawProjections(const bool drawFrustum, const gmtl::Vec3f& surfColor, 
    143143                        const float scaleFactor); 
    144144 
     
    170170protected:     // --- Geom helpers --- // 
    171171   void initQuadObj(); 
    172    void drawLine(gmtl::Vec3f& start, gmtl::Vec3f& end); 
    173    void drawBox(float size, GLenum type); 
    174    void drawWireCube(float size); 
    175    void drawSolidCube(float size); 
     172   void drawLine(const gmtl::Vec3f& start, const gmtl::Vec3f& end); 
     173   void drawBox(const float size, const GLenum type); 
     174   void drawWireCube(const float size); 
     175   void drawSolidCube(const float size); 
    176176   //void drawGlove(gadget::GloveProxy* gloveProxy); 
    177177