Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4856 in orxonox.OLD for orxonox/trunk/src/lib/graphics/render2D


Ignore:
Timestamp:
Jul 14, 2005, 12:15:38 AM (19 years ago)
Author:
bensch
Message:

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

Location:
orxonox/trunk/src/lib/graphics/render2D
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/graphics/render2D/element_2d.cc

    r4847 r4856  
    4848  this->setClassID(CL_ELEMENT_2D, "Element2D");
    4949
     50  this->setPosition2D(0,0);
     51  this->setAlignment(E2D_ALIGN_CENTER);
     52
    5053  Render2D::getInstance()->registerElement2D(this);
    51 
    5254}
    5355
     
    5860void Element2D::positioning()
    5961{
    60   // setting the Position of this ELEM2D.
    61   if (this->bindNode)
     62
     63  // setting the Position of this 2D-Element.
     64  if (this->alignment == E2D_ALIGN_SCREEN_CENTER)
     65  {
     66    absPos2D.x = GraphicsEngine::getInstance()->getResolutionX()/2 + this->relPos2D[0];
     67    absPos2D.y = GraphicsEngine::getInstance()->getResolutionY()/2 + this->relPos2D[1];
     68    absPos2D.depth = 0;
     69  }
     70  else if (this->bindNode)
    6271  {
    6372    GLdouble projectPos[3];
  • orxonox/trunk/src/lib/graphics/render2D/element_2d.h

    r4850 r4856  
    2626typedef enum
    2727{
    28   E2D_ALIGN_NONE,
    29   E2D_ALIGN_LEFT,
    30   E2D_ALIGN_RIGHT,
    31   E2D_ALIGN_CENTER,
    32   E2D_ALIGN_SCREEN_CENTER
     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
    3333} E2D_ALIGNMENT;
    3434
     
    3939  float       y;                 //!< The y-coordinate.
    4040  float       depth;             //!< The distance from the viewing plane.
    41 
    4241};
    4342
     
    4948    virtual ~Element2D();
    5049
    51     void setPosition2D(int xCoord, int yCoord);
    52     void setLayer(E2DLayer layer);
     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; };
    5358    /** @param visible true if the Element should be visible false otherwise (will not be rendered) */
    5459    inline void setVisibility(bool visible) { this->visible = visible; };
    5560    /** @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; };
     61   inline void setBindNode(const PNode* bindNode) { this->bindNode = bindNode; };
    5762
    5863    /** @returns the visibility state */
     
    6873  protected:
    6974    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
    7080  private:
    7181    bool                    visible;
    72     int                     relPos2D[2];      //!< X-coord, Y-Coord (relative to the Coordinates of the alignment if given.)
    73     Position2D              absPos2D;         //!< The absolute position of the 2D-Element.
    7482    E2DLayer                layer;
    7583
    76     E2D_ALIGNMENT           alignment;        //!< How the Element is aligned around its Position
    7784};
    7885
Note: See TracChangeset for help on using the changeset viewer.