Changeset 7332 in orxonox.OLD for trunk/src/lib/graphics/render2D
- Timestamp:
- Apr 18, 2006, 5:35:11 PM (19 years ago)
- Location:
- trunk/src/lib/graphics/render2D
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/render2D/element_2d.cc
r7330 r7332 29 29 #include "color.h" 30 30 31 //#include "shell_command.h"32 //SHELL_COMMAND(debug, Element2D, debug2D);31 #include "shell_command.h" 32 SHELL_COMMAND(debug, Element2D, debug2DSC); 33 33 34 34 using namespace std; … … 99 99 deleteNode = tmp; 100 100 tmp++; 101 // printf("TEST::%s(%s) %s\n", (*deleteNode)->getName(), (*deleteNode)->getClassName(), this->getName());101 // printf("TEST::%s(%s) %s\n", (*deleteNode)->getName(), (*deleteNode)->getClassName(), this->getName()); 102 102 if ((this->parentMode & E2D_PROHIBIT_CHILD_DELETE) || 103 103 ((*deleteNode)->parentMode & E2D_PROHIBIT_DELETE_WITH_PARENT)) … … 139 139 // ELEMENT2D-native settings. 140 140 LoadParam(root, "alignment", this, Element2D, setAlignment) 141 141 .describe("loads the alignment: (either: center, left, right or screen-center)"); 142 142 143 143 LoadParam(root, "layer", this, Element2D, setLayer) 144 144 .describe("loads the layer onto which to project: (either: top, medium, bottom, below-all)"); 145 145 146 146 LoadParam(root, "bind-node", this, Element2D, setBindNode) 147 147 .describe("sets a node, this 2D-Element should be shown upon (name of the node)"); 148 148 149 149 LoadParam(root, "visibility", this, Element2D, setVisibility) 150 151 152 153 // PNode-style:150 .describe("if the Element is visible or not"); 151 152 153 // PNode-style: 154 154 LoadParam(root, "rel-coor-2d", this, Element2D, setRelCoor2D) 155 155 .describe("Sets The relative position of the Node to its parent."); 156 156 157 157 LoadParam(root, "abs-coor-2d", this, Element2D, setAbsCoor2D) 158 158 .describe("Sets The absolute Position of the Node."); 159 159 160 160 LoadParam(root, "rel-dir-2d", this, Element2D, setRelDir2D) 161 161 .describe("Sets The relative rotation of the Node to its parent."); 162 162 163 163 LoadParam(root, "abs-dir-2d", this, Element2D, setAbsDir2D) 164 164 .describe("Sets The absolute rotation of the Node."); 165 165 166 166 LoadParam(root, "parent", this, Element2D, setParent2D) 167 167 .describe("the Name of the Parent of this Element2D"); 168 168 169 169 LoadParam(root, "parent-mode", this, Element2D, setParentMode2D) 170 170 .describe("the mode to connect this node to its parent ()"); 171 171 172 172 // cycling properties … … 174 174 { 175 175 LoadParam_CYCLE(element, "child", this, Element2D, addChild2D) 176 176 .describe("adds a new Child to the current Node."); 177 177 } 178 178 LOAD_PARAM_END_CYCLE(element); … … 282 282 { 283 283 this->setRelCoor2D(Vector2D((float)x/(float)GraphicsEngine::getInstance()->getResolutionX(), 284 (float)y/(float)GraphicsEngine::getInstance()->getResolutionY()));284 (float)y/(float)GraphicsEngine::getInstance()->getResolutionY())); 285 285 } 286 286 … … 308 308 { 309 309 this->setRelCoorSoft2D(Vector2D((float)x/(float)GraphicsEngine::getInstance()->getResolutionX(), 310 (float)y/(float)GraphicsEngine::getInstance()->getResolutionY()),310 (float)y/(float)GraphicsEngine::getInstance()->getResolutionY()), 311 311 bias); 312 312 } … … 373 373 { 374 374 this->setAbsCoor2D(Vector2D((float)x/(float)GraphicsEngine::getInstance()->getResolutionX(), 375 (float)y/(float)GraphicsEngine::getInstance()->getResolutionY()));375 (float)y/(float)GraphicsEngine::getInstance()->getResolutionY())); 376 376 } 377 377 … … 436 436 { 437 437 this->shiftCoor2D(Vector2D((float)x/(float)GraphicsEngine::getInstance()->getResolutionX(), 438 (float)y/(float)GraphicsEngine::getInstance()->getResolutionY()));438 (float)y/(float)GraphicsEngine::getInstance()->getResolutionY())); 439 439 } 440 440 … … 533 533 if (this->checkIntegrity(child)) 534 534 { 535 // Setting the New Parent. 535 536 child->parent = this; 536 537 if (likely(this != NULL)) 537 538 { 538 // ELEMENT SORTING TO LAYERS // 539 unsigned int childCount = this->children.size(); 540 541 list<Element2D*>::iterator elem; 542 for (elem = this->children.begin(); elem != this->children.end(); elem++) 543 { 544 if ((*elem)->layer < child->layer) 545 { 546 this->children.insert(elem, child); 547 break; 548 } 549 } 550 if (childCount == this->children.size()) 551 this->children.push_back(child); 552 //////////////////////////////// 553 if (unlikely(this->layer > child->getLayer())) 554 { 555 PRINTF(2)("Layer '%s' of Child(%s) lower than parents(%s) layer '%s'. updating...\n", 556 Element2D::layer2DToChar(child->getLayer()),child->getName(), this->getName(), Element2D::layer2DToChar(this->layer)); 557 child->setLayer(this->layer); 558 } 559 } 560 else 561 { 562 PRINTF(1)("Tried to reparent2D to own child '%s::%s' to '%s::%s'.\n", 563 this->getClassName(), this->getName(), child->getClassName(), child->getName()); 564 child->parent = NULL; 565 } 539 // Layers of Children that are smaller than this(parents) Layer will be updated, and pushed to the front. 540 if (unlikely(this->layer > child->getLayer())) 541 { 542 PRINTF(2)("Layer '%s' of Child(%s::%s) lower than parents(%s::%s) layer '%s'. updating...\n", 543 Element2D::layer2DToChar(child->getLayer()),child->getClassName(), child->getName(), 544 this->getClassName(), this->getName(), Element2D::layer2DToChar(this->layer)); 545 child->layer = this->layer; 546 this->children.push_front(child); 547 } 548 else 549 { 550 // Inserting the Element at the right Layer depth. 551 list<Element2D*>::iterator elem; 552 for (elem = this->children.begin(); elem != this->children.end(); elem++) 553 { 554 if ((*elem)->layer <= child->layer) 555 { 556 this->children.insert(elem, child); 557 break; 558 } 559 } 560 // if we are at the Last child push it back. 561 if (elem == this->children.end()) 562 this->children.push_back(child); 563 } 564 } 565 else 566 { 567 PRINTF(1)("Tried to reparent2D to own child '%s::%s' to '%s::%s'.\n", 568 this->getClassName(), this->getName(), child->getClassName(), child->getName()); 569 child->parent = NULL; 570 } 566 571 } 567 572 child->parentCoorChanged2D(); … … 658 663 else 659 664 PRINTF(2)("Not Found Element2D's (%s::%s) new Parent by Name: %s\n", 660 665 this->getClassName(), this->getName(), parentName.c_str()); 661 666 } 662 667 … … 787 792 if( likely(this->parent != NULL)) 788 793 { 789 794 // movement for nodes with smoothMove enabled 790 795 if (unlikely(this->toCoordinate != NULL)) 791 796 { … … 865 870 projectPos+1, 866 871 projectPos+2); 867 // printf("%s::%s == %f %f %f :: %f %f\n", this->getClassName(), this->getName(),868 // this->bindNode->getAbsCoor().x,869 // this->bindNode->getAbsCoor().y,870 // this->bindNode->getAbsCoor().z,871 // projectPos[0],872 // projectPos[1]);872 // printf("%s::%s == %f %f %f :: %f %f\n", this->getClassName(), this->getName(), 873 // this->bindNode->getAbsCoor().x, 874 // this->bindNode->getAbsCoor().y, 875 // this->bindNode->getAbsCoor().z, 876 // projectPos[0], 877 // projectPos[1]); 873 878 874 879 this->prevRelCoordinate.x = this->absCoordinate.x = projectPos[0] /* /(float)GraphicsEngine::getInstance()->getResolutionX() */ + this->relCoordinate.x; … … 890 895 float sine = sin(this->parent->getAbsDir2D()); 891 896 float cose = cos(this->parent->getAbsDir2D()); 892 // this->absCoordinate.x = this->relCoordinate.x*cose - this->relCoordinate.y*sine + this->parent->getRelCoor2D().x*(1-cose) +this->parent->getRelCoor2D().y*sine;893 // this->absCoordinate.y = this->relCoordinate.x*sine + this->relCoordinate.y*cose + this->parent->getRelCoor2D().y*(1-cose) +this->parent->getRelCoor2D().x*sine;897 // this->absCoordinate.x = this->relCoordinate.x*cose - this->relCoordinate.y*sine + this->parent->getRelCoor2D().x*(1-cose) +this->parent->getRelCoor2D().y*sine; 898 // this->absCoordinate.y = this->relCoordinate.x*sine + this->relCoordinate.y*cose + this->parent->getRelCoor2D().y*(1-cose) +this->parent->getRelCoor2D().x*sine; 894 899 895 900 this->absCoordinate.x = this->parent->getAbsCoor2D().x + (this->relCoordinate.x*cos(this->parent->getAbsDir2D()) - this->relCoordinate.y * sin(this->parent->getAbsDir2D())); … … 953 958 else 954 959 PRINT(0)(" -"); 955 PRINT(0)("E lement2D(%s::%s) - absCoord: (%0.2f, %0.2f), relCoord(%0.2f, %0.2f), direction(%0.2f) - %s, layer:%s\n",956 957 958 959 960 961 962 963 964 960 PRINT(0)("E2D(%s::%s);AC:(%0.2f, %0.2f);RC:(%0.2f, %0.2f);AD(%0.2f)->%s;Layer:(%s)\n", 961 this->getClassName(), 962 this->getName(), 963 this->absCoordinate.x, 964 this->absCoordinate.y, 965 this->relCoordinate.x, 966 this->relCoordinate.y, 967 this->getAbsDir2D(), 968 Element2D::parentingModeToString2D(parentMode), 969 Element2D::layer2DToChar(this->layer)); 965 970 966 971 if (depth >= 2 || depth == 0) -
trunk/src/lib/graphics/render2D/element_2d.h
r7330 r7332 210 210 211 211 void debug2D (unsigned int depth = 1, unsigned int level = 0) const; 212 void debug2DSC (unsigned int depth = 1, unsigned int level = 0) { this->debug2D(depth, level); }; // Wrapping Function for ShellCommand. 212 213 void debugDraw2D(unsigned int depth = 1, float size = 1.0, Vector color = Vector(1,0,0), unsigned int level = 0) const; 213 214
Note: See TracChangeset
for help on using the changeset viewer.