Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Aug 19, 2005, 12:49:21 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: Element2D: PNode-style declaration

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

Legend:

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

    r5068 r5081  
    177177}
    178178
     179
     180void Element2D::setRelCoor2D (const Vector& relCoord)
     181{
     182}
     183
     184
     185void Element2D::setRelCoor2D (float x, float y, float z)
     186{
     187}
     188
     189void Element2D::setRelCoorSoft2D(const Vector& relCoordSoft, float bias)
     190{
     191}
     192
     193void Element2D::setRelCoorSoft2D(float x, float y, float dontCare, float bias)
     194{
     195}
     196
     197void Element2D::setAbsCoor2D (const Vector& absCoord)
     198{
     199}
     200
     201void Element2D::setAbsCoor2D (float x, float y, float depth)
     202{
     203}
     204
     205void Element2D::shiftCoor (const Vector& shift)
     206{
     207}
     208
     209
     210void Element2D::setRelDir2D (float relDir)
     211{
     212}
     213
     214void Element2D::setRelDirSoft2D(float relDirSoft, float bias)
     215{
     216}
     217
     218void Element2D::setAbsDir2D (float absDir)
     219{
     220}
     221
     222void Element2D::shiftDir (float shiftDir)
     223{
     224}
     225
     226
     227void Element2D::addChild2D (Element2D* child, int parentingMod)
     228{
     229}
     230
     231void Element2D::addChild2D (const char* childName)
     232{
     233}
     234
     235void Element2D::removeChild2D (Element2D* child)
     236{
     237}
     238
     239void Element2D::remove2D()
     240{
     241}
     242
     243
     244void Element2D::setParent2D (Element2D* parent)
     245{
     246}
     247
     248void Element2D::setParent2D (const char* parentName)
     249{
     250}
     251
     252
     253void Element2D::softReparent(PNode* parentNode, float bias)
     254{
     255}
     256
     257void Element2D::softReparent(const char* parentName, float bias)
     258{
     259}
     260
     261
     262void Element2D::setParentMode2D (const char* parentingMode)
     263{
     264}
     265
     266
     267void Element2D::update2D (float dt)
     268{
     269}
     270
     271
     272void Element2D::debug (unsigned int depth, unsigned int level) const
     273{
     274}
     275
     276void Element2D::debugDraw2D(unsigned int depth, float size, Vector color) const
     277{
     278}
     279
     280
     281// helper functions //
     282const char* Element2D::parentingModeToChar(int parentingMode)
     283{
     284}
     285
     286E2D_PARENT_MODE Element2D::charToParentingMode(const char* parentingMode)
     287{
     288}
     289
     290
     291
     292
     293
     294
    179295/**
    180296 * ticks the 2d-Element
  • trunk/src/lib/graphics/render2D/element_2d.h

    r5068 r5081  
    11/*!
    22 * @file element_2d.h
    3  * @brief Definition of the 2D elements rendered on top through the GraphicsEngine
     3 * Definition of the 2D elements rendered on top through the GraphicsEngine
     4 * @todo reimplement it, so it looks just like PNode.
    45*/
    56
     
    89
    910#include "base_object.h"
     11#include "vector.h"
    1012
    1113// FORWARD DECLARATION
    1214class PNode;
    1315class TiXmlElement;
     16template<class T> class tList;
    1417
    1518//!< An enumerator defining the Depth of a 2D-element.
     
    3538} E2D_ALIGNMENT;
    3639
     40typedef enum
     41{
     42  E2D_LOCAL_ROTATE          =   1,    //!< Rotates all the children around their centers.
     43  E2D_ROTATE_MOVEMENT       =   2,    //!< Moves all the children around the center of their parent, without the rotation around their own centers.
     44
     45  E2D_MOVEMENT              =   4,    //!< Moves all children along with the parent.
     46// special linkage modes
     47  E2D_ALL                   =   3,    //!< Moves all children around the center of their parent, and also rotates their centers
     48  E2D_ROTATE_AND_MOVE       =   5     //!< Rotates all children around their axis, and moves them as the Parent Moves, but does not rotate around the center of their parent.
     49} E2D_PARENT_MODE;
     50#define     E2D_DEFAULT_PARENTING_MODE  E2D_ALL
     51
    3752//! A Struct defining the Position of an Element in 2D-space
    3853struct Position2D
     
    8297    inline bool isActive() { return this->active; };
    8398
     99
     100    // LIKE PNODE
     101  public:
     102    void setRelCoor2D (const Vector& relCoord);
     103    void setRelCoor2D (float x, float y, float dontCare);
     104    void setRelCoorSoft2D(const Vector& relCoordSoft, float bias = 1.0);
     105    void setRelCoorSoft2D(float x, float y, float dontCare, float bias = 1.0);
     106    /** @returns the relative position */
     107    inline const Vector& getRelCoor2D () const { return this->prevRelCoordinate; };
     108    void setAbsCoor2D (const Vector& absCoord);
     109    void setAbsCoor2D (float x, float y, float depth);
     110    /** @returns the absolute position */
     111    inline const Vector& getAbsCoor2D () const { return this->absCoordinate; };
     112    void shiftCoor (const Vector& shift);
     113
     114    void setRelDir2D (float relDir);
     115    void setRelDirSoft2D(float relDirSoft, float bias = 1.0);
     116    /** @returns the relative Direction */
     117    inline float getRelDir2D () const { return this->prevRelDirection; };
     118    void setAbsDir2D (float absDir);
     119    /** @returns the absolute Direction */
     120    inline float getAbsDir2D () const { return this->absDirection; };
     121    void shiftDir (float shiftDir);
     122
     123    /** @returns the Speed of the Node */
     124    inline float getSpeed() const { return 0; };
     125    /** @returns the Velocity of the Node */
     126    inline const Vector& getVelocity() const { return this->velocity; };
     127
     128
     129    void addChild2D (Element2D* child, int parentingMode = E2D_DEFAULT_PARENTING_MODE);
     130    void addChild2D (const char* childName);
     131    void removeChild2D (Element2D* child);
     132    void remove2D();
     133
     134    void setParent2D (Element2D* parent);
     135    void setParent2D (const char* parentName);
     136    /** @returns the parent of this Element2D */
     137    Element2D* getParent () const { return this->parent; };
     138
     139    void softReparent(PNode* parentNode, float bias = 1.0);
     140    void softReparent(const char* parentName, float bias = 1.0);
     141
     142    /** @param parentMode sets the parentingMode of this Node */
     143    void setParentMode2D (E2D_PARENT_MODE parentMode) { this->parentMode = parentMode; };
     144    void setParentMode2D (const char* parentingMode);
     145    /** @returns the Parenting mode of this node */
     146    int getParentMode2D() const { return this->parentMode; };
     147
     148    void update2D (float dt);
     149
     150    void debug (unsigned int depth = 1, unsigned int level = 0) const;
     151    void debugDraw2D(unsigned int depth = 1, float size = 1.0, Vector color = Vector(1,1,1)) const;
     152
     153    // helper functions //
     154    static const char* parentingModeToChar(int parentingMode);
     155    static E2D_PARENT_MODE charToParentingMode(const char* parentingMode);
     156
     157  private:
     158    void init(Element2D* parent);
     159    /** tells the child that the parent's Coordinate has changed */
     160    inline void parentCoorChanged () { this->bRelCoorChanged = true; }
     161    /** tells the child that the parent's Direction has changed */
     162    inline void parentDirChanged () { this->bRelDirChanged = true; }
     163    /** @returns the last calculated coordinate */
     164    inline Vector getLastAbsCoor() { return this->lastAbsCoordinate; }
     165
     166  public:
    84167    virtual void tick(float dt);
    85168    virtual void draw() const = NULL;
     
    99182    bool                    active;           //!< If the given Element2D is active.
    100183    E2D_LAYER               layer;            //!< What layer this Element2D is on.
     184
     185
     186
     187
     188
     189  private:
     190    bool              bRelCoorChanged;    //!< If Relative Coordinate has changed since last time we checked
     191    bool              bRelDirChanged;     //!< If Relative Direction has changed since last time we checked
     192
     193    Vector            relCoordinate;      //!< coordinates relative to the parent
     194    Vector            absCoordinate;      //!< absolute coordinates in the world ( from (0,0,0) )
     195    float             relDirection;       //!< direction relative to the parent
     196    float             absDirection;       //!< absolute direvtion in the world ( from (0,0,1) )
     197
     198    Vector            prevRelCoordinate;  //!< The last Relative Coordinate from the last update-Cycle.
     199    Vector            lastAbsCoordinate;  //!< this is used for speedcalculation, it stores the last coordinate
     200    float             prevRelDirection;   //!< The last Relative Direciton from the last update-Cycle.
     201//  Quaternion        lastAbsDirection;
     202
     203    Vector            velocity;           //!< Saves the velocity.
     204
     205    Vector*           toCoordinate;       //!< a position to which to iterate. (This is used in conjunction with softReparent.and set*CoorSoft)
     206    float*            toDirection;        //!< a direction to which to iterate. (This is used in conjunction with softReparent and set*DirSoft)
     207    float             bias;               //!< how fast to iterate to the given position (default is 1)
     208
     209    Element2D*        parent;             //!< a pointer to the parent node
     210    tList<Element2D>* children;           //!< list of the children of this Element2D
     211
     212    unsigned int      parentMode;         //!< the mode of the binding
    101213};
    102214
Note: See TracChangeset for help on using the changeset viewer.