Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5417 in orxonox.OLD for trunk/src/lib/graphics/render2D


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

Location:
trunk/src/lib/graphics/render2D
Files:
4 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}
  • trunk/src/lib/graphics/render2D/element_2d.h

    r5414 r5417  
    185185
    186186    void debug (unsigned int depth = 1, unsigned int level = 0) const;
    187     void debugDraw2D(unsigned int depth = 1, float size = 1.0, Vector color = Vector(1,1,1)) const;
     187    void debugDraw2D(unsigned int depth = 1, float size = 1.0, Vector color = Vector(1,0,0), unsigned int level = 0) const;
    188188
    189189    // helper functions //
  • trunk/src/lib/graphics/render2D/render_2d.cc

    r5406 r5417  
    2525#include <math.h>
    2626
     27#include "shell_command.h"
     28SHELL_COMMAND(toggleNodeVisibility, Render2D, toggleNodesVisibility);
     29
    2730using namespace std;
    2831
     
    3437   this->setClassID(CL_RENDER_2D, "Render2D");
    3538   this->setName("Render2D");
     39
     40   this->showNodes = false;
    3641}
    3742
     
    7883  GraphicsEngine::enter2DMode();
    7984  NullElement2D::getInstance()->draw2D(E2D_LAYER_ALL);
     85  if (this->showNodes)
     86    NullElement2D::getInstance()->debugDraw2D(0);
    8087  GraphicsEngine::leave2DMode();
    8188}
  • trunk/src/lib/graphics/render2D/render_2d.h

    r5406 r5417  
    2222    inline static Render2D* getInstance() { if (!singletonRef) singletonRef = new Render2D();  return singletonRef; };
    2323
     24    void toggleNodesVisibility() { this->showNodes = !this->showNodes; };
     25
    2426    void update(float dt);
    2527    void tick(float dt);
     
    3032    static Render2D*              singletonRef;                    //!< Reference to this class.
    3133
     34    bool                          showNodes;                       //!< If the debug-Nodes should be visible
    3235 };
    3336
Note: See TracChangeset for help on using the changeset viewer.