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