IG::ComponentBaseInterface and Unigine::ComponentBase


photo

Recommended Posts

Hi,

Related to support ticket of S.Amerio 003737: Strong Stuttering (2.12b+last patch) and component system.

With 2.12 patch, there is kind of warning I don't know how to fix: 

Component::setNodeProperty: cant find component RotorComponent on node rotor_main(1967616924) (you need inherit you component from 'ComponentBaseInterface')
Component::setNodeProperty: cant find component RotorComponent on node rotor_tail(1775036688) (you need inherit you component from 'ComponentBaseInterface')
Component::setNodeProperty: cant find component RotorwashComponent on node rotorwash(346689259) (you need inherit you component from 'ComponentBaseInterface')
Component::setNodeProperty: cant find component SlingRope on node sling_rope(1033778571) (you need inherit you component from 'ComponentBaseInterface')
Component::setNodeProperty: cant find component CamerasComponent on node cameras(1021862997) (you need inherit you component from 'ComponentBaseInterface')
Component::setNodeProperty: cant find component LandingGearComponent on node landing_gear_nose(1290253031) (you need inherit you component from 'ComponentBaseInterface')
Component::setNodeProperty: cant find component LandingGearComponent on node landing_gear_left(1892212613) (you need inherit you component from 'ComponentBaseInterface')
Component::setNodeProperty: cant find component LandingGearComponent on node landing_gear_right(1983186188) (you need inherit you component from 'ComponentBaseInterface')

Entity (helicopter) is still loading properly, all components (declared in IG_config.xml) are CIGI accessible.

    <entity id="160" name="h160">
      <path>shared_entities/platform/air/hc/h160_sling-camera/h160.node</path>
      <component id="161" name="cameras">
        <property>CamerasComponent</property>
        <node>cameras</node>
      </component>
      <component id="34" name="rotor_main">
        <property>RotorComponent</property>
        <node>dynamic/rotor_main</node>
        <parameter name="data1" type="int">rpm</parameter>
        <parameter name="data2" type="int">propagate</parameter>
      </component>
      <component id="35" name="rotor_tail">
        <property>RotorComponent</property>
        <node>dynamic/rotor_tail</node>
        <parameter name="data1" type="int">rpm</parameter>
        <parameter name="data2" type="int">propagate</parameter>
      </component>
      <component id="37" name="rotorwash">
        <property>RotorwashComponent</property>
        <node>rotorwash</node>
        <parameter name="data1" type="int">wind_percent</parameter>
        <parameter name="data2" type="int">sand_percent</parameter>
        <parameter name="data3" type="int">height_threshold</parameter>
      </component>
      <component id="200" name="landing_gear_nose">
        <property>LandingGearComponent</property>
        <node>dynamic/landing_gear_nose</node>
        <parameter name="data1" type="int">extension_percent</parameter>
        <parameter name="data2" type="int">propagate</parameter>
      </component>
      <component id="201" name="landing_gear_left">
        <property>LandingGearComponent</property>
        <node>dynamic/landing_gear_left</node>
        <parameter name="data1" type="int">extension_percent</parameter>
        <parameter name="data2" type="int">propagate</parameter>
      </component>
      <component id="202" name="landing_gear_right">
        <property>LandingGearComponent</property>
        <node>dynamic/landing_gear_right</node>
        <parameter name="data1" type="int">extension_percent</parameter>
        <parameter name="data2" type="int">propagate</parameter>
      </component>
      <component id="40" name="sling">
        <property>SlingRope</property>
        <node>ADE/dynamic/sling_rope</node>
        <parameter name="data1" type="float">rope_length</parameter>
        <parameter name="data2" type="float">segment_mass</parameter>
        <parameter name="data3" type="float">bag_mass</parameter>
      </component>
    </entity>

But.. is there a way to get rid of the warning?
E.g. how should I  use / implement Unigine::Plugins::IG::ComponentBaseInterface whith components that are not necessary related to IG..?

class CamerasComponent :
	public Unigine::ComponentBase
{
public:
	COMPONENT(CamerasComponent, Unigine::ComponentBase);
	[...]

Kind regards,
Charles

Link to post

Hello! 
you need inherit you components from ComponentBaseInterface for work in IG.

class CamerasComponent :
	public Unigine::ComponentBase, public Unigine::Plugins::IG::ComponentBaseInterface
{
public:
	COMPONENT(CamerasComponent, Unigine::ComponentBase);
	[...]

also you can override methods

virtual void saveState(const Unigine::BlobPtr &blob) 
virtual void restoreState(const Unigine::BlobPtr &blob) 

for synchroinization between synckers channels

Link to post

Hi,

Thanks, quick fixed!

This is what I tried.. believing that public inheritance declaration is distributive...
Should really learn one day bit more C++ :-o

class CamerasComponent :
	public Unigine::ComponentBase, Unigine::Plugins::IG::ComponentBaseInterface
{
public:
	COMPONENT(CamerasComponent, Unigine::ComponentBase);
	[...]

So, that I do understand right the point of

	class ComponentBaseInterface
	{
	public:
		virtual ~ComponentBaseInterface() {}

		virtual void saveState(const Unigine::BlobPtr &blob) { UNIGINE_UNUSED(blob); };
		virtual void restoreState(const Unigine::BlobPtr &blob) { UNIGINE_UNUSED(blob); };
	};

It aims:
- master (with CIGI plugin) load an entity
- slaves, through syncker, load as well same entity type but its components can be synchronized with master ones with save/restore state meth
... right?

Kind regards,
Charles

Link to post
On 10/7/2020 at 7:10 PM, Lales.Charles said:

It aims:
- master (with CIGI plugin) load an entity
- slaves, through syncker, load as well same entity type but its components can be synchronized with master ones with save/restore state meth
... right?

You need override these are methods for saving / restoring the state of the component, in the case when extraslave is connected.

When extraslave is connected IG collects all the current state and sends it to it.  If you do not use extraslays you can ignore these methods

Link to post