Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 3542 was 3537, checked in by patrick, 20 years ago

orxonox/trank: worked on removing alg. from pnode and changed a little on camera for the new tackmanager

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
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 (float timeStamp);
77  void processTick (float dt);
78  virtual void tick (float dt);
79
80  void setName (char* newName);
81  char* getName ();
82
83
84  void debug ();
85
86 protected:
87  PNode(char*);
88
89  float timeStamp;         //!< this the timeStamp of when the abs{Coordinat, Direction} has been calculated
90  char* objectName;        //!< The name of the Object
91  bool bAbsCoorChanged;    //!< If Absolute Coordinate has changed since last time we checked
92  bool bRelCoorChanged;    //!< If Relative Coordinate has changed since last time we checked
93  bool bAbsDirChanged;     //!< If Absolute Direction has changed since last time we checked
94  bool bRelDirChanged;     //!< If Relative Direction has changed since last time we checked
95
96  Vector relCoordinate;    //!< coordinates relative to the parent
97  Vector absCoordinate;    //!< absolute coordinates in the world ( from (0,0,0) )
98  Quaternion relDirection; //!< direction relative to the parent
99  Quaternion absDirection; //!< absolute direvtion in the world ( from (0,0,1) )
100
101  parentingMode mode;       //!< the mode of the binding
102
103};
104
105#endif /* _P_NODE_H */
106 
Note: See TracBrowser for help on using the repository browser.