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, because the object (point) did move, |
---|
17 | don't forget to reset both relCoor and absCoor (offset is the same) |
---|
18 | */ |
---|
19 | |
---|
20 | |
---|
21 | #ifndef _P_NODE_H |
---|
22 | #define _P_NODE_H |
---|
23 | |
---|
24 | #include "stdincl.h" |
---|
25 | |
---|
26 | |
---|
27 | class PNode { |
---|
28 | |
---|
29 | public: |
---|
30 | PNode (); |
---|
31 | ~PNode (); |
---|
32 | |
---|
33 | Vector getRelCoor (); |
---|
34 | void setRelCoor (Vector relCoord); |
---|
35 | Vector getAbsCoor (); |
---|
36 | void setAbsCoor (Vector absCoord); |
---|
37 | |
---|
38 | Quaternion getRelDir (); |
---|
39 | void setRelDir (Quaternion relDir); |
---|
40 | Quaternion getAbsDir (); |
---|
41 | void setAbsCoor (Quaternion absDir); |
---|
42 | |
---|
43 | void addChild (PNode* pNode); |
---|
44 | void removeChild (PNode* pNode); |
---|
45 | |
---|
46 | private: |
---|
47 | long timeStamp; //! this the timeStamp of when the abs{Coordinat, Direction} has been calculated |
---|
48 | bool bCoorChanged; |
---|
49 | bool bDirChanged; |
---|
50 | |
---|
51 | Vector relCoordinate; //! coordinates relative to the parent |
---|
52 | Vector absCoordinate; //! absolute coordinates in the world ( from (0,0,0) ) |
---|
53 | Quaternion relDirection; //! direction relative to the parent |
---|
54 | Quaternion absDirection; //! absolute direvtion in the world ( from (0,0,1) ) |
---|
55 | |
---|
56 | tList<PNode>* children; //! list of the children |
---|
57 | |
---|
58 | }; |
---|
59 | |
---|
60 | #endif /* _P_NODE_H */ |
---|