Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 21, 2005, 11:09:57 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: visibility of Element2D-debug-draw through
ShellCommand:: Render2D toggleNodeVisibility

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/graphics/render2D/element_2d.cc

    r5414 r5417  
    902902  if (this->visible)
    903903    this->draw();
    904   if (this->children->getSize() >0)
     904  if (this->children->getSize() > 0)
    905905  {
    906906    tIterator<Element2D>* drawIT = children->getIterator();
     
    919919 * displays the Element2D at its position with its rotation as a Plane.
    920920 */
    921 void Element2D::debugDraw2D(unsigned int depth, float size, Vector color) const
    922 {
     921void Element2D::debugDraw2D(unsigned int depth, float size, Vector color, unsigned int level) const
     922{
     923  if (level == 0)
     924  {
     925    glPushAttrib(GL_ENABLE_BIT);
     926    glMatrixMode(GL_MODELVIEW);
     927
     928    glDisable(GL_LIGHTING);
     929    glDisable(GL_BLEND);
     930    glDisable(GL_TEXTURE_2D);
     931  }
     932
     933  glPushMatrix();
     934  /* translate */
     935  /* rotate */
     936  glColor3f(color.x, color.y, color.z);
     937
     938  glTranslatef (this->getAbsCoor2D().x, this->getAbsCoor2D().y, 0);
     939  glRotatef(this->getAbsDir2D(), 0,0,1);
     940  glBegin(GL_LINE_LOOP);
     941  glVertex2f(-this->getSizeX2D(), -this->getSizeY2D());
     942  glVertex2f(-this->getSizeX2D(), +this->getSizeY2D());
     943  glVertex2f(+this->getSizeX2D(), +this->getSizeY2D());
     944  glVertex2f(+this->getSizeX2D(), -this->getSizeY2D());
     945  glEnd();
     946
     947
     948  glPopMatrix();
     949  if (depth >= 2 || depth == 0)
     950  {
     951    Vector childColor =  Color::HSVtoRGB(Color::RGBtoHSV(color)+Vector(20,0,.0));
     952    tIterator<Element2D>* iterator = this->children->getIterator();
     953    Element2D* pn = iterator->firstElement();
     954    while( pn != NULL)
     955    {
     956      // drawing the Dependency graph
     957      if (this != NullElement2D::getInstance())
     958      {
     959        glBegin(GL_LINES);
     960        glColor3f(color.x, color.y, color.z);
     961        glVertex3f(this->getAbsCoor2D ().x,
     962                   this->getAbsCoor2D ().y,
     963                   0);
     964        glColor3f(childColor.x, childColor.y, childColor.z);
     965        glVertex3f(pn->getAbsCoor2D ().x,
     966                   pn->getAbsCoor2D ().y,
     967                   0);
     968        glEnd();
     969      }
     970      if (depth == 0)
     971        pn->debugDraw2D(0, size, childColor, level+1);
     972      else
     973        pn->debugDraw2D(depth - 1, size, childColor, level +1);
     974      pn = iterator->nextElement();
     975    }
     976    delete iterator;
     977  }
     978  if (level == 0)
     979    glPopAttrib();
    923980
    924981}
Note: See TracChangeset for help on using the changeset viewer.