Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6634 in orxonox.OLD for trunk/src/lib/coord/p_node.cc


Ignore:
Timestamp:
Jan 21, 2006, 1:18:19 AM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the network-branche back to the trunk

merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/network . -r6500:HEAD
minor conflicts in texture and one Makefile resolved to the trunk

also made a small patch to texture, so it Modulates with GL_REPEAT

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/coord/p_node.cc

    r6624 r6634  
    505505{
    506506  PNode* childNode = dynamic_cast<PNode*>(ClassList::getObject(childName, CL_PARENT_NODE));
     507//  PRINTF(0)("Adding the Child: %s to: %s\n", childName, this->getName());
     508//  assert( childNode != NULL );
    507509  if (childNode != NULL)
     510  {
    508511    this->addChild(childNode);
     512  }
    509513}
    510514
     
    10691073  SYNCHELP_READ_FLOAT( f3 );
    10701074  this->setRelCoor( f1, f2, f3 );
    1071   //this->setRelCoor( 5, 0, 0 );
    1072 
    1073   /*SYNCHELP_READ_FLOAT( f1 );
    1074   SYNCHELP_READ_FLOAT( f2 );
    1075   SYNCHELP_READ_FLOAT( f3 );*/
    1076   //this->setAbsCoor( f1, f2, f3 );
     1075
    10771076
    10781077  SYNCHELP_READ_FLOAT( f1 );
     
    10821081  this->setRelDir( Quaternion( Vector(f2, f3, f4), f1 ) );
    10831082
    1084   /*SYNCHELP_READ_FLOAT( f1 );
    1085   SYNCHELP_READ_FLOAT( f2 );
    1086   SYNCHELP_READ_FLOAT( f3 );
    1087   SYNCHELP_READ_FLOAT( f4 );*/
    1088   //this->setAbsDir( Quaternion( Vector(f2, f3, f4), f1 ) );
    1089 
    10901083  int n;
    10911084  char * childName;
    10921085
     1086  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]);
    10931087  SYNCHELP_READ_INT( n );
     1088  PRINTF(0)("read %s:n=%d\n", this->getName(), n);
    10941089
    10951090  for (int i = 0; i<n; i++)
    10961091  {
    10971092    SYNCHELP_READ_STRINGM( childName );
    1098     //PRINTF(0)("childname = %s\n", childName);
     1093    PRINTF(0)("RCVD CHILD = %s\n", childName);
    10991094    addChild( childName );
    11001095    delete childName;
     
    11321127  SYNCHELP_WRITE_FLOAT( this->relCoordinate.z );
    11331128
    1134   //PRINTF(0)("%s, %f, %f, %f\n", getClassName(), relCoordinate.x, relCoordinate.y, relCoordinate.z);
    1135 
    1136   /*SYNCHELP_WRITE_FLOAT( this->absCoordinate.x );
    1137   SYNCHELP_WRITE_FLOAT( this->absCoordinate.y );
    1138   SYNCHELP_WRITE_FLOAT( this->absCoordinate.z );*/
    1139 
    1140   //PRINTF(0)("%s, %f, %f, %f\n", getClassName(), absCoordinate.x, absCoordinate.y, absCoordinate.z);
    1141 
    11421129  SYNCHELP_WRITE_FLOAT( this->relDirection.w );
    11431130  SYNCHELP_WRITE_FLOAT( this->relDirection.v.x );
     
    11451132  SYNCHELP_WRITE_FLOAT( this->relDirection.v.z );
    11461133
    1147   /*SYNCHELP_WRITE_FLOAT( this->absDirection.w );
    1148   SYNCHELP_WRITE_FLOAT( this->absDirection.v.x );
    1149   SYNCHELP_WRITE_FLOAT( this->absDirection.v.y );
    1150   SYNCHELP_WRITE_FLOAT( this->absDirection.v.z );*/
    1151 
    11521134  int n = children.size();
     1135
     1136  //check if camera is in children
     1137  for (std::list<PNode*>::const_iterator it = children.begin(); it!=children.end(); it++)
     1138  {
     1139    if ( (*it)->isA(CL_CAMERA) )
     1140      n--;
     1141  }
     1142  PRINTF(0)("write %s:n=%d\n", this->getName(), n);
    11531143  SYNCHELP_WRITE_INT( n );
     1144  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]);
    11541145
    11551146  for (std::list<PNode*>::const_iterator it = children.begin(); it!=children.end(); it++)
    11561147  {
    1157     SYNCHELP_WRITE_STRING( (*it)->getName() );
     1148    //dont add camera because there is only one camera attached to local player
     1149    if ( !(*it)->isA(CL_CAMERA) )
     1150    {
     1151      PRINTF(0)("SENDING CHILD: %s\n", (*it)->getName());
     1152      SYNCHELP_WRITE_STRING( (*it)->getName() );
     1153    }
    11581154  }
    11591155
    11601156  return SYNCHELP_WRITE_N;
    11611157}
     1158
     1159#define __FLAG_COOR 1
     1160#define __FLAG_ROT  2
     1161
     1162#define __OFFSET_POS 1
     1163#define __OFFSET_ROT 0.05
     1164
     1165/**
     1166 * Writes data from network containing information about the state which has changed
     1167 * @param data pointer to data
     1168 * @param length length of data
     1169 * @param sender hostID of sender
     1170 */
     1171int PNode::writeSync( const byte * data, int length, int sender )
     1172{
     1173  SYNCHELP_READ_BEGIN();
     1174
     1175  if ( this->getHostID()==this->getOwner() )
     1176  {
     1177    return SYNCHELP_READ_N;
     1178  }
     1179
     1180  byte flags = 0;
     1181  SYNCHELP_READ_BYTE( flags );
     1182  //PRINTF(0)("%s::FLAGS = %d\n", this->getName(), flags);
     1183
     1184  float f1, f2, f3, f4;
     1185
     1186  if ( flags & __FLAG_COOR )
     1187  {
     1188    SYNCHELP_READ_FLOAT( f1 );
     1189    SYNCHELP_READ_FLOAT( f2 );
     1190    SYNCHELP_READ_FLOAT( f3 );
     1191    PRINTF(0)("RCVD COOR: %f %f %f\n", f1, f2, f3);
     1192    this->setRelCoor( f1, f2, f3 );
     1193  }
     1194
     1195  if ( flags & __FLAG_ROT )
     1196  {
     1197    SYNCHELP_READ_FLOAT( f1 );
     1198    SYNCHELP_READ_FLOAT( f2 );
     1199    SYNCHELP_READ_FLOAT( f3 );
     1200    SYNCHELP_READ_FLOAT( f4 );
     1201    PRINTF(0)("RCVD QUAT: %f %f %f %f\n", f1, f2, f3, f4);
     1202    //this->setRelDir( Quaternion( Vector(f2, f3, f4), f1 ) );
     1203    Quaternion q;
     1204    q.w = f1;
     1205    q.v.x = f2;
     1206    q.v.y = f3;
     1207    q.v.z = f4;
     1208    this->setAbsDir( q );
     1209  }
     1210
     1211  return SYNCHELP_READ_N;
     1212}
     1213
     1214/**
     1215 * data copied in data will bee sent to another host
     1216 * @param data pointer to data
     1217 * @param maxLength max length of data
     1218 * @return the number of bytes writen
     1219 */
     1220int PNode::readSync( byte * data, int maxLength )
     1221{
     1222  SYNCHELP_WRITE_BEGIN();
     1223
     1224  if ( this->getHostID()!=this->getOwner() )
     1225  {
     1226    return SYNCHELP_WRITE_N;
     1227  }
     1228
     1229  byte flags = 0;
     1230  if ( fabs( coorx - relCoordinate.x ) > __OFFSET_POS ||
     1231       fabs( coory - relCoordinate.y ) > __OFFSET_POS ||
     1232       fabs( coorz - relCoordinate.z ) > __OFFSET_POS )
     1233    flags |= __FLAG_COOR;
     1234
     1235  if ( fabs( rotw - absDirection.w ) > __OFFSET_ROT ||
     1236       fabs( rotx - absDirection.v.x ) > __OFFSET_ROT ||
     1237       fabs( roty - absDirection.v.y ) > __OFFSET_ROT ||
     1238       fabs( rotz - absDirection.v.z ) > __OFFSET_ROT )
     1239    flags |= __FLAG_ROT;
     1240
     1241
     1242  SYNCHELP_WRITE_BYTE( flags );
     1243  //PRINTF(0)("FLAGS = %d\n", flags);
     1244
     1245  if ( flags & __FLAG_COOR )
     1246  {
     1247
     1248    PRINTF(0)("SEND COOR: %f %f %f\n", this->relCoordinate.x, this->relCoordinate.y, this->relCoordinate.z);
     1249
     1250    SYNCHELP_WRITE_FLOAT( this->relCoordinate.x );
     1251    SYNCHELP_WRITE_FLOAT( this->relCoordinate.y );
     1252    SYNCHELP_WRITE_FLOAT( this->relCoordinate.z );
     1253
     1254    coorx = relCoordinate.x;
     1255    coory = relCoordinate.y;
     1256    coorz = relCoordinate.z;
     1257  }
     1258
     1259  if ( flags & __FLAG_ROT )
     1260  {
     1261
     1262    PRINTF(0)("SEND QUAT: %f %f %f %f\n", this->absDirection.w, this->absDirection.v.x, this->absDirection.v.y, this->absDirection.v.z);
     1263
     1264    SYNCHELP_WRITE_FLOAT( this->absDirection.w );
     1265    SYNCHELP_WRITE_FLOAT( this->absDirection.v.x );
     1266    SYNCHELP_WRITE_FLOAT( this->absDirection.v.y );
     1267    SYNCHELP_WRITE_FLOAT( this->absDirection.v.z );
     1268
     1269    rotw = absDirection.w;
     1270    rotx = absDirection.v.x;
     1271    roty = absDirection.v.y;
     1272    rotz = absDirection.v.z;
     1273  }
     1274
     1275  return SYNCHELP_WRITE_N;
     1276}
Note: See TracChangeset for help on using the changeset viewer.