Changeset 5081 in orxonox.OLD for trunk/src/lib/graphics/render2D/element_2d.h
- Timestamp:
- Aug 19, 2005, 12:49:21 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/graphics/render2D/element_2d.h
r5068 r5081 1 1 /*! 2 2 * @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. 4 5 */ 5 6 … … 8 9 9 10 #include "base_object.h" 11 #include "vector.h" 10 12 11 13 // FORWARD DECLARATION 12 14 class PNode; 13 15 class TiXmlElement; 16 template<class T> class tList; 14 17 15 18 //!< An enumerator defining the Depth of a 2D-element. … … 35 38 } E2D_ALIGNMENT; 36 39 40 typedef 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 37 52 //! A Struct defining the Position of an Element in 2D-space 38 53 struct Position2D … … 82 97 inline bool isActive() { return this->active; }; 83 98 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: 84 167 virtual void tick(float dt); 85 168 virtual void draw() const = NULL; … … 99 182 bool active; //!< If the given Element2D is active. 100 183 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 101 213 }; 102 214
Note: See TracChangeset
for help on using the changeset viewer.