Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: text renders as good as before, but now as Element2D

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