Jump to content

Adding component "EntityComponent" at runtime?


photo

Recommended Posts

Hello,

I'm dynamically loading an FBX at runtime in C++ and I'm trying to assign it the EntityComponent property. But I can't find the header where EntityComponent is defined. My goal is to be able to define an entity shape and material at Runtime and control it through standard CIGI.

  • How do I make ComponentSystem::get()->addComponent<EntityComponent>(imported_node); to compile ?
  • Is this the correct way to do what I'm trying to achieve? (specifying an entity at runtime)
  • How would I set the CIGI ID and Type ID for this entity at runtime?

Thanks!

Link to comment

Hello! 

The classic way is to describe this entity type in ig_config.xml and load the node via IG - so that it correctly initializes all parameters as usual entity. Why is this method not suitable? these FBXs weren't prepared as an .node?

 

EntityComponent is needed to set prespawned entities in the editor - after loading the world, IG considers this node to be its entity. In this case, it will no longer be possible to change the type - because specific model is used.

but you can try adding EntityComponent at runtime.

int prop_index = node->addProperty("EntityComponent");
auto prop_param = node->getProperty(prop_index)->getParameterPtr();
prop_param->getChild("entity_id")->setValueInt(123); 
prop_param->getChild("type_id")->setValueString("200"); // for load defenitions ArticulatedParts и Components

 

Link to comment
prop_param->getChild("entity_id")->setValueInt(123); 

The line above does actually create an entity with this ID, I can move it with CIGI correctly. But strangely it isn't listed in the syncker debug window with the postfix "( id: XX type: YY)".

 

prop_param->getChild("type_id")->setValueString("200"); 

The line above does not create the type id; the entity is marked with the type id "0 (unknown type)", but it correctly shows the mesh I loaded. Is it the expected behavior?

As I tried to explain, I'm trying to create an entity from an FBX which cannot be defined in the Editor or in ig_config_xml as usual, because it come from an external source which generate it on-demand.

 

But at least now I can control it with CIGI so thanks!

Edited by Amerio.Stephane
Link to comment
×
×
  • Create New...