Index: orxonox/branches/parenting/src/p_node.cc
===================================================================
--- orxonox/branches/parenting/src/p_node.cc	(revision 3264)
+++ orxonox/branches/parenting/src/p_node.cc	(revision 3265)
@@ -14,4 +14,7 @@
    main-programmer: Patrick Boenzli
    co-programmer: ...
+
+   \todo Null-Parent => center of the coord system - singleton
+   \todo Smooth-Parent: delay, speed
 */
 
@@ -31,6 +34,29 @@
 {
   this->children = new tList<PNode>();
-  this->bCoorChanged = true;
-  this->bDirChanged = true;
+  this->bRelCoorChanged = true;
+  this->bAbsCoorChanged = false;
+  this->bRelDirChanged = true;
+  this->bAbsDirChanged = false;
+  this->parent = NULL;
+}
+
+
+/**
+   \brief constructor with coodinates
+*/
+PNode::PNode (Vector* absCoordinate, PNode* parent )
+{
+  this->absCoordinate = *absCoordinate;
+  this->relCoordinate = this->absCoordinate - this->parent->getAbsCoor ();
+  
+  
+  this->children = new tList<PNode>();
+  this->bRelCoorChanged = false;
+  this->bAbsCoorChanged = true;
+  this->bRelDirChanged = true;
+  this->bAbsDirChanged = false;
+  this->parent = parent;
+
+  parent->addChild (this);
 }
 
@@ -68,5 +94,8 @@
 */
 void PNode::setRelCoor (Vector relCoord)
-{}
+{
+  this->bRelCoorChanged = true;
+  this->relCoordinate = relCoord;
+}
 
 
@@ -76,5 +105,7 @@
 */
 Vector PNode::getAbsCoor ()
-{}
+{
+  return this->absCoordinate;
+}
 
 
@@ -88,5 +119,8 @@
 */
 void PNode::setAbsCoor (Vector absCoord)
-{}
+{
+  this->bAbsCoorChanged = true;
+  this->absCoordinate = absCoord;
+}
 
 
@@ -111,6 +145,21 @@
 
 */
-void PNode::shiftCoor (Vector shift)
-{}
+void PNode::shiftCoor (Vector* shift)
+{
+  if( this->bAbsCoorChanged)
+    {
+      this->absCoordinate = this->absCoordinate + *shift;
+    }
+  else 
+    {
+      this->relCoordinate = this->relCoordinate + *shift;
+      this->bRelCoorChanged = true;
+    }
+
+  printf("PNode::shiftCoor() - relCoord: (%f, %f, %f)\n", 
+	 this->relCoordinate.x, 
+	 this->relCoordinate.y,
+	 this->relCoordinate.z);
+}
 
 
@@ -121,5 +170,7 @@
 */
 Quaternion PNode::getRelDir ()
-{}
+{
+  return this->relDirection;
+}
 
 
@@ -133,5 +184,8 @@
 */
 void PNode::setRelDir (Quaternion relDir)
-{}
+{
+  this->bRelCoorChanged = true;
+  this->relDirection = relDir;
+}
 
 
@@ -176,5 +230,5 @@
 
 */
-void PNode::shiftDir (Quaternion shift)
+void PNode::shiftDir (Quaternion* shift)
 {}
 
@@ -203,4 +257,5 @@
 {
   pNode->mode = mode;
+  pNode->parent = this;
   this->children->add (pNode);
 }
@@ -222,4 +277,35 @@
 {
   this->parent = parent;
+}
+
+/**
+   \brief set the mode of this parent manualy
+*/
+void PNode::setMode (parentingMode mode)
+{
+  this->mode = mode;
+}
+
+/**
+   \brief has to be called, if the parent coordinate has changed
+   
+   normaly this will be done by the parent itself automaticaly. If you call this, you
+   will force an update of the coordinated of the node.
+*/
+void PNode::parentCoorChanged ()
+{
+  this->bRelCoorChanged = true;
+}
+
+
+/**
+   \brief has to be called, if the parent direction has changed
+   
+   normaly this will be done by the parent itself automaticaly. If you call this, you
+   will force an update of the direction of the node.
+*/
+void PNode::parentDirChanged ()
+{
+  this->bRelDirChanged = true;
 }
 
