ivan.cuevas Posted June 20, 2019 Share Posted June 20, 2019 Hi all, Very similar to this topic, I want to known if it's possible to create and process custom packets, in this case for DIS using the IG Template. Thanks. Link to comment
alexander Posted June 20, 2019 Share Posted June 20, 2019 Hi Ivan, First of all, you need to download KDIS 2.9.0 from here: https://sourceforge.net/projects/kdis/files/ Add additional include directory in your project to the KDIS/include/ folder. Then you can use this: #include <PDU/Header.h> #include <DataTypes/EntityType.h> #include <PDU/Entity_Info_Interaction/Entity_State_PDU.h> // ... int AppWorldLogic::init() { // .... int index = Engine::get()->findPlugin("DISConnector"); // check DISConnector plugin load if (index != -1) { // getting the DIS interface dis = (IG::DIS::ConnectorInterface*)Engine::get()->getPluginData(index); // adding a callback for all packets dis->setCallbackOnRecvPacket(MakeCallback(this, &AppWorldLogic::on_recv_packet)); } return 1; } // .... void AppWorldLogic::on_recv_packet(KDIS::PDU::Header *pdu) { if (pdu->GetPDUType() == KDIS::DATA_TYPE::ENUMS::Entity_State_PDU_Type) { KDIS::PDU::Entity_State_PDU *entity_state_pdu = static_cast<KDIS::PDU::Entity_State_PDU *>(pdu); auto location = entity_state_pdu->GetEntityLocation(); auto linear_velocity = entity_state_pdu->GetEntityLinearVelocity(); auto appearance = entity_state_pdu->GetEntityAppearance(); // ... } else if (pdu->GetPDUType() == KDIS::DATA_TYPE::ENUMS::Other_PDU_Type) { // ... } } Best regards, Alexander 1 Link to comment
ivan.cuevas Posted June 20, 2019 Author Share Posted June 20, 2019 Many thanks @alexander. Link to comment
Recommended Posts