Jump to content

[SOLVED] IG GetEntityType for DIS unexpected behavior


photo

Recommended Posts

Hi.

 

We are trying to load some test entities using the ig_config.xml file. Our client side builds an EntityStatePDU and sends it without issues and our server side is receiving it fine too.

Our code looks like this:

void OnEntityStatePDUrcv(KDIS::PDU::Entity_State_PDU* pdu){
  
  int64_t entityType = GetInternalEntityType(pdu->GetEntityType());
  
  // We also tried forcing the value, like this:
  // DATA_TYPE::EntityType testType = DATA_TYPE::EntityType(1, 2, 222, 4, 14, 0, 0);
  // int64_t entityType = GetInternalEntityType(testType);
  
  // >> Different values every time we run the app here...
  Log::message("EntityType value: %lld\n", entityType);
  
  
  // ... //
  
  if(entity->GetType()  != entityType) {
    entity->setType(entityType);
  }
  
}

int64_t GetInternalEntityType(DATA_TYPE::EntityType& t) {
  // IG::ManagerInterface pointer
  return _igManager->getEntityType(t.GetEntityKind(),
                                   t.GetDomain(),
                                   t.GetCountry(),
                                   t.GetCategory(),
                                   t.GetSubCategory(),
                                   t.GetSpecific(),
                                   t.GetExtra());
}

 

At the moment, our ig_config file looks like this: (As found in this message) 

<entity_types>
  <entity name="testcube" id="1.2.222.4.14.0.0">
    <path>ig/entities/e_test/testcube.node</path>
  </entity>
  
  <entity name="lcm1e" id= "1.3.222.5.17.0.0">
    <path>assets/lcm1e/lcm1e.node</path>
  </entity>
  <!-- == more entities == -->
</entity_types>

 

Our problem is, every time we launch the application, the value returned by the function 'getEntityType' is different, and we don't know how to correctly set the entityType to the entity for the mesh to show.

The call to 'entity->setEntity(entityType)' doesn't show anything on our application.

We also double-checked all the .node files that are being used and all are ok.

 

Any insight on what could be the problem? 

 

PD: We tried substituting the id with a single number and tried to load it directly, and then the setEntity is working as it should (model shows correctly on screen).

Using Unigine 2.9.0.2, btw.

 

 

 

Link to comment

Hi.

We are using the source you provided us in this ticket:

https://developer.unigine.com/en/personal/support-ticket/2174

We didn't change the plugin; simply compiled it agains't our custom KDIS library.

 

The IG Interface is the one on the version 2.9.0.2.

 

Here is an updated version of the code, with a more precise location of the problem:

{
  // Forced value for testing purposes
  KDIS::DATA_TYPE::EntityType t = KDIS::DATA_TYPE::EntityType(1, 3, 222, 5, 17, 0, 0);
  
  // EntityStatePDUrcv callback
  int64_t entityType = FindEntityType("lcm1e");
  int64_t entityType2 = GetInternalEntityType(t);
  
  Log::message("Find value: %lld\tgetEntityType value: %lld\n", entityType, entityType2);
  
  // << entityType shows correct model.
  // << entityType2 DOES NOT show model (does nothing).
  if(entity->GetType() != entityType2) {
    entity->SetType(entityType2);
  }
  
}

// Functions are just our wrappers for the IG ManagerInterface

int64_t FindEntityType(const char* name) {
  _igManager->findEntityType(name);
}

int64_t GetInternalEntityType(KDIS::DATA_TYPE::EntityType& type) {
  return _igManager->getEntityType(type.GetEntityKind(),
                                   type.GetDomain(),
                                   type.GetCountry(),
                                   type.GetCategory(),
                                   type.GetSubCategory(),
                                   type.GetSpecific(),
                                   type.GetExtra());
}

The ig_config file remains the same:

<entity_types>
  <entity name="testcube" id="1.2.222.4.14.0.0">
    <path>ig/entities/e_test/testcube.node</path>
  </entity>
  
  <entity name="lcm1e" id="1.3.222.5.17.0.0">
    <path>assets/lcm1e/lcm1e.node</path>
  </entity>
  <!-- == more entities == -->
</entity_types>

 

And this is the log output:

d4a2383955316f55a6ae7a1cbaf0787d.png.876fd474360710a9723596d87677cc9d.png

c1439826b24521f0e3bf16693ec93775.png.a8b05a4964ea7762cadc03c051f5c3be.png

69b61fd1fb2c3be53b571419839c4ab8.png.097d05d202472b81ee03f447f1d743fa.png

 

Especial mention to the getEntityType value that it changes with each run of the program.

 

 

Link to comment
  • morbid changed the title to [SOLVED] IG GetEntityType for DIS unexpected behavior
×
×
  • Create New...