Jump to content

[SOLVED] Support for custom/not official DIS PDUs


photo

Recommended Posts

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

  • Like 1
Link to comment
  • morbid changed the title to [SOLVED] Support for custom/not official DIS PDUs
×
×
  • Create New...