From: Cirilo B. <pin...@us...> - 2004-11-20 08:20:27
|
Update of /cvsroot/once/oncecode/src/common In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7747/common Modified Files: ocpcconvert.cpp ocpcserialize.cpp ocpcserialize.h ocplayeractionmsg.cpp ocplayeractionmsg.h Log Message: Reworked movement system yet again and moved player key input to pckeyinput. Index: ocpcserialize.h =================================================================== RCS file: /cvsroot/once/oncecode/src/common/ocpcserialize.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ocpcserialize.h 15 Nov 2004 07:18:05 -0000 1.4 --- ocpcserialize.h 20 Nov 2004 08:20:10 -0000 1.5 *************** *** 68,79 **** { public: csVector3 position; ! csVector3 speed; float yrot; float yrot_vel; - csVector3 body; - csVector3 legs; - csVector3 cdshift; - char init_cd; CS_ID area_id; --- 68,78 ---- { public: + // Data needed for Dead Reckoning + bool on_ground; + float speed; csVector3 position; ! csVector3 velocity; float yrot; float yrot_vel; CS_ID area_id; Index: ocpcconvert.cpp =================================================================== RCS file: /cvsroot/once/oncecode/src/common/ocpcconvert.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ocpcconvert.cpp 16 Nov 2004 10:54:51 -0000 1.7 --- ocpcconvert.cpp 20 Nov 2004 08:20:10 -0000 1.8 *************** *** 46,49 **** --- 46,50 ---- { SYSTRACE("ocPcConverters::UpdatePropclassFromSerial(iPcMesh)"); + fprintf(stderr, "---\n---\n---\nLoading mesh...\n"); return GetApplication()->GetLoader()->LoadMesh(pcmesh, data->mesh_name); } *************** *** 53,59 **** SYSTRACE("ocPcConverters::PropclassToSerial(iPcLinearMovement)"); ocPcLinearMovementData* data = new ocPcLinearMovementData; ! iSector* sect; ! pclinmove->GetLastPosition(data->position, data->yrot, sect); CS_ASSERT(sect); --- 54,61 ---- SYSTRACE("ocPcConverters::PropclassToSerial(iPcLinearMovement)"); ocPcLinearMovementData* data = new ocPcLinearMovementData; ! iSector* sect; ! pclinmove->GetDRData(data->on_ground, data->speed, data->position, ! data->yrot, sect, data->velocity, data->yrot_vel); CS_ASSERT(sect); *************** *** 61,78 **** sector_reg = GetApplication()->GetEntityRegistry()->GetSectorRegistry(); data->area_id = sector_reg->GetIDBySector(sect); - - pclinmove->GetVelocity(data->speed); - - csVector3 ang_vel; - pclinmove->GetAngularVelocity(ang_vel); - data->yrot_vel = ang_vel.y; - iPcCollisionDetection *coldet = 0; - pclinmove->GetCDDimensions(data->body, data->legs, data->cdshift, coldet); - if (coldet != 0) - data->init_cd = 1; - else - data->init_cd = 0; - return data; } --- 63,67 ---- *************** *** 86,103 **** iSector* sector = sector_reg->GetSectorByID(data->area_id); CS_ASSERT(sector); ! ! pc->SetPosition(data->position, data->yrot, sector); ! pc->SetVelocity(data->speed); ! pc->SetAngularVelocity(csVector3(0, data->yrot_vel, 0)); ! ! if (data->init_cd != 0) ! { ! csVector3 _legs; ! csVector3 _body; ! csVector3 _cdshift; ! iPcCollisionDetection *_pc_cd; ! pc->GetCDDimensions(_body, _legs, _cdshift, _pc_cd); ! pc->InitCD(data->body, data->legs, data->cdshift, _pc_cd); ! } return true; --- 75,81 ---- iSector* sector = sector_reg->GetSectorByID(data->area_id); CS_ASSERT(sector); ! ! pc->SetDRData(data->on_ground, data->speed, data->position, ! data->yrot, sector, data->velocity, data->yrot_vel); return true; Index: ocplayeractionmsg.h =================================================================== RCS file: /cvsroot/once/oncecode/src/common/ocplayeractionmsg.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ocplayeractionmsg.h 15 Nov 2004 07:18:05 -0000 1.6 --- ocplayeractionmsg.h 20 Nov 2004 08:20:10 -0000 1.7 *************** *** 27,30 **** --- 27,31 ---- #define PLAYER_UPDATE_POS_INTERVAL 1000 + #include "csgeom/vector3.h" #include "common/ocserialize.h" *************** *** 78,97 **** }; - class ocRequestPosInit : public iSerial { - public: - ocRequestPosInit() {} - virtual ~ocRequestPosInit() {} - - // ************************* Factory pseudo-interface *********************** - static int ocClassID; - static iSerial* ocCreateInstance(); - static bool Deserialize(ocRequestPosInit* me, ocSerialBuffer &buf); - - // ************************** iSerial interface ***************************** - virtual uint32 GetMessageLength() - { return 0; } - virtual void Serialize(ocSerialBuffer &buf); - virtual int GetSerialType() const; - }; class ocRequestSvrPosUpdate : public iSerial --- 79,82 ---- *************** *** 114,119 **** // Data to send/receive: ! float x, y, z, rot; ! uint32 area_id; }; --- 99,109 ---- // Data to send/receive: ! bool on_ground; ! float speed; ! csVector3 position; ! csVector3 velocity; ! float yrot; ! float yrot_vel; ! CS_ID area_id; }; Index: ocpcserialize.cpp =================================================================== RCS file: /cvsroot/once/oncecode/src/common/ocpcserialize.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ocpcserialize.cpp 15 Nov 2004 07:18:05 -0000 1.5 --- ocpcserialize.cpp 20 Nov 2004 08:20:10 -0000 1.6 *************** *** 67,94 **** void ocPcLinearMovementData::Serialize(ocSerialBuffer& buf) { ! buf.WriteVector3(position); ! buf.WriteVector3(speed); ! buf.WriteFloat(yrot); ! buf.WriteFloat(yrot_vel); ! buf.WriteVector3(body); ! buf.WriteVector3(legs); ! buf.WriteVector3(cdshift); ! buf.WriteChar(init_cd); ! buf.WriteUInt32(area_id); } bool ocPcLinearMovementData::Deserialize(ocSerialBuffer& buf) { ! if (!buf.ReadVector3(position)) return false; ! if (!buf.ReadVector3(speed)) return false; ! if (!buf.ReadFloat(yrot)) return false; ! if (!buf.ReadFloat(yrot_vel)) return false; ! if (!buf.ReadVector3(body)) return false; ! if (!buf.ReadVector3(legs)) return false; ! if (!buf.ReadVector3(cdshift)) return false; ! if (!buf.ReadChar(init_cd)) return false; ! if (!buf.ReadUInt32(area_id)) return false; ! return true; } --- 67,100 ---- void ocPcLinearMovementData::Serialize(ocSerialBuffer& buf) { ! if(on_ground) ! buf.WriteChar('1'); ! else ! buf.WriteChar('0'); ! ! buf.WriteFloat(speed); ! buf.WriteVector3(position); ! buf.WriteVector3(velocity); ! buf.WriteFloat(yrot); ! buf.WriteFloat(yrot_vel); ! buf.WriteUInt32(area_id); } bool ocPcLinearMovementData::Deserialize(ocSerialBuffer& buf) { ! char _on_ground; ! if (!buf.ReadChar(_on_ground)) return false; ! if (_on_ground == 0) ! on_ground = false; ! else ! on_ground = true; ! ! if (!buf.ReadFloat(speed)) return false; ! if (!buf.ReadVector3(position)) return false; ! if (!buf.ReadVector3(velocity)) return false; ! if (!buf.ReadFloat(yrot)) return false; ! if (!buf.ReadFloat(yrot_vel)) return false; ! if (!buf.ReadUInt32(area_id)) return false; ! return true; } Index: ocplayeractionmsg.cpp =================================================================== RCS file: /cvsroot/once/oncecode/src/common/ocplayeractionmsg.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** ocplayeractionmsg.cpp 15 Nov 2004 07:18:05 -0000 1.10 --- ocplayeractionmsg.cpp 20 Nov 2004 08:20:10 -0000 1.11 *************** *** 92,120 **** - /***************************** ocRequestPosInit ******************************/ - int ocRequestPosInit::ocClassID = CLASSTYPE('P', 'o', 's', 'I'); - - iSerial* ocRequestPosInit::ocCreateInstance() - { - return new ocRequestPosInit; - } - - void ocRequestPosInit::Serialize(ocSerialBuffer &buf) - { - return; // There is no data to write - } - - bool ocRequestPosInit::Deserialize(ocRequestPosInit* me, ocSerialBuffer &buf) - { - return true; // There is no data to read, so it's always a success! - } - - int ocRequestPosInit::GetSerialType() const - { - return ocClassID; - } - - - /***************************** ocRequestPosUpdate ******************************/ int ocRequestSvrPosUpdate::ocClassID = CLASSTYPE('P', 'o', 'S', 'U'); --- 92,95 ---- *************** *** 127,139 **** uint32 ocRequestSvrPosUpdate::GetMessageLength() { ! return (uint32) (4*sizeof(float) + sizeof(uint32)); } void ocRequestSvrPosUpdate::Serialize(ocSerialBuffer &buf) { ! buf.WriteFloat(x); ! buf.WriteFloat(y); ! buf.WriteFloat(z); ! buf.WriteFloat(rot); buf.WriteUInt32(area_id); } --- 102,120 ---- uint32 ocRequestSvrPosUpdate::GetMessageLength() { ! return (uint32) (sizeof(char)+sizeof(float)*9+sizeof(uint32)); } void ocRequestSvrPosUpdate::Serialize(ocSerialBuffer &buf) { ! if(on_ground) ! buf.WriteChar('\1'); ! else ! buf.WriteChar('\0'); ! ! buf.WriteFloat(speed); ! buf.WriteVector3(position); ! buf.WriteVector3(velocity); ! buf.WriteFloat(yrot); ! buf.WriteFloat(yrot_vel); buf.WriteUInt32(area_id); } *************** *** 141,150 **** bool ocRequestSvrPosUpdate::Deserialize(ocRequestSvrPosUpdate* me, ocSerialBuffer &buf) { ! if(!buf.ReadFloat(me->x)) return false; ! if(!buf.ReadFloat(me->y)) return false; ! if(!buf.ReadFloat(me->z)) return false; ! if(!buf.ReadFloat(me->rot)) return false; ! if(!buf.ReadUInt32(me->area_id)) return false; return true; } --- 122,139 ---- bool ocRequestSvrPosUpdate::Deserialize(ocRequestSvrPosUpdate* me, ocSerialBuffer &buf) { ! char _on_ground; ! if (!buf.ReadChar(_on_ground)) return false; ! if (_on_ground == 0) ! me->on_ground = false; ! else ! me->on_ground = true; + if (!buf.ReadFloat(me->speed)) return false; + if (!buf.ReadVector3(me->position)) return false; + if (!buf.ReadVector3(me->velocity)) return false; + if (!buf.ReadFloat(me->yrot)) return false; + if (!buf.ReadFloat(me->yrot_vel)) return false; + if (!buf.ReadUInt32(me->area_id)) return false; + return true; } |