Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 3689 was 3683, checked in by patrick, 20 years ago

orxonox/trunk: projectile speed issue: fixed some strange behaveour. still got the problem, that the the projectile have variable relative speeds to the player…

File size: 4.5 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//#include "vector.h"
26
27// FORWARD DEFINITION \\
28class PNode; /* forward decleration, so that parentEntry has access to PNode */
29class Quaternion;
30class Vector;
31template<class T> class tList;
32
33//! enumeration for the different translation-binding-types
34//typedef enum parentingMode {PNODE_LOCAL_ROTATE, PNODE_ROTATE_MOVEMENT, PNODE_ALL, PNODE_MOVEMENT, PNODE_ROTATE_AND_MOVE};
35// linkage modes
36#define PNODE_LOCAL_ROTATE       1    //!< Rotates all the children around their centers.
37#define PNODE_ROTATE_MOVEMENT    2    //!< Moves all the children around the center of their parent, without the rotation around their own centers.
38#define PNODE_MOVEMENT           4    //!< Moves all children along with the parent.
39// special linkage modes
40#define PNODE_ALL                3    //!< Moves all children around the center of their parent, and also rotates their centers
41#define PNODE_ROTATE_AND_MOVE    5    //!< Rotates all children around their axis, and moves them as the Parent Moves, but does not rotate around the center of their parent.
42
43//! The default mode of the translation-binding.
44#define DEFAULT_MODE PNODE_ALL
45
46//! Patent Node is a Engine to calculate the position of an Object in respect to the position of its parent.
47class PNode : public BaseObject {
48
49 public:
50  PNode ();
51  PNode (Vector* absCoordinate, PNode* pNode);
52  virtual ~PNode ();
53
54  PNode* parent;            //!< a pointer to the parent node
55  tList<PNode>* children;   //!< list of the children
56
57
58
59  Vector* getRelCoor ();
60  void setRelCoor (Vector* relCoord);
61  void setRelCoor (Vector relCoord);
62  Vector getAbsCoor ();
63  void setAbsCoor (Vector* absCoord);
64  void setAbsCoor (Vector absCoord);
65  void shiftCoor (Vector* shift);
66  void shiftCoor (Vector shift);
67  //void shiftCoor (Vector shift);
68
69  Quaternion getRelDir ();
70  void setRelDir (Quaternion* relDir);
71  void setRelDir (Quaternion relDir);
72  Quaternion getAbsDir ();
73  void setAbsDir (Quaternion* absDir);
74  void setAbsDir (Quaternion absDir);
75  void shiftDir (Quaternion* shift);
76  void shiftDir (Quaternion shift);
77
78  float getSpeed();
79
80  void addChild (PNode* pNode);
81  void addChild (PNode* pNode, int parentingMode);
82  void removeChild (PNode* pNode);
83  void remove();
84
85
86  void setParent (PNode* parent);
87  void parentCoorChanged ();
88  void parentDirChanged ();
89  void setMode (int parentingMode);
90  int getMode();
91
92  virtual void update (float dt);
93  void processTick (float dt);
94
95  void setName (char* newName);
96  char* getName ();
97
98
99  void debug ();
100
101 protected:
102  float timeStamp;         //!< this the timeStamp of when the abs{Coordinat, Direction} has been calculated
103  char* objectName;        //!< The name of the Object
104  bool bAbsCoorChanged;    //!< If Absolute Coordinate has changed since last time we checked
105  bool bRelCoorChanged;    //!< If Relative Coordinate has changed since last time we checked
106  bool bAbsDirChanged;     //!< If Absolute Direction has changed since last time we checked
107  bool bRelDirChanged;     //!< If Relative Direction has changed since last time we checked
108
109  Vector* relCoordinate;    //!< coordinates relative to the parent
110  Vector* absCoordinate;    //!< absolute coordinates in the world ( from (0,0,0) )
111  Quaternion* relDirection; //!< direction relative to the parent
112  Quaternion* absDirection; //!< absolute direvtion in the world ( from (0,0,1) )
113
114  int mode;                //!< the mode of the binding
115
116 private:
117  void init(PNode* parent);
118
119  Vector* lastAbsCoordinate; //!< this is used for speedcalculation, it stores the last coordinate
120  float time;                //!< time since last update
121};
122
123#endif /* _P_NODE_H */
124 
Note: See TracBrowser for help on using the repository browser.