Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/levelloader/src/lib/coord/p_node.h @ 3605

Last change on this file since 3605 was 3605, checked in by bensch, 19 years ago

orxonox/trunk: merged trunk back to levelloader
merged with command:
svn merge -r 3499:HEAD trunk branches/levelloader

Conflicts in
C track_manager.h
C world_entities/player.cc
C world_entities/player.h
C world_entities/environment.h
C lib/coord/p_node.cc
C defs/debug.h
C track_manager.cc
C story_entities/campaign.h

solved in merge-favouring. It was quite easy because Chris only worked on the headers, and he didi it quite clean. Thats the spirit :)

Conflits in world.cc are a MESS: fix it

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