Changeset 4858 in orxonox.OLD for orxonox/trunk/src/lib/graphics/render2D
- Timestamp:
- Jul 14, 2005, 12:43:39 AM (19 years ago)
- Location:
- orxonox/trunk/src/lib/graphics/render2D
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/src/lib/graphics/render2D/element_2d.cc
r4856 r4858 21 21 #include "graphics_engine.h" 22 22 #include "p_node.h" 23 #include "load_param.h" 24 #include "tinyxml.h" 25 #include "class_list.h" 23 26 24 27 using namespace std; … … 44 47 45 48 49 /** 50 * initializes a Element2D 51 */ 46 52 void Element2D::init() 47 53 { … … 52 58 53 59 Render2D::getInstance()->registerElement2D(this); 60 } 61 62 /** 63 * Loads the Parameters of an Element2D from... 64 * @param root The XML-element to load from 65 */ 66 void Element2D::loadParams(const TiXmlElement* root) 67 { 68 LoadParam<Element2D>(root, "alignment", this, &Element2D::setAlignment) 69 .describe("loads the alignment: (either: center, left, right or screen-center)"); 70 71 LoadParam<Element2D>(root, "layer", this, &Element2D::setLayer) 72 .describe("loads the layer onto which to project: (either: top, medium, bottom, below-all)"); 73 74 LoadParam<Element2D>(root, "bind-node", this, &Element2D::setBindNode) 75 .describe("sets a node, this 2D-Element should be shown upon (name of the node)"); 76 77 LoadParam<Element2D>(root, "2d-position", this, &Element2D::setPosition2D) 78 .describe("the _relative_ position (away from alignment) this 2d-element shows"); 79 80 // LoadParam<Element2D>(root, "visibility", this, &Element2D::setVisibility) 81 // .describe("if the Element is visible or not"); 82 } 83 84 /** 85 * sets the alignment of the 2D-element in form of a String 86 * @param alignment the alignment @see loadParams 87 */ 88 void Element2D::setAlignment(const char* alignment) 89 { 90 if (!strcmp(alignment, "center")) 91 this->setAlignment(E2D_ALIGN_CENTER); 92 else if (!strcmp(alignment, "left")) 93 this->setAlignment(E2D_ALIGN_LEFT); 94 else if (!strcmp(alignment, "right")) 95 this->setAlignment(E2D_ALIGN_RIGHT); 96 else if (!strcmp(alignment, "screen-center")) 97 this->setAlignment(E2D_ALIGN_SCREEN_CENTER); 98 } 99 100 /** 101 * sets the layer onto which this 2D-element is projected to. 102 * @param layer the layer @see loadParams 103 */ 104 void Element2D::setLayer(const char* layer) 105 { 106 if (!strcmp(layer, "top")) 107 this->setLayer(E2D_TOP); 108 else if (!strcmp(layer, "medium")) 109 this->setLayer(E2D_MEDIUM); 110 else if (!strcmp(layer, "bottom")) 111 this->setLayer(E2D_BOTTOM); 112 else if (!strcmp(layer, "below-all")) 113 this->setLayer(E2D_BELOW_ALL); 114 } 115 116 117 /** 118 * sets a node, this 2D-Element should be shown upon 119 * @param bindNode the name of the Node (should be existing) 120 */ 121 void Element2D::setBindNode(const char* bindNode) 122 { 123 const PNode* tmpBindNode = dynamic_cast<const PNode*>(ClassList::getObject(bindNode, CL_PARENT_NODE)); 124 if (tmpBindNode != NULL) 125 this->bindNode = tmpBindNode; 54 126 } 55 127 -
orxonox/trunk/src/lib/graphics/render2D/element_2d.h
r4856 r4858 11 11 // FORWARD DECLARATION 12 12 class PNode; 13 class TiXmlElement; 13 14 14 15 //!< An enumerator defining the Depth of a 2D-element. … … 48 49 virtual ~Element2D(); 49 50 51 void init(); 52 void loadParams(const TiXmlElement* root); 53 50 54 /** @param xCoord the xCoordinate @param yCoord the y-Coordinate. These coordinates are Relative */ 51 55 inline void setPosition2D(int xCoord, int yCoord) { this->relPos2D[0] = xCoord; this->relPos2D[1] = yCoord; }; … … 54 58 /** @param alignment the new Alignment of the 2D-Element */ 55 59 inline void setAlignment(E2D_ALIGNMENT alignment) { this->alignment = alignment; }; 60 void setAlignment(const char* alignment); 56 61 /** @param layer the Layer this is drawn on */ 57 62 inline void setLayer(E2DLayer layer) { this->layer = layer; }; 63 void setLayer(const char* layer); 58 64 /** @param visible true if the Element should be visible false otherwise (will not be rendered) */ 59 65 inline void setVisibility(bool visible) { this->visible = visible; }; 60 66 /** @param bindNode the Node this 2D-element should follow. if NULL the Element will not follow anything */ 61 67 inline void setBindNode(const PNode* bindNode) { this->bindNode = bindNode; }; 68 void setBindNode(const char* bindNode); 62 69 63 70 /** @returns the visibility state */ 64 71 inline bool isVisible() { return this->visible; }; 65 72 66 void positioning();67 73 virtual void tick(float dt); 68 74 virtual void draw() const = NULL; 69 75 70 pr ivate:71 void init();76 protected: 77 void positioning(); 72 78 73 79 protected:
Note: See TracChangeset
for help on using the changeset viewer.