Changeset 6634 in orxonox.OLD for trunk/src/lib/coord
- Timestamp:
- Jan 21, 2006, 1:18:19 AM (19 years ago)
- Location:
- trunk/src/lib/coord
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/coord/p_node.cc
r6624 r6634 505 505 { 506 506 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 ); 507 509 if (childNode != NULL) 510 { 508 511 this->addChild(childNode); 512 } 509 513 } 510 514 … … 1069 1073 SYNCHELP_READ_FLOAT( f3 ); 1070 1074 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 1077 1076 1078 1077 SYNCHELP_READ_FLOAT( f1 ); … … 1082 1081 this->setRelDir( Quaternion( Vector(f2, f3, f4), f1 ) ); 1083 1082 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 1090 1083 int n; 1091 1084 char * childName; 1092 1085 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]); 1093 1087 SYNCHELP_READ_INT( n ); 1088 PRINTF(0)("read %s:n=%d\n", this->getName(), n); 1094 1089 1095 1090 for (int i = 0; i<n; i++) 1096 1091 { 1097 1092 SYNCHELP_READ_STRINGM( childName ); 1098 //PRINTF(0)("childname= %s\n", childName);1093 PRINTF(0)("RCVD CHILD = %s\n", childName); 1099 1094 addChild( childName ); 1100 1095 delete childName; … … 1132 1127 SYNCHELP_WRITE_FLOAT( this->relCoordinate.z ); 1133 1128 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 1142 1129 SYNCHELP_WRITE_FLOAT( this->relDirection.w ); 1143 1130 SYNCHELP_WRITE_FLOAT( this->relDirection.v.x ); … … 1145 1132 SYNCHELP_WRITE_FLOAT( this->relDirection.v.z ); 1146 1133 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 1152 1134 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); 1153 1143 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]); 1154 1145 1155 1146 for (std::list<PNode*>::const_iterator it = children.begin(); it!=children.end(); it++) 1156 1147 { 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 } 1158 1154 } 1159 1155 1160 1156 return SYNCHELP_WRITE_N; 1161 1157 } 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 */ 1171 int 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 */ 1220 int 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 } -
trunk/src/lib/coord/p_node.h
r6616 r6634 186 186 int writeState(const byte* data, int length, int sender); 187 187 int readState(byte* data, int maxLength ); 188 int writeSync(const byte* data, int length, int sender); 189 int readSync(byte* data, int maxLength ); 188 190 189 191 private: … … 229 231 230 232 static PNode* nullParent; //!< The ROOT of the main PNode Tree. 233 234 private: 235 float coorx; 236 float coory; 237 float coorz; 238 239 float rotw; 240 float rotx; 241 float roty; 242 float rotz; 231 243 }; 232 244
Note: See TracChangeset
for help on using the changeset viewer.