/*! \file p_node.h \brief Definition of a parenting node parenting is how coordinates are handled in orxonox, meaning, that all coordinates are representet relative to another parent node. this nodes build a parenting tree of one-sided references (from up to down referenced). Every node manages itself a list of childrens (of whos it is parent - easy...) absCoordinate, absDirection have to be recalculated as soon as there was a change in place or ortientation. this is only the case if o bDirChanged is true (so changed) AND timeStamp != now o bCoorChanged is true (so moved) AND timeStamp != now this conditions make it cheaper to recalculate the tree (reduces redundant work). remember: if you have to change the coordinates or the directions, use the functions that are defined to execute this operation - otherwhise there will be big problems... */ #ifndef _P_NODE_H #define _P_NODE_H #include "stdincl.h" class PNode; /* forward decleration, so that parentEntry has access to PNode */ typedef enum parentingMode {MOVEMENT = 0, ROTATION, ALL}; #define DEFAULT_MODE ALL class PNode { public: PNode (); PNode (Vector* absCoordinate, PNode* pNode); virtual ~PNode (); void destroy (); PNode* parent; //! a pointer to the parent node tList* children; //! list of the children parentingMode mode; Vector getRelCoor (); void setRelCoor (Vector* relCoord); Vector getAbsCoor (); void setAbsCoor (Vector* absCoord); void shiftCoor (Vector* shift); Quaternion getRelDir (); void setRelDir (Quaternion* relDir); Quaternion getAbsDir (); void setAbsDir (Quaternion* absDir); void shiftDir (Quaternion* shift); void addChild (PNode* pNode); void addChild (PNode* pNode, parentingMode mode); void removeChild (PNode* pNode); void setParent (PNode* parent); void parentCoorChanged (); void parentDirChanged (); void setMode (parentingMode mode); virtual void update (long timeStamp); void debug (); long timeStamp; //! this the timeStamp of when the abs{Coordinat, Direction} has been calculated bool bAbsCoorChanged; bool bRelCoorChanged; bool bRelDirChanged; bool bAbsDirChanged; Vector relCoordinate; //! coordinates relative to the parent Vector absCoordinate; //! absolute coordinates in the world ( from (0,0,0) ) Quaternion relDirection; //! direction relative to the parent Quaternion absDirection; //! absolute direvtion in the world ( from (0,0,1) ) }; #endif /* _P_NODE_H */