Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: zero-loop problem in pnode, dynamic pnode realocation. unstable, segfault when changing level.

File size: 3.4 KB
RevLine 
[3246]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
[3365]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...
[3246]18*/
19
20
21#ifndef _P_NODE_H
22#define _P_NODE_H
23
24#include "stdincl.h"
25
[3529]26
[3365]27class PNode; /* forward decleration, so that parentEntry has access to PNode */
[3246]28
[3450]29//! enumeration for the different translation-binding-types
[3365]30typedef enum parentingMode {MOVEMENT = 0, ROTATION, ALL};
[3450]31//! The default mode of the translation-binding.
[3365]32#define DEFAULT_MODE ALL
[3246]33
[3450]34//! Patent Node is a Engine to calculate the position of an Object in respect to the position of its parent.
[3365]35class PNode : public BaseObject {
36
[3246]37 public:
38  PNode ();
[3365]39  PNode (Vector* absCoordinate, PNode* pNode);
40  virtual ~PNode ();
[3246]41
[3365]42  void destroy ();
43
[3450]44  PNode* parent;            //!< a pointer to the parent node
45  tList<PNode>* children;   //!< list of the children
[3365]46
[3450]47  parentingMode mode;       //!< the mode of the binding
[3365]48
[3246]49  Vector getRelCoor ();
[3365]50  void setRelCoor (Vector* relCoord);
51  //void setRelCoor (Vector relCoord);
[3246]52  Vector getAbsCoor ();
[3365]53  void setAbsCoor (Vector* absCoord);
54  //void setAbsCoor (Vector absCoord);
55  void shiftCoor (Vector* shift);
56  //void shiftCoor (Vector shift);
[3246]57
58  Quaternion getRelDir ();
[3365]59  void setRelDir (Quaternion* relDir);
[3246]60  Quaternion getAbsDir ();
[3365]61  void setAbsDir (Quaternion* absDir);
62  void shiftDir (Quaternion* shift);
[3246]63
64  void addChild (PNode* pNode);
[3365]65  void addChild (PNode* pNode, parentingMode mode);
[3246]66  void removeChild (PNode* pNode);
[3521]67  //void setParent (PNode* parent);
[3365]68  void parentCoorChanged ();
69  void parentDirChanged ();
70  void setMode (parentingMode mode);
[3246]71
[3365]72  virtual void update (float timeStamp);
73  void processTick (float dt);
74  virtual void tick (float dt);
[3246]75
[3365]76  void setName (char* newName);
77  char* getName ();
78
79
80  void debug ();
81
[3521]82 protected:
[3529]83  PNode(char*);
84
[3450]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
[3365]91
[3450]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) )
[3246]96
97};
98
99#endif /* _P_NODE_H */
[3529]100 
Note: See TracBrowser for help on using the repository browser.