Changeset 5417 in orxonox.OLD for trunk/src/lib/graphics/render2D
- Timestamp:
- Oct 21, 2005, 11:09:57 AM (19 years ago)
- Location:
- trunk/src/lib/graphics/render2D
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/render2D/element_2d.cc
r5414 r5417 902 902 if (this->visible) 903 903 this->draw(); 904 if (this->children->getSize() > 0)904 if (this->children->getSize() > 0) 905 905 { 906 906 tIterator<Element2D>* drawIT = children->getIterator(); … … 919 919 * displays the Element2D at its position with its rotation as a Plane. 920 920 */ 921 void Element2D::debugDraw2D(unsigned int depth, float size, Vector color) const 922 { 921 void 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(); 923 980 924 981 } -
trunk/src/lib/graphics/render2D/element_2d.h
r5414 r5417 185 185 186 186 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; 188 188 189 189 // helper functions // -
trunk/src/lib/graphics/render2D/render_2d.cc
r5406 r5417 25 25 #include <math.h> 26 26 27 #include "shell_command.h" 28 SHELL_COMMAND(toggleNodeVisibility, Render2D, toggleNodesVisibility); 29 27 30 using namespace std; 28 31 … … 34 37 this->setClassID(CL_RENDER_2D, "Render2D"); 35 38 this->setName("Render2D"); 39 40 this->showNodes = false; 36 41 } 37 42 … … 78 83 GraphicsEngine::enter2DMode(); 79 84 NullElement2D::getInstance()->draw2D(E2D_LAYER_ALL); 85 if (this->showNodes) 86 NullElement2D::getInstance()->debugDraw2D(0); 80 87 GraphicsEngine::leave2DMode(); 81 88 } -
trunk/src/lib/graphics/render2D/render_2d.h
r5406 r5417 22 22 inline static Render2D* getInstance() { if (!singletonRef) singletonRef = new Render2D(); return singletonRef; }; 23 23 24 void toggleNodesVisibility() { this->showNodes = !this->showNodes; }; 25 24 26 void update(float dt); 25 27 void tick(float dt); … … 30 32 static Render2D* singletonRef; //!< Reference to this class. 31 33 34 bool showNodes; //!< If the debug-Nodes should be visible 32 35 }; 33 36
Note: See TracChangeset
for help on using the changeset viewer.