| [3246] | 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 |  | 
|---|
| [3365] | 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... | 
|---|
| [3246] | 18 | */ | 
|---|
 | 19 |  | 
|---|
 | 20 |  | 
|---|
 | 21 | #ifndef _P_NODE_H | 
|---|
 | 22 | #define _P_NODE_H | 
|---|
 | 23 |  | 
|---|
 | 24 | #include "stdincl.h" | 
|---|
 | 25 |  | 
|---|
| [3365] | 26 | class PNode; /* forward decleration, so that parentEntry has access to PNode */ | 
|---|
| [3246] | 27 |  | 
|---|
| [3365] | 28 | typedef enum parentingMode {MOVEMENT = 0, ROTATION, ALL}; | 
|---|
 | 29 | #define DEFAULT_MODE ALL | 
|---|
| [3246] | 30 |  | 
|---|
| [3365] | 31 | class PNode : public BaseObject { | 
|---|
 | 32 |  | 
|---|
| [3246] | 33 |  public: | 
|---|
 | 34 |   PNode (); | 
|---|
| [3365] | 35 |   PNode (Vector* absCoordinate, PNode* pNode); | 
|---|
 | 36 |   virtual ~PNode (); | 
|---|
| [3246] | 37 |  | 
|---|
| [3365] | 38 |   void destroy (); | 
|---|
 | 39 |  | 
|---|
 | 40 |   PNode* parent; //! a pointer to the parent node | 
|---|
 | 41 |   tList<PNode>* children; //! list of the children | 
|---|
 | 42 |  | 
|---|
 | 43 |   parentingMode mode; | 
|---|
 | 44 |  | 
|---|
| [3246] | 45 |   Vector getRelCoor (); | 
|---|
| [3365] | 46 |   void setRelCoor (Vector* relCoord); | 
|---|
 | 47 |   //void setRelCoor (Vector relCoord); | 
|---|
| [3246] | 48 |   Vector getAbsCoor (); | 
|---|
| [3365] | 49 |   void setAbsCoor (Vector* absCoord); | 
|---|
 | 50 |   //void setAbsCoor (Vector absCoord); | 
|---|
 | 51 |   void shiftCoor (Vector* shift); | 
|---|
 | 52 |   //void shiftCoor (Vector shift); | 
|---|
| [3246] | 53 |  | 
|---|
 | 54 |   Quaternion getRelDir (); | 
|---|
| [3365] | 55 |   void setRelDir (Quaternion* relDir); | 
|---|
| [3246] | 56 |   Quaternion getAbsDir (); | 
|---|
| [3365] | 57 |   void setAbsDir (Quaternion* absDir); | 
|---|
 | 58 |   void shiftDir (Quaternion* shift); | 
|---|
| [3246] | 59 |  | 
|---|
 | 60 |   void addChild (PNode* pNode); | 
|---|
| [3365] | 61 |   void addChild (PNode* pNode, parentingMode mode); | 
|---|
| [3246] | 62 |   void removeChild (PNode* pNode); | 
|---|
| [3365] | 63 |   void setParent (PNode* parent); | 
|---|
 | 64 |   void parentCoorChanged (); | 
|---|
 | 65 |   void parentDirChanged (); | 
|---|
 | 66 |   void setMode (parentingMode mode); | 
|---|
| [3246] | 67 |  | 
|---|
| [3365] | 68 |   virtual void update (float timeStamp); | 
|---|
 | 69 |   void processTick (float dt); | 
|---|
 | 70 |   virtual void tick (float dt); | 
|---|
| [3246] | 71 |  | 
|---|
| [3365] | 72 |   void setName (char* newName); | 
|---|
 | 73 |   char* getName (); | 
|---|
 | 74 |  | 
|---|
 | 75 |  | 
|---|
 | 76 |   void debug (); | 
|---|
 | 77 |  | 
|---|
 | 78 |   float timeStamp;   //! this the timeStamp of when the abs{Coordinat, Direction} has been calculated | 
|---|
 | 79 |   char* objectName; | 
|---|
 | 80 |   bool bAbsCoorChanged; | 
|---|
 | 81 |   bool bRelCoorChanged; | 
|---|
 | 82 |   bool bRelDirChanged; | 
|---|
 | 83 |   bool bAbsDirChanged; | 
|---|
 | 84 |  | 
|---|
| [3246] | 85 |   Vector relCoordinate;  //! coordinates relative to the parent | 
|---|
 | 86 |   Vector absCoordinate; //! absolute coordinates in the world ( from (0,0,0) ) | 
|---|
 | 87 |   Quaternion relDirection; //! direction relative to the parent | 
|---|
 | 88 |   Quaternion absDirection; //! absolute direvtion in the world ( from (0,0,1) ) | 
|---|
 | 89 |  | 
|---|
 | 90 | }; | 
|---|
 | 91 |  | 
|---|
 | 92 | #endif /* _P_NODE_H */ | 
|---|