@@ -232,22 +318,68 @@
    worry, normaly...
 */
-void PNode::update(long timeStamp)
-{
-  if(this->parent == NULL)
-    printf("PNode::upate(long timeStamp) - parent is NULL...");
-  if( this->bCoorChanged && this->timeStamp != DataTank::timeStamp)
-    {
-      /* update the current absCoordinate */
-      this->absCoordinate = parent->getAbsCoor () + this->relCoordinate;
-    }
-  if( this->bDirChanged && this->timeStamp != DataTank::timeStamp)
-    {
-      /* update the current absDirection - remember * means rotation around sth.*/
-      this->absDirection = parent->getAbsDir () * this->relDirection;
-    }
-  
+void PNode::update (long timeStamp)
+{
+  printf("PNode::update() \n");
+  //if( this->parent != NULL)
+  //    {
+      
+      if( this->mode == MOVEMENT || this->mode == ALL)
+	{
+	  if( this->bAbsCoorChanged /*&& this->timeStamp != DataTank::timeStamp*/)
+	    {
+	      /* if you have set the absolute coordinates this overrides all other changes */
+	      this->relCoordinate = this->absCoordinate - parent->getAbsCoor ();
+	    }
+	  else if( this->bRelCoorChanged /*&& this->timeStamp != DataTank::timeStamp*/)
+	    {
+ printf("PNode::update() - inside: before: absCoord: (%f, %f, %f)\n", 
+	 this->absCoordinate.x, 
+	 this->absCoordinate.y,
+	 this->absCoordinate.z);
+printf("PNode::update() - inside: before: relCoord: (%f, %f, %f)\n", 
+	 this->relCoordinate.x, 
+	 this->relCoordinate.y,
+	 this->relCoordinate.z);
+	      /*this is bad style... must be deleted later - just for testing*/
+	      if( this->parent == NULL)
+		{
+		this->absCoordinate = this->relCoordinate;
+		printf("PNode::update() - insinde: NULL NULL NULL\n");
+		}
+	      else
+		this->absCoordinate = parent->getAbsCoor () + this->relCoordinate;	      /* update the current absCoordinate */
+ printf("PNode::update() - inside after: absCoord: (%f, %f, %f)\n", 
+	 this->absCoordinate.x, 
+	 this->absCoordinate.y,
+	 this->absCoordinate.z);
+printf("PNode::update() - inside after: relCoord: (%f, %f, %f)\n", 
+	 this->relCoordinate.x, 
+	 this->relCoordinate.y,
+	 this->relCoordinate.z);
+	    }
+	}
+      
+      if( this->mode == ROTATION && this->mode == ALL)
+	{
+	  if( this->bAbsDirChanged /*&& this->timeStamp != DataTank::timeStamp*/)
+	    {
+	      /* if you have set the absolute coordinates this overrides all other changes */
+	      this->relDirection = this->absDirection - parent->getAbsDir ();
+	    }
+	  else if( this->bRelDirChanged /*&& this->timeStamp != DataTank::timeStamp*/)
+	    {
+	      /* update the current absDirection - remember * means rotation around sth.*/
+	      this->absDirection = parent->getAbsDir () * this->relDirection;
+	    }
+	}    
+      // }
   PNode* pn = this->children->enumerate();
   while( pn != NULL) 
     { 
+      /* if this node has changed, make sure, that all children are updated also */
+      if( this->bRelCoorChanged || this->bAbsCoorChanged)
+	pn->parentCoorChanged ();
+      if( this->bRelDirChanged || this->bAbsDirChanged)
+	pn->parentDirChanged ();
       pn->update(timeStamp);
       pn = this->children->nextElement();
@@ -255,7 +387,16 @@
 
   this->timeStamp = timeStamp;
-  this->bCoorChanged = false;
-  this->bDirChanged = false;
-
-}
-
+  this->bRelCoorChanged = false;
+  this->bAbsCoorChanged = false;
+  this->bRelDirChanged = false;
+  this->bAbsDirChanged = false;
+}
+
+
+void PNode::debug()
+{
+  printf("PNode::debug() - absCoord: (%f, %f, %f)\n", 
+	 this->absCoordinate.x, 
+	 this->absCoordinate.y,
+	 this->absCoordinate.z);
+}
Index: orxonox/branches/parenting/src/p_node.h
===================================================================
--- orxonox/branches/parenting/src/p_node.h	(revision 3264)
+++ orxonox/branches/parenting/src/p_node.h	(revision 3265)
@@ -33,5 +33,9 @@
  public:
   PNode ();
+  PNode (Vector* absCoordinate, PNode* pNode);
   ~PNode ();
+
+  PNode* parent; //! a pointer to the parent node
+  tList<PNode>* children; //! list of the children
 
   parentingMode mode;
@@ -41,5 +45,5 @@
   Vector getAbsCoor ();
   void setAbsCoor (Vector absCoord);
-  void shiftCoor (Vector shift);
+  void shiftCoor (Vector* shift);
 
   Quaternion getRelDir ();
@@ -47,5 +51,5 @@
   Quaternion getAbsDir ();
   void setAbsDir (Quaternion absDir);
-  void shiftDir (Quaternion shift);
+  void shiftDir (Quaternion* shift);
 
   void addChild (PNode* pNode);
@@ -53,10 +57,17 @@
   void removeChild (PNode* pNode);
   void setParent (PNode* parent);
-  void update (long timeStamp);
+  void parentCoorChanged ();
+  void parentDirChanged ();
+  void setMode (parentingMode mode);
+  virtual void update (long timeStamp);
+
+  void debug ();
 
  private:
-  long timeStamp; //! this the timeStamp of when the abs{Coordinat, Direction} has been calculated
-  bool bCoorChanged;
-  bool bDirChanged;
+  long timeStamp;   //! this the timeStamp of when the abs{Coordinat, Direction} has been calculated
+  bool bAbsCoorChanged;
+  bool bRelCoorChanged;
+  bool bRelDirChanged;
+  bool bAbsDirChanged;
 
   Vector relCoordinate;  //! coordinates relative to the parent
@@ -65,7 +76,4 @@
   Quaternion absDirection; //! absolute direvtion in the world ( from (0,0,1) )
 
-  PNode* parent;
-  tList<PNode>* children; //! list of the children
-
 };
 
