Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 3536 was 3535, checked in by bensch, 20 years ago

orxonox/trunk: player connected to the track.
There is some strange error about this, that I do not quite understand.

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 "stdincl.h"
25
26
27class PNode; /* forward decleration, so that parentEntry has access to PNode */
28
29//! enumeration for the different translation-binding-types
30typedef enum parentingMode {MOVEMENT = 0, ROTATION, ALL};
31//! The default mode of the translation-binding.
32#define DEFAULT_MODE ALL
33
34//! Patent Node is a Engine to calculate the position of an Object in respect to the position of its parent.
35class PNode : public BaseObject {
36
37 public:
38  PNode ();
39  PNode (Vector* absCoordinate, PNode* pNode);
40  virtual ~PNode ();
41
42  void destroy ();
43
44  PNode* parent;            //!< a pointer to the parent node
45  tList<PNode>* children;   //!< list of the children
46
47  parentingMode mode;       //!< the mode of the binding
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 setParent (PNode* parent);
68  void parentCoorChanged ();
69  void parentDirChanged ();
70  void setMode (parentingMode mode);
71
72  virtual void update (float timeStamp);
73  void processTick (float dt);
74  virtual void tick (float dt);
75
76  void setName (char* newName);
77  char* getName ();
78
79
80  void debug ();
81
82 protected:
83  PNode(char*);
84
85  float timeStamp;         //!< this the timeStamp of when the abs{Coordinat, Direction} has been calculated
86  char* objectName;        //!< The name of the Object
87  bool bAbsCoorChanged;    //!< If Absolute Coordinate has changed since last time we checked
88  bool bRelCoorChanged;    //!< If Relative Coordinate has changed since last time we checked
89  bool bAbsDirChanged;     //!< If Absolute Direction has changed since last time we checked
90  bool bRelDirChanged;     //!< If Relative Direction has changed since last time we checked
91
92  Vector relCoordinate;    //!< coordinates relative to the parent
93  Vector absCoordinate;    //!< absolute coordinates in the world ( from (0,0,0) )
94  Quaternion relDirection; //!< direction relative to the parent
95  Quaternion absDirection; //!< absolute direvtion in the world ( from (0,0,1) )
96
97};
98
99#endif /* _P_NODE_H */
100 
Note: See TracBrowser for help on using the repository browser.