Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: more 2D-definitions, better draw function

File size: 2.4 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,
29  E2D_ALIGN_LEFT,
30  E2D_ALIGN_RIGHT,
31  E2D_ALIGN_CENTER,
32  E2D_ALIGN_SCREEN_CENTER
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
44//! A class for ...
45class Element2D : public BaseObject {
46
47 public:
48  Element2D();
49  virtual ~Element2D();
50
51  void setPosition(int xCoord, int yCoord);
52  void setLayer(E2DLayer layer);
53  /** @param visible true if the Element should be visible false otherwise (will not be rendered) */
54  inline void setVisibility(bool visible) { this->visible = visible; };
55  /** @param bindNode the Node this 2D-element should follow. if NULL the Element will not follow anything */
56  inline void setBindNode(const PNode* bindNode) { this->bindNode = bindNode; };
57
58  /** @returns the visibility state */
59  inline bool isVisible() { return this->visible; };
60
61  void positioning();
62  virtual void tick(float dt);
63  virtual void draw() const = NULL;
64
65  private:
66    void init();
67
68 private:
69   bool                    visible;
70   int                     relPos2D[2];      //!< X-coord, Y-Coord (relative to the Coordinates of the alignment if given.)
71   Position2D              absPos2D;         //!< The absolute position of the 2D-Element.
72   E2DLayer                layer;
73
74   E2D_ALIGNMENT           alignment;        //!< How the Element is aligned around its Position
75   const PNode*            bindNode;         //!< a node over which to display this 2D-element
76};
77
78
79#endif /* _ELEMENT_2D_H */
Note: See TracBrowser for help on using the repository browser.