Changeset 6331 in orxonox.OLD for branches/network/src/lib/coord
- Timestamp:
- Dec 29, 2005, 5:37:00 PM (19 years ago)
- Location:
- branches/network/src/lib/coord
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/lib/coord/p_node.cc
r6142 r6331 27 27 #include "glincl.h" 28 28 #include "color.h" 29 30 #include "synchronizeable.h" 29 31 30 32 using namespace std; … … 1003 1005 return (PNODE_ROTATE_AND_MOVE); 1004 1006 } 1007 1008 /** 1009 * Writes data from network containing information about the state 1010 * @param data pointer to data 1011 * @param length length of data 1012 * @param sender hostID of sender 1013 */ 1014 int PNode::writeState( const byte * data, int length, int sender ) 1015 { 1016 SYNCHELP_READ_BEGIN(); 1017 1018 char * name; 1019 SYNCHELP_READ_STRINGM( name ); 1020 1021 char * parentName = NULL; 1022 SYNCHELP_READ_STRINGM( parentName ); 1023 1024 if ( strcmp(parentName, "")==0 ) 1025 { 1026 setParent( (char*)NULL ); 1027 } 1028 else 1029 { 1030 setParent( parentName ); 1031 } 1032 1033 delete[] parentName; 1034 1035 int parentMode; 1036 SYNCHELP_READ_INT( parentMode ); 1037 this->setParentMode((PARENT_MODE)parentMode); 1038 1039 if ( strcmp(name, "")==0 ) 1040 { 1041 this->setName( NULL ); 1042 } 1043 else 1044 { 1045 this->setName( name ); 1046 } 1047 delete name; 1048 name = NULL; 1049 1050 float f1, f2, f3, f4; 1051 1052 SYNCHELP_READ_FLOAT( f1 ); 1053 SYNCHELP_READ_FLOAT( f2 ); 1054 SYNCHELP_READ_FLOAT( f3 ); 1055 this->setRelCoor( f1, f2, f3 ); 1056 1057 PRINTF(0)("%f %f %f\n", f1, f2, f3); 1058 1059 SYNCHELP_READ_FLOAT( f1 ); 1060 SYNCHELP_READ_FLOAT( f2 ); 1061 SYNCHELP_READ_FLOAT( f3 ); 1062 this->setAbsCoor( f1, f2, f3 ); 1063 1064 PRINTF(0)("%f %f %f\n", f1, f2, f3); 1065 1066 SYNCHELP_READ_FLOAT( f1 ); 1067 SYNCHELP_READ_FLOAT( f2 ); 1068 SYNCHELP_READ_FLOAT( f3 ); 1069 SYNCHELP_READ_FLOAT( f4 ); 1070 this->setRelDir( Quaternion( Vector(f2, f3, f4), f1 ) ); 1071 1072 SYNCHELP_READ_FLOAT( f1 ); 1073 SYNCHELP_READ_FLOAT( f2 ); 1074 SYNCHELP_READ_FLOAT( f3 ); 1075 SYNCHELP_READ_FLOAT( f4 ); 1076 this->setAbsDir( Quaternion( Vector(f2, f3, f4), f1 ) ); 1077 1078 int n; 1079 char * childName; 1080 1081 SYNCHELP_READ_INT( n ); 1082 1083 for (int i = 0; i<n; i++) 1084 { 1085 SYNCHELP_READ_STRINGM( childName ); 1086 addChild( childName ); 1087 delete childName; 1088 childName = NULL; 1089 } 1090 1091 return SYNCHELP_READ_N; 1092 } 1093 1094 /** 1095 * data copied in data will bee sent to another host 1096 * @param data pointer to data 1097 * @param maxLength max length of data 1098 * @return the number of bytes writen 1099 */ 1100 int PNode::readState( byte * data, int maxLength ) 1101 { 1102 SYNCHELP_WRITE_BEGIN(); 1103 1104 SYNCHELP_WRITE_STRING( this->getName() ); 1105 1106 if ( this->parent ) 1107 { 1108 SYNCHELP_WRITE_STRING( parent->getName() ); 1109 } 1110 else 1111 { 1112 SYNCHELP_WRITE_STRING( "" ); 1113 } 1114 1115 SYNCHELP_WRITE_INT( this->parentMode ); 1116 1117 SYNCHELP_WRITE_FLOAT( this->relCoordinate.x ); 1118 SYNCHELP_WRITE_FLOAT( this->relCoordinate.y ); 1119 SYNCHELP_WRITE_FLOAT( this->relCoordinate.z ); 1120 1121 PRINTF(0)("%s, %f, %f, %f\n", getClassName(), relCoordinate.x, relCoordinate.y, relCoordinate.z); 1122 1123 SYNCHELP_WRITE_FLOAT( this->absCoordinate.x ); 1124 SYNCHELP_WRITE_FLOAT( this->absCoordinate.y ); 1125 SYNCHELP_WRITE_FLOAT( this->absCoordinate.z ); 1126 1127 PRINTF(0)("%s, %f, %f, %f\n", getClassName(), absCoordinate.x, absCoordinate.y, absCoordinate.z); 1128 1129 SYNCHELP_WRITE_FLOAT( this->relDirection.w ); 1130 SYNCHELP_WRITE_FLOAT( this->relDirection.v.x ); 1131 SYNCHELP_WRITE_FLOAT( this->relDirection.v.y ); 1132 SYNCHELP_WRITE_FLOAT( this->relDirection.v.z ); 1133 1134 SYNCHELP_WRITE_FLOAT( this->absDirection.w ); 1135 SYNCHELP_WRITE_FLOAT( this->absDirection.v.x ); 1136 SYNCHELP_WRITE_FLOAT( this->absDirection.v.y ); 1137 SYNCHELP_WRITE_FLOAT( this->absDirection.v.z ); 1138 1139 int n = children.size(); 1140 SYNCHELP_WRITE_INT( n ); 1141 1142 for (std::list<PNode*>::const_iterator it = children.begin(); it!=children.end(); it++) 1143 { 1144 SYNCHELP_WRITE_STRING( (*it)->getName() ); 1145 } 1146 return SYNCHELP_WRITE_N; 1147 } -
branches/network/src/lib/coord/p_node.h
r6142 r6331 178 178 static PARENT_MODE charToParentingMode(const char* parentingMode); 179 179 180 int writeState(const byte* data, int length, int sender); 181 int readState(byte* data, int maxLength ); 180 182 181 183 private:
Note: See TracChangeset
for help on using the changeset viewer.