Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/graphics/render2D/element_2d.h @ 5070

Last change on this file since 5070 was 5068, checked in by bensch, 19 years ago

orxonox/trunk: added Shell Class to the utils.
This class should enable us to print all the output from orxonox directly onto the screen.
Also it should allow inputting some little Commands, so that we have more force over our little project :)

Also added a new Function to tList, removeLast, that is very quick in deleting the last element, as this is used inside of the Shell (deleting the Last Element is a major issue)

File size: 3.9 KB
Line 
1/*!
2 * @file element_2d.h
3 * @brief Definition of the 2D elements rendered on top through the GraphicsEngine
4*/
5
6#ifndef _ELEMENT_2D_H
7#define _ELEMENT_2D_H
8
9#include "base_object.h"
10
11// FORWARD DECLARATION
12class PNode;
13class TiXmlElement;
14
15//!< An enumerator defining the Depth of a 2D-element.
16typedef enum
17{
18  E2D_BELOW_ALL                 =     1,        //!< Will be rendered below the 3D-scene. @todo make this work.
19  E2D_BOTTOM                    =     2,        //!< Will be rendered on the bottom Layer
20  E2D_MEDIUM                    =     4,        //!< Will be rendered on the medium Layer.
21  E2D_TOP                       =     8,        //!< Will be rendered on top of everything else
22
23  E2D_LAYER_COUNT               =     4         //!< The count of Layers.
24} E2D_LAYER;
25#define E2D_DEFAULT_LAYER       E2D_TOP
26#define E2D_ALL_LAYERS          E2D_TOP | E2D_MEDIUM | E2D_BOTTOM | E2D_BELOW_ALL
27
28typedef enum
29{
30  E2D_ALIGN_NONE                =     0,
31  E2D_ALIGN_LEFT                =     1,
32  E2D_ALIGN_RIGHT               =     2,
33  E2D_ALIGN_CENTER              =     4,
34  E2D_ALIGN_SCREEN_CENTER       =     8
35} E2D_ALIGNMENT;
36
37//! A Struct defining the Position of an Element in 2D-space
38struct Position2D
39{
40  float       x;                 //!< The x-coordinate.
41  float       y;                 //!< The y-coordinate.
42  float       depth;             //!< The distance from the viewing plane.
43};
44
45//! A class for ...
46class Element2D : virtual public BaseObject {
47
48  public:
49    Element2D();
50    virtual ~Element2D();
51
52    void init();
53    void loadParams(const TiXmlElement* root);
54
55    /** @param xCoord the xCoordinate @param yCoord the y-Coordinate. These coordinates are Relative */
56    inline void setPosition2D(int xCoord, int yCoord) { this->relPos2D[0] = xCoord; this->relPos2D[1] = yCoord; };
57    /** this returns the Absolute Position on the screen set by positioning in the tick-phase */
58    inline const Position2D& getPosition2D() { return this->absPos2D; };
59
60    /** @param alignment the new Alignment of the 2D-Element */
61    inline void setAlignment(E2D_ALIGNMENT alignment) { this->alignment = alignment; };
62    void setAlignment(const char* alignment);
63
64    void setLayer(E2D_LAYER layer);
65    void setLayer(const char* layer);
66    /** @returns the Layer this Element is drawn to */
67    inline E2D_LAYER getLayer() { return this->layer; };
68
69    /** @param visible true if the Element should be visible false otherwise (will not be rendered) */
70    inline void setVisibility(bool visible) { this->visible = visible; };
71    /** @param active true if the Element should be active, false otherwise (will not be ticked) */
72    inline void setActiveness(bool active) { this->active = active; };
73
74
75    /** @param bindNode the Node this 2D-element should follow. if NULL the Element will not follow anything */
76    inline void setBindNode(const PNode* bindNode) { this->bindNode = bindNode; };
77    void setBindNode(const char* bindNode);
78
79    /** @returns the visibility state */
80    inline bool isVisible() { return this->visible; };
81    /** @returns the active-State */
82    inline bool isActive() { return this->active; };
83
84    virtual void tick(float dt);
85    virtual void draw() const = NULL;
86
87  protected:
88    void positioning();
89
90  protected:
91    const PNode*            bindNode;         //!< a node over which to display this 2D-element
92    int                     relPos2D[2];      //!< X-coord, Y-Coord (relative to the Coordinates of the alignment if given.)
93    Position2D              absPos2D;         //!< The absolute position of the 2D-Element.
94
95    E2D_ALIGNMENT           alignment;        //!< How the Element is aligned around its Position
96
97  private:
98    bool                    visible;          //!< If the given Element2D is visible.
99    bool                    active;           //!< If the given Element2D is active.
100    E2D_LAYER               layer;            //!< What layer this Element2D is on.
101};
102
103
104#endif /* _ELEMENT_2D_H */
Note: See TracBrowser for help on using the repository browser.