/*! \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 */ //! enumeration for the different translation-binding-types typedef enum parentingMode {MOVEMENT = 0, ROTATION, ALL}; //! The default mode of the translation-binding. #define DEFAULT_MODE ALL //! Patent Node is a Engine to calculate the position of an Object in respect to the position of its parent. class PNode : public BaseObject { 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; //!< the mode of the binding Vector getRelCoor (); void setRelCoor (Vector* relCoord); //void setRelCoor (Vector relCoord); Vector getAbsCoor (); void setAbsCoor (Vector* absCoord); //void setAbsCoor (Vector absCoord); void shiftCoor (Vector* shift); //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 (float timeStamp); void processTick (float dt); virtual void tick (float dt); void setName (char* newName); char* getName (); void debug (); float timeStamp; //!< this the timeStamp of when the abs{Coordinat, Direction} has been calculated char* objectName; //!< The name of the Object bool bAbsCoorChanged; //!< If Absolute Coordinate has changed since last time we checked bool bRelCoorChanged; //!< If Relative Coordinate has changed since last time we checked bool bAbsDirChanged; //!< If Absolute Direction has changed since last time we checked bool bRelDirChanged; //!< If Relative Direction has changed since last time we checked 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 */