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 | typedef enum parentingMode {MOVEMENT = 0, ROTATION, ALL}; |
---|
29 | #define DEFAULT_MODE ALL |
---|
30 | |
---|
31 | class PNode { |
---|
32 | |
---|
33 | public: |
---|
34 | PNode (); |
---|
35 | ~PNode (); |
---|
36 | |
---|
37 | parentingMode mode; |
---|
38 | |
---|
39 | Vector getRelCoor (); |
---|
40 | void setRelCoor (Vector relCoord); |
---|
41 | Vector getAbsCoor (); |
---|
42 | void setAbsCoor (Vector absCoord); |
---|
43 | void shiftCoor (Vector shift); |
---|
44 | |
---|
45 | Quaternion getRelDir (); |
---|
46 | void setRelDir (Quaternion relDir); |
---|
47 | Quaternion getAbsDir (); |
---|
48 | void setAbsDir (Quaternion absDir); |
---|
49 | void shiftDir (Quaternion shift); |
---|
50 | |
---|
51 | void addChild (PNode* pNode); |
---|
52 | void addChild (PNode* pNode, parentingMode mode); |
---|
53 | void removeChild (PNode* pNode); |
---|
54 | void setParent (PNode* parent); |
---|
55 | void update (long timeStamp); |
---|
56 | |
---|
57 | private: |
---|
58 | long timeStamp; //! this the timeStamp of when the abs{Coordinat, Direction} has been calculated |
---|
59 | bool bCoorChanged; |
---|
60 | bool bDirChanged; |
---|
61 | |
---|
62 | Vector relCoordinate; //! coordinates relative to the parent |
---|
63 | Vector absCoordinate; //! absolute coordinates in the world ( from (0,0,0) ) |
---|
64 | Quaternion relDirection; //! direction relative to the parent |
---|
65 | Quaternion absDirection; //! absolute direvtion in the world ( from (0,0,1) ) |
---|
66 | |
---|
67 | PNode* parent; |
---|
68 | tList<PNode>* children; //! list of the children |
---|
69 | |
---|
70 | }; |
---|
71 | |
---|
72 | #endif /* _P_NODE_H */ |
---|