| 1 | /*!  | 
|---|
| 2 |     \file p_node.h | 
|---|
| 3 |     \brief Definition of a parenting node | 
|---|
| 4 |  | 
|---|
| 5 |     parenting is how coordinates are handled in orxonox, meaning, that all coordinates | 
|---|
| 6 |     are representet relative to another parent node. this nodes build a parenting | 
|---|
| 7 |     tree of one-sided references (from up to down referenced). | 
|---|
| 8 |     Every node manages itself a list of childrens (of whos it is parent - easy...) | 
|---|
| 9 |  | 
|---|
| 10 |     absCoordinate, absDirection have to be recalculated as soon as there was a change in | 
|---|
| 11 |     place or ortientation. this is only the case if  | 
|---|
| 12 |     o bDirChanged is true (so changed) AND timeStamp != now | 
|---|
| 13 |     o bCoorChanged is true (so moved) AND timeStamp != now | 
|---|
| 14 |     this conditions make it cheaper to recalculate the tree (reduces redundant work). | 
|---|
| 15 |  | 
|---|
| 16 |     remember: if you have to change the coordinates or the directions, use the functions | 
|---|
| 17 |     that are defined to execute this operation - otherwhise there will be big problems... | 
|---|
| 18 | */ | 
|---|
| 19 |  | 
|---|
| 20 |  | 
|---|
| 21 | #ifndef _P_NODE_H | 
|---|
| 22 | #define _P_NODE_H | 
|---|
| 23 |  | 
|---|
| 24 | #include "stdincl.h" | 
|---|
| 25 |  | 
|---|
| 26 | class PNode; /* forward decleration, so that parentEntry has access to PNode */ | 
|---|
| 27 |  | 
|---|
| 28 | //! enumeration for the different translation-binding-types | 
|---|
| 29 | typedef enum parentingMode {MOVEMENT = 0, ROTATION, ALL}; | 
|---|
| 30 | //! The default mode of the translation-binding. | 
|---|
| 31 | #define DEFAULT_MODE ALL | 
|---|
| 32 |  | 
|---|
| 33 | //! Patent Node is a Engine to calculate the position of an Object in respect to the position of its parent. | 
|---|
| 34 | class PNode : public BaseObject { | 
|---|
| 35 |  | 
|---|
| 36 |  public: | 
|---|
| 37 |   PNode (); | 
|---|
| 38 |   PNode (Vector* absCoordinate, PNode* pNode); | 
|---|
| 39 |   virtual ~PNode (); | 
|---|
| 40 |  | 
|---|
| 41 |   void destroy (); | 
|---|
| 42 |  | 
|---|
| 43 |   PNode* parent;            //!< a pointer to the parent node | 
|---|
| 44 |   tList<PNode>* children;   //!< list of the children | 
|---|
| 45 |  | 
|---|
| 46 |   parentingMode mode;       //!< the mode of the binding | 
|---|
| 47 |  | 
|---|
| 48 |   Vector getRelCoor (); | 
|---|
| 49 |   void setRelCoor (Vector* relCoord); | 
|---|
| 50 |   //void setRelCoor (Vector relCoord); | 
|---|
| 51 |   Vector getAbsCoor (); | 
|---|
| 52 |   void setAbsCoor (Vector* absCoord); | 
|---|
| 53 |   //void setAbsCoor (Vector absCoord); | 
|---|
| 54 |   void shiftCoor (Vector* shift); | 
|---|
| 55 |   //void shiftCoor (Vector shift); | 
|---|
| 56 |  | 
|---|
| 57 |   Quaternion getRelDir (); | 
|---|
| 58 |   void setRelDir (Quaternion* relDir); | 
|---|
| 59 |   Quaternion getAbsDir (); | 
|---|
| 60 |   void setAbsDir (Quaternion* absDir); | 
|---|
| 61 |   void shiftDir (Quaternion* shift); | 
|---|
| 62 |  | 
|---|
| 63 |   void addChild (PNode* pNode); | 
|---|
| 64 |   void addChild (PNode* pNode, parentingMode mode); | 
|---|
| 65 |   void removeChild (PNode* pNode); | 
|---|
| 66 |   void setParent (PNode* parent); | 
|---|
| 67 |   void parentCoorChanged (); | 
|---|
| 68 |   void parentDirChanged (); | 
|---|
| 69 |   void setMode (parentingMode mode); | 
|---|
| 70 |  | 
|---|
| 71 |   virtual void update (float timeStamp); | 
|---|
| 72 |   void processTick (float dt); | 
|---|
| 73 |   virtual void tick (float dt); | 
|---|
| 74 |  | 
|---|
| 75 |   void setName (char* newName); | 
|---|
| 76 |   char* getName (); | 
|---|
| 77 |  | 
|---|
| 78 |  | 
|---|
| 79 |   void debug (); | 
|---|
| 80 |  | 
|---|
| 81 |   float timeStamp;         //!< this the timeStamp of when the abs{Coordinat, Direction} has been calculated | 
|---|
| 82 |   char* objectName;        //!< The name of the Object | 
|---|
| 83 |   bool bAbsCoorChanged;    //!< If Absolute Coordinate has changed since last time we checked | 
|---|
| 84 |   bool bRelCoorChanged;    //!< If Relative Coordinate has changed since last time we checked | 
|---|
| 85 |   bool bAbsDirChanged;     //!< If Absolute Direction has changed since last time we checked | 
|---|
| 86 |   bool bRelDirChanged;     //!< If Relative Direction has changed since last time we checked | 
|---|
| 87 |  | 
|---|
| 88 |   Vector relCoordinate;    //!< coordinates relative to the parent | 
|---|
| 89 |   Vector absCoordinate;    //!< absolute coordinates in the world ( from (0,0,0) ) | 
|---|
| 90 |   Quaternion relDirection; //!< direction relative to the parent | 
|---|
| 91 |   Quaternion absDirection; //!< absolute direvtion in the world ( from (0,0,1) ) | 
|---|
| 92 |  | 
|---|
| 93 | }; | 
|---|
| 94 |  | 
|---|
| 95 | #endif /* _P_NODE_H */ | 
|---|