Index: trunk/src/lib/coord/p_node.cc
===================================================================
--- trunk/src/lib/coord/p_node.cc	(revision 6624)
+++ trunk/src/lib/coord/p_node.cc	(revision 6634)
@@ -505,6 +505,10 @@
 {
   PNode* childNode = dynamic_cast<PNode*>(ClassList::getObject(childName, CL_PARENT_NODE));
+//  PRINTF(0)("Adding the Child: %s to: %s\n", childName, this->getName());
+//  assert( childNode != NULL );
   if (childNode != NULL)
+  {
     this->addChild(childNode);
+  }
 }
 
@@ -1069,10 +1073,5 @@
   SYNCHELP_READ_FLOAT( f3 );
   this->setRelCoor( f1, f2, f3 );
-  //this->setRelCoor( 5, 0, 0 );
-
-  /*SYNCHELP_READ_FLOAT( f1 );
-  SYNCHELP_READ_FLOAT( f2 );
-  SYNCHELP_READ_FLOAT( f3 );*/
-  //this->setAbsCoor( f1, f2, f3 );
+
 
   SYNCHELP_READ_FLOAT( f1 );
@@ -1082,19 +1081,15 @@
   this->setRelDir( Quaternion( Vector(f2, f3, f4), f1 ) );
 
-  /*SYNCHELP_READ_FLOAT( f1 );
-  SYNCHELP_READ_FLOAT( f2 );
-  SYNCHELP_READ_FLOAT( f3 );
-  SYNCHELP_READ_FLOAT( f4 );*/
-  //this->setAbsDir( Quaternion( Vector(f2, f3, f4), f1 ) );
-
   int n;
   char * childName;
 
+  PRINTF(0)("JKLO %d %d %d %d\n", data[__synchelp_read_i], data[__synchelp_read_i+1], data[__synchelp_read_i+2], data[__synchelp_read_i+3]);
   SYNCHELP_READ_INT( n );
+  PRINTF(0)("read %s:n=%d\n", this->getName(), n);
 
   for (int i = 0; i<n; i++)
   {
     SYNCHELP_READ_STRINGM( childName );
-    //PRINTF(0)("childname = %s\n", childName);
+    PRINTF(0)("RCVD CHILD = %s\n", childName);
     addChild( childName );
     delete childName;
@@ -1132,12 +1127,4 @@
   SYNCHELP_WRITE_FLOAT( this->relCoordinate.z );
 
-  //PRINTF(0)("%s, %f, %f, %f\n", getClassName(), relCoordinate.x, relCoordinate.y, relCoordinate.z);
-
-  /*SYNCHELP_WRITE_FLOAT( this->absCoordinate.x );
-  SYNCHELP_WRITE_FLOAT( this->absCoordinate.y );
-  SYNCHELP_WRITE_FLOAT( this->absCoordinate.z );*/
-
-  //PRINTF(0)("%s, %f, %f, %f\n", getClassName(), absCoordinate.x, absCoordinate.y, absCoordinate.z);
-
   SYNCHELP_WRITE_FLOAT( this->relDirection.w );
   SYNCHELP_WRITE_FLOAT( this->relDirection.v.x );
@@ -1145,17 +1132,145 @@
   SYNCHELP_WRITE_FLOAT( this->relDirection.v.z );
 
-  /*SYNCHELP_WRITE_FLOAT( this->absDirection.w );
-  SYNCHELP_WRITE_FLOAT( this->absDirection.v.x );
-  SYNCHELP_WRITE_FLOAT( this->absDirection.v.y );
-  SYNCHELP_WRITE_FLOAT( this->absDirection.v.z );*/
-
   int n = children.size();
+
+  //check if camera is in children
+  for (std::list<PNode*>::const_iterator it = children.begin(); it!=children.end(); it++)
+  {
+    if ( (*it)->isA(CL_CAMERA) )
+      n--;
+  }
+  PRINTF(0)("write %s:n=%d\n", this->getName(), n);
   SYNCHELP_WRITE_INT( n );
+  PRINTF(0)("ASDF %d %d %d %d\n", data[__synchelp_write_i-4], data[__synchelp_write_i-3], data[__synchelp_write_i-2], data[__synchelp_write_i-1]);
 
   for (std::list<PNode*>::const_iterator it = children.begin(); it!=children.end(); it++)
   {
-    SYNCHELP_WRITE_STRING( (*it)->getName() );
+    //dont add camera because there is only one camera attached to local player
+    if ( !(*it)->isA(CL_CAMERA) )
+    {
+      PRINTF(0)("SENDING CHILD: %s\n", (*it)->getName());
+      SYNCHELP_WRITE_STRING( (*it)->getName() );
+    }
   }
 
   return SYNCHELP_WRITE_N;
 }
+
+#define __FLAG_COOR 1
+#define __FLAG_ROT  2
+
+#define __OFFSET_POS 1
+#define __OFFSET_ROT 0.05
+
+/**
+ * Writes data from network containing information about the state which has changed
+ * @param data pointer to data
+ * @param length length of data
+ * @param sender hostID of sender
+ */
+int PNode::writeSync( const byte * data, int length, int sender )
+{
+  SYNCHELP_READ_BEGIN();
+
+  if ( this->getHostID()==this->getOwner() )
+  {
+    return SYNCHELP_READ_N;
+  }
+
+  byte flags = 0;
+  SYNCHELP_READ_BYTE( flags );
+  //PRINTF(0)("%s::FLAGS = %d\n", this->getName(), flags);
+
+  float f1, f2, f3, f4;
+
+  if ( flags & __FLAG_COOR )
+  {
+    SYNCHELP_READ_FLOAT( f1 );
+    SYNCHELP_READ_FLOAT( f2 );
+    SYNCHELP_READ_FLOAT( f3 );
+    PRINTF(0)("RCVD COOR: %f %f %f\n", f1, f2, f3);
+    this->setRelCoor( f1, f2, f3 );
+  }
+
+  if ( flags & __FLAG_ROT )
+  {
+    SYNCHELP_READ_FLOAT( f1 );
+    SYNCHELP_READ_FLOAT( f2 );
+    SYNCHELP_READ_FLOAT( f3 );
+    SYNCHELP_READ_FLOAT( f4 );
+    PRINTF(0)("RCVD QUAT: %f %f %f %f\n", f1, f2, f3, f4);
+    //this->setRelDir( Quaternion( Vector(f2, f3, f4), f1 ) );
+    Quaternion q;
+    q.w = f1;
+    q.v.x = f2;
+    q.v.y = f3;
+    q.v.z = f4;
+    this->setAbsDir( q );
+  }
+
+  return SYNCHELP_READ_N;
+}
+
+/**
+ * data copied in data will bee sent to another host
+ * @param data pointer to data
+ * @param maxLength max length of data
+ * @return the number of bytes writen
+ */
+int PNode::readSync( byte * data, int maxLength )
+{
+  SYNCHELP_WRITE_BEGIN();
+
+  if ( this->getHostID()!=this->getOwner() )
+  {
+    return SYNCHELP_WRITE_N;
+  }
+
+  byte flags = 0;
+  if ( fabs( coorx - relCoordinate.x ) > __OFFSET_POS ||
+       fabs( coory - relCoordinate.y ) > __OFFSET_POS ||
+       fabs( coorz - relCoordinate.z ) > __OFFSET_POS )
+    flags |= __FLAG_COOR;
+
+  if ( fabs( rotw - absDirection.w ) > __OFFSET_ROT ||
+       fabs( rotx - absDirection.v.x ) > __OFFSET_ROT ||
+       fabs( roty - absDirection.v.y ) > __OFFSET_ROT ||
+       fabs( rotz - absDirection.v.z ) > __OFFSET_ROT )
+    flags |= __FLAG_ROT;
+
+
+  SYNCHELP_WRITE_BYTE( flags );
+  //PRINTF(0)("FLAGS = %d\n", flags);
+
+  if ( flags & __FLAG_COOR )
+  {
+
+    PRINTF(0)("SEND COOR: %f %f %f\n", this->relCoordinate.x, this->relCoordinate.y, this->relCoordinate.z);
+
+    SYNCHELP_WRITE_FLOAT( this->relCoordinate.x );
+    SYNCHELP_WRITE_FLOAT( this->relCoordinate.y );
+    SYNCHELP_WRITE_FLOAT( this->relCoordinate.z );
+
+    coorx = relCoordinate.x;
+    coory = relCoordinate.y;
+    coorz = relCoordinate.z;
+  }
+
+  if ( flags & __FLAG_ROT )
+  {
+
+    PRINTF(0)("SEND QUAT: %f %f %f %f\n", this->absDirection.w, this->absDirection.v.x, this->absDirection.v.y, this->absDirection.v.z);
+
+    SYNCHELP_WRITE_FLOAT( this->absDirection.w );
+    SYNCHELP_WRITE_FLOAT( this->absDirection.v.x );
+    SYNCHELP_WRITE_FLOAT( this->absDirection.v.y );
+    SYNCHELP_WRITE_FLOAT( this->absDirection.v.z );
+
+    rotw = absDirection.w;
+    rotx = absDirection.v.x;
+    roty = absDirection.v.y;
+    rotz = absDirection.v.z;
+  }
+
+  return SYNCHELP_WRITE_N;
+}
Index: trunk/src/lib/coord/p_node.h
===================================================================
--- trunk/src/lib/coord/p_node.h	(revision 6624)
+++ trunk/src/lib/coord/p_node.h	(revision 6634)
@@ -186,4 +186,6 @@
   int       writeState(const byte* data, int length, int sender);
   int       readState(byte* data, int maxLength );
+  int       writeSync(const byte* data, int length, int sender);
+  int       readSync(byte* data, int maxLength );
 
  private:
@@ -229,4 +231,14 @@
 
   static PNode*      nullParent;         //!< The ROOT of the main PNode Tree.
+
+  private:
+    float coorx;
+    float coory;
+    float coorz;
+
+    float rotw;
+    float rotx;
+    float roty;
+    float rotz;
 };
 