Index: orxonox/branches/parenting/src/world.cc
===================================================================
--- orxonox/branches/parenting/src/world.cc	(revision 3264)
+++ orxonox/branches/parenting/src/world.cc	(revision 3265)
@@ -23,4 +23,5 @@
 #include "camera.h"
 #include "environment.h"
+#include "p_node.h"
 
 using namespace std;
@@ -78,4 +79,7 @@
   cn->addToWorld(this);
   cn->enable(true);
+
+  /* this is only for test purposes */
+  this->debug ();
 }
 
@@ -571,7 +575,40 @@
 void World::debug()
 {
-  //List<WorldEntity> *l;
+  printf("World::debug() - starting debug\n");
+  PNode* p1 = new PNode ();
+  PNode* p2 = new PNode (new Vector(2, 2, 2), p1);
+  PNode* p3 = new PNode (new Vector(4, 4, 4), p1);
+  PNode* p4 = new PNode (new Vector(6, 6, 6), p2);
+
+  p1->setMode (ALL);
+
+  //p1->addChild (p2);
+  // p1->addChild (p3);
+  //p2->addChild (p4);
+
+  p1->debug ();
+  p2->debug ();
+  p3->debug ();
+  p4->debug ();
+
+  p1->shiftCoor (new Vector(-1, -1, -1));
+
+  printf("World::debug() - shift\n");
+  p1->debug ();
+  p2->debug ();
+  p3->debug ();
+  p4->debug ();
+  
+  p1->update (1);
+
+  printf("World::debug() - update\n");
+  p1->debug ();
+  p2->debug ();
+  p3->debug ();
+  p4->debug ();
+
+
+  /*
   WorldEntity* entity;
-  
   printf("counting all entities\n");
   printf("World::debug() - enumerate()\n");
@@ -582,4 +619,5 @@
       entity = entities->nextElement();
     }
+  */
 }
 
@@ -800,2 +838,3 @@
   return false;
 }
+
