Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/lib/coord/p_node.h @ 3551

Last change on this file since 3551 was 3551, checked in by patrick, 19 years ago

orxonox/trunk: renamed all timing functions to tick() - cleanede up world

File size: 3.4 KB
Line 
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 "base_object.h"
25
26// FORWARD DEFINITION \\
27class PNode; /* forward decleration, so that parentEntry has access to PNode */
28class Quaternion;
29class Vector;
30
31//! enumeration for the different translation-binding-types
32typedef enum parentingMode {MOVEMENT = 0, ROTATION, ALL};
33//! The default mode of the translation-binding.
34#define DEFAULT_MODE ALL
35
36//! Patent Node is a Engine to calculate the position of an Object in respect to the position of its parent.
37class PNode : public BaseObject {
38
39 public:
40  PNode ();
41  PNode (Vector* absCoordinate, PNode* pNode);
42  virtual ~PNode ();
43
44  PNode* parent;            //!< a pointer to the parent node
45  tList<PNode>* children;   //!< list of the children
46
47
48
49  Vector getRelCoor ();
50  void setRelCoor (Vector* relCoord);
51  //void setRelCoor (Vector relCoord);
52  Vector getAbsCoor ();
53  void setAbsCoor (Vector* absCoord);
54  //void setAbsCoor (Vector absCoord);
55  void shiftCoor (Vector* shift);
56  //void shiftCoor (Vector shift);
57
58  Quaternion getRelDir ();
59  void setRelDir (Quaternion* relDir);
60  Quaternion getAbsDir ();
61  void setAbsDir (Quaternion* absDir);
62  void shiftDir (Quaternion* shift);
63
64  void addChild (PNode* pNode);
65  void addChild (PNode* pNode, parentingMode mode);
66  void removeChild (PNode* pNode);
67  void remove();
68
69
70  void setParent (PNode* parent);
71  void parentCoorChanged ();
72  void parentDirChanged ();
73  void setMode (parentingMode mode);
74  parentingMode getMode();
75
76  virtual void update ();
77  void processTick (float dt);
78
79  void setName (char* newName);
80  char* getName ();
81
82
83  void debug ();
84
85 protected:
86  PNode(char*);
87
88  float timeStamp;         //!< this the timeStamp of when the abs{Coordinat, Direction} has been calculated
89  char* objectName;        //!< The name of the Object
90  bool bAbsCoorChanged;    //!< If Absolute Coordinate has changed since last time we checked
91  bool bRelCoorChanged;    //!< If Relative Coordinate has changed since last time we checked
92  bool bAbsDirChanged;     //!< If Absolute Direction has changed since last time we checked
93  bool bRelDirChanged;     //!< If Relative Direction has changed since last time we checked
94
95  Vector relCoordinate;    //!< coordinates relative to the parent
96  Vector absCoordinate;    //!< absolute coordinates in the world ( from (0,0,0) )
97  Quaternion relDirection; //!< direction relative to the parent
98  Quaternion absDirection; //!< absolute direvtion in the world ( from (0,0,1) )
99
100  parentingMode mode;       //!< the mode of the binding
101
102};
103
104#endif /* _P_NODE_H */
105 
Note: See TracBrowser for help on using the repository browser.