From: <sv...@ww...> - 2004-08-01 13:21:15
|
Author: wolverine Date: 2004-08-01 06:21:08 -0700 (Sun, 01 Aug 2004) New Revision: 1197 Modified: trunk/CSP/CSPSim/Source/DynamicObject.cpp Log: formatting changes Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=1197 Modified: trunk/CSP/CSPSim/Source/DynamicObject.cpp =================================================================== --- trunk/CSP/CSPSim/Source/DynamicObject.cpp 2004-08-01 03:31:42 UTC (rev 1196) +++ trunk/CSP/CSPSim/Source/DynamicObject.cpp 2004-08-01 13:21:08 UTC (rev 1197) @@ -388,76 +388,73 @@ } -NetworkMessage * DynamicObject::getUpdateMessage() -{ - CSP_LOG(APP, DEBUG, "DynamicObject::getUpdateMessage()"); - unsigned short messageType = 2; - unsigned short payloadLen = sizeof(int) + sizeof(double) + 3*sizeof(simdata::Vector3) + +NetworkMessage * DynamicObject::getUpdateMessage() { + CSP_LOG(APP, DEBUG, "DynamicObject::getUpdateMessage()"); + unsigned short messageType = 2; + unsigned short payloadLen = sizeof(int) + sizeof(double) + 3*sizeof(simdata::Vector3) + sizeof(simdata::Quat) /* + sizeof(simdata::Matrix3) + sizeof(double) */; - NetworkMessage * message = CSPSim::theSim->getNetworkMessenger()->allocMessageBuffer(messageType, payloadLen); + NetworkMessage * message = CSPSim::theSim->getNetworkMessenger()->allocMessageBuffer(messageType, payloadLen); - ObjectUpdateMessagePayload * ptrPayload = (ObjectUpdateMessagePayload*)message->getPayloadPtr(); - ptrPayload->id = m_ID; - ptrPayload->timeStamp = CSPSim::theSim->getElapsedTime(); - b_GlobalPosition->value().writeBinary((unsigned char *)&(ptrPayload->globalPosition),24); - b_LinearVelocity->value().writeBinary((unsigned char *)&(ptrPayload->linearVelocity),24); - b_AngularVelocity->value().writeBinary((unsigned char *)&(ptrPayload->angularVelocity),24); - b_Attitude->value().writeBinary((unsigned char *)&(ptrPayload->attitude),32); - -// simdata::MemoryWriter writer((simdata::uint8*)ptrPayload); -// writer << m_ID; -// writer << m_Type; -// writer << CSPSim::theSim->getElapsedTime(); -// b_GlobalPosition->value().serialize(writer); -// b_LinearVelocity->value().serialize(writer); -// b_AngularVelocity->value().serialize(writer); -// b_Attitude->value().serialize(writer); + ObjectUpdateMessagePayload * ptrPayload = (ObjectUpdateMessagePayload*)message->getPayloadPtr(); + ptrPayload->id = m_ID; + ptrPayload->timeStamp = CSPSim::theSim->getElapsedTime(); + b_GlobalPosition->value().writeBinary((unsigned char *)&(ptrPayload->globalPosition),24); + b_LinearVelocity->value().writeBinary((unsigned char *)&(ptrPayload->linearVelocity),24); + b_AngularVelocity->value().writeBinary((unsigned char *)&(ptrPayload->angularVelocity),24); + b_Attitude->value().writeBinary((unsigned char *)&(ptrPayload->attitude),32); + + // simdata::MemoryWriter writer((simdata::uint8*)ptrPayload); + // writer << m_ID; + // writer << m_Type; + // writer << CSPSim::theSim->getElapsedTime(); + // b_GlobalPosition->value().serialize(writer); + // b_LinearVelocity->value().serialize(writer); + // b_AngularVelocity->value().serialize(writer); + // b_Attitude->value().serialize(writer); - CSP_LOG(APP, DEBUG, "DynamicObject::getUpdateMessage() - returning message"); + CSP_LOG(APP, DEBUG, "DynamicObject::getUpdateMessage() - returning message"); - - return message; + return message; } -void DynamicObject::putUpdateMessage(NetworkMessage* message) -{ - // read message +void DynamicObject::putUpdateMessage(NetworkMessage* message) { + // read message - ObjectUpdateMessagePayload * ptrPayload = (ObjectUpdateMessagePayload*)message->getPayloadPtr(); - // verify we have the correct id in the packet for this object. - if (m_ID == ptrPayload->id) - { -// printf("Loading update message of object %d\n", m_ID); - } - else - { -// printf("Error loading update message, object id (%d) does not match\n", idValue); - } + ObjectUpdateMessagePayload * ptrPayload = (ObjectUpdateMessagePayload*)message->getPayloadPtr(); + // verify we have the correct id in the packet for this object. + if (m_ID == ptrPayload->id) + { + // printf("Loading update message of object %d\n", m_ID); + } + else + { + // printf("Error loading update message, object id (%d) does not match\n", idValue); + } - // we can disregard this message if the timestamp is older then the most - // recent update. + // we can disregard this message if the timestamp is older then the most + // recent update. - ptrPayload->timeStamp = CSPSim::theSim->getElapsedTime(); - // - //load the other values. - b_GlobalPosition->value().readBinary((unsigned char*)&(ptrPayload->globalPosition),24); - b_LinearVelocity->value().readBinary((unsigned char *)&(ptrPayload->linearVelocity),24); - b_AngularVelocity->value().readBinary((unsigned char *)&(ptrPayload->angularVelocity),24); - b_Attitude->value().readBinary((unsigned char *)&(ptrPayload->attitude),32); + ptrPayload->timeStamp = CSPSim::theSim->getElapsedTime(); + // + //load the other values. + b_GlobalPosition->value().readBinary((unsigned char*)&(ptrPayload->globalPosition),24); + b_LinearVelocity->value().readBinary((unsigned char *)&(ptrPayload->linearVelocity),24); + b_AngularVelocity->value().readBinary((unsigned char *)&(ptrPayload->angularVelocity),24); + b_Attitude->value().readBinary((unsigned char *)&(ptrPayload->attitude),32); -// unsigned int _id; -// unsigned _type; -// float _timestamp; -// -// simdata::MemoryReader reader((simdata::uint8*)ptrPayload); -// reader >> _id; -// reader >> _type; -// reader >> _timestamp; -// b_GlobalPosition->value().serialize(reader); -// b_LinearVelocity->value().serialize(reader); -// b_AngularVelocity->value().serialize(reader); -// b_Attitude->value().serialize(reader); + // unsigned int _id; + // unsigned _type; + // float _timestamp; + // + // simdata::MemoryReader reader((simdata::uint8*)ptrPayload); + // reader >> _id; + // reader >> _type; + // reader >> _timestamp; + // b_GlobalPosition->value().serialize(reader); + // b_LinearVelocity->value().serialize(reader); + // b_AngularVelocity->value().serialize(reader); + // b_Attitude->value().serialize(reader); } |