Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 15, 2005, 7:13:23 PM (20 years ago)
Author:
bensch
Message:

orxonox/branches/2d-recalc: some recalculations.. do not know it i will continue with this, as has certain disadvantages over the old approach… maybe later

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2d-recalc/src/lib/graphics/render2D/element_2d.h

    r5380 r5381  
    22 * @file element_2d.h
    33 * Definition of the 2D elements rendered on top through the GraphicsEngine
    4  *
    5  * @todo reimplement it, so it looks just like PNode.
    6 */
     4 */
    75
    86#ifndef _ELEMENT_2D_H
     
    3735  E2D_ALIGN_RIGHT               =     2,
    3836  E2D_ALIGN_CENTER              =     4,
    39   E2D_ALIGN_SCREEN_CENTER       =     8
     37  E2D_ALIGN_SCREEN_CENTER       =     8,
    4038} E2D_ALIGNMENT;
    4139
     
    9896    inline bool isActive() { return this->active; };
    9997
    100 
     98    /////////////
     99    // SCALING //
     100    /////////////
    101101    inline void setSize2D(float x, float y) { this->sizeX = x, this->sizeY = y; };
    102102    void setSize2Dpx(int x, int y);
     
    110110    int getSizeY2Dpx() const;
    111111
    112     // LIKE PNODE
    113   public:
     112    // PNODE-STYLE-behavioral
     113  public:
     114    /////////////////
     115    // COORDINATES //
     116    /////////////////
     117    // RELATIVE //
    114118    void setRelCoor2D (const Vector& relCoord);
    115     void setRelCoor2D (float x, float y, float dontCare = 1.0);
     119    /** @param x x-coordinate.  @param y y-coordinate. @param z z-coordinate. @see void PNode::setRelCoor2D (const Vector& absCoord) */
     120    void setRelCoor2D (float x, float y, float dontCare = 1.0) { this->setRelCoor2D(Vector(x, y, dontCare)); };
    116121    void setRelCoor2Dpx (int x, int y);
     122    inline void setRelCoor2Dpx (const Vector& relCoordpx) { this->setRelCoor2D(relCoordpx.x, relCoordpx.y); };
    117123    void setRelCoorSoft2D (const Vector& relCoordSoft, float bias = 1.0);
    118     void setRelCoorSoft2D (float x, float y, float dontCare = 1.0, float bias = 1.0);
     124    /** set relative coordinates smoothely @param x x-relative coordinates to its parent
     125     * @param y y-relative coordinates to its parent @param z z-relative coordinates to its parent
     126     * @see  void PNode::setRelCoorSoft (const Vector&, float) */
     127    void setRelCoorSoft2D (float x, float y, float dontCare = 1.0, float bias = 1.0) { this->setRelCoorSoft2D(Vector(x,y, dontCare), bias); };
    119128    void setRelCoorSoft2Dpx (int x, int y, float bias = 1.0);
    120129    /** @returns the relative position */
     
    122131    /** @returns the Relative Coordinate Destination */
    123132    inline const Vector& getRelCoorSoft2D() const { return (this->toCoordinate)?*this->toCoordinate:this->relCoordinate; };
    124     const Vector& getRelCoor2Dpx() const;
     133    Vector getRelCoor2Dpx() const;
     134    // ABSOLUTE //
    125135    void setAbsCoor2D (const Vector& absCoord);
    126     void setAbsCoor2D (float x, float y, float depth = 1.0);
     136    /** @param x x-coordinate.  @param y y-coordinate. @param z z-coordinate. @see void PNode::setAbsCoor2D (const Vector& absCoord) */
     137    void setAbsCoor2D (float x, float y, float depth = 1.0) { this->setAbsCoor2D(Vector(x, y, depth)); };
    127138    void setAbsCoor2Dpx (int x, int y);
    128139    /** @returns the absolute position */
    129140    inline const Vector& getAbsCoor2D () const { return this->absCoordinate; };
    130     const Vector& getAbsCoor2Dpx () const;
     141    Vector getAbsCoor2Dpx () const;
    131142
    132143    void shiftCoor2D (const Vector& shift);
    133144    void shiftCoor2Dpx (int x, int y);
    134145
     146    /** @returns the Speed of the Node */
     147    inline float getSpeed() const { return 0; };
     148    /** @returns the Velocity of the Node */
     149    inline const Vector& getVelocity() const { return this->velocity; };
     150
     151    ////////////////
     152    // DIRECTIONS //
     153    ////////////////
     154    // RELATIVE //
    135155    void setRelDir2D (float relDir);
    136156    void setRelDirSoft2D(float relDirSoft, float bias = 1.0);
     
    139159    /** @returns the Relative Directional Destination */
    140160    inline float getRelDirSoft2D() const { return (this->toDirection)?*this->toDirection:this->relDirection; };
     161    // ABSOLUTE //
    141162    void setAbsDir2D (float absDir);
    142163    /** @returns the absolute Direction */
    143164    inline float getAbsDir2D () const { return this->absDirection; };
    144165    void shiftDir2D (float shiftDir);
    145 
    146     /** @returns the Speed of the Node */
    147     inline float getSpeed() const { return 0; };
    148     /** @returns the Velocity of the Node */
    149     inline const Vector& getVelocity() const { return this->velocity; };
    150 
    151 
     166    ///////////////
     167    // PARENTING //
     168    ///////////////
    152169    void addChild2D (Element2D* child, int parentingMode = E2D_PARENT_NONE);
    153170    void addChild2D (const char* childName);
     
    169186    int getParentMode2D() const { return this->parentMode; };
    170187
     188
     189    //////////////
     190    // HANDLING //
     191    //////////////
    171192    void update2D (float dt);
    172193
     
    192213  private:
    193214    const PNode*            bindNode;           //!< a node over which to display this 2D-element
     215    bool                    coordinateType;     //!< true if type is [0-1],[0-1]-style, false if type is [0-ResolutionX][0-ResolutionY]-style.
     216
    194217    float                   sizeX;              //!< The size of the rendered item in x-direction
    195218    float                   sizeY;              //!< The size of the rendered Item in y-direction
     
    212235    Vector                  lastAbsCoordinate;  //!< this is used for speedcalculation, it stores the last coordinate
    213236    float                   prevRelDirection;   //!< The last Relative Direciton from the last update-Cycle.
    214 //  float                   lastAbsDirection;
    215237
    216238    Vector                  velocity;           //!< Saves the velocity.
Note: See TracChangeset for help on using the changeset viewer.