How to obtain custom simulation variables through CIGI?

Any issues, problems or troubleshooting topics related to the additional features present in the Prepar3D Professional Plus client application.
Post Reply
wesleylu
Posts: 8
Joined: Thu Aug 05, 2021 1:50 am

How to obtain custom simulation variables through CIGI?

Post by wesleylu »

Hi,

I have adapted a plug-in through SimpleAirplane Sample and currently have the custom simulation variables I need injected into Prepar3D.
I want to use CIGI to set the values of these variables to ultimately drive the animation.
I know that I need to use CigiArticulatedParts.xml to connect simulation variables and ArticulatedPartID in CIGI.
But how does PropertyGet and PropertySet behave? If I set a PropertySet, will it call SetElevator in my plugin?

The code in the plugin is:
pSimObjectMgr->RegisterProperty(CLSID_Airplane, TEXT("Elevator"), TEXT("percent over 100"), SimpleAirplane::SetElevator, EVENTTYPE_AXIS);
Clifton Crane
Lockheed Martin
Posts: 1207
Joined: Tue Sep 25, 2012 2:34 pm

Re: How to obtain custom simulation variables through CIGI?

Post by Clifton Crane »

Hi wesleylu,

Yes, the CigiArticulatedParts.xml file will bind the PropertySet and PropertyGet properties to the corresponding articulated part ID. On the Host, the PropertyGet function will be used. On the IG, the PropertySet function will be used. If PropertySet is not present, Prepar3D will attempt to use the PropertyGet as a setter, which is how our default SimVars are configured.

You can also configure a CigiArticulatedParts.xml for a specific SimObject, and do not need to modify the default file.

Here are a couple Learning Center articles that may help:

https://www.prepar3d.com/SDKv6/sdk/simu ... ml#general
https://www.prepar3d.com/SDKv6/prepar3d ... figuration

Regards,
Clifton
Clifton Crane
Prepar3D® Software Engineer Sr.
wesleylu
Posts: 8
Joined: Thu Aug 05, 2021 1:50 am

Re: How to obtain custom simulation variables through CIGI?

Post by wesleylu »

I still haven't succeeded,
I want to know how to modify the value of custom simulation variables.

In this example,
https://www.prepar3d.com/SDKv5/sdk/pdk_ ... Properties

//Sample registration of properties
pSimObjectMgr->RegisterProperty(CLSID_MySimObject, "MyDoubleProperty", "percent over 100", MySimObject::GetMyDoubleProperty);

//Sample PPropertyCallback function
/*static*/ STDMETHODIMP MySimObject::GetMyDoubleProperty(__in const ISimObject& Sim, __out double& dProperty, __in int iIndex)
{
dProperty = static_cast<const MySimObject&>(Sim).m_dMyDoublePropertyValue;

return S_OK;
}

It looks like I can only get data out of it, not set it.

In the SimpleAirplane example, it seems that data can be set through events. Will CIGI's PropertySet trigger events in the plug-in I wrote?
If so, which EVENTTYPE should I use?
Clifton Crane
Lockheed Martin
Posts: 1207
Joined: Tue Sep 25, 2012 2:34 pm

Re: How to obtain custom simulation variables through CIGI?

Post by Clifton Crane »

Hi wesleylu,

The Events section toward the bottom of the SimObject API Overview article shows how to define settable properties.

EVENTTYPE_NORMAL can be used to define a property that is settable. Properties can be set (or triggered) via the TriggerProperty call, a button or key press, or any other means for setting a Simulation Variable. Note that the callback prototype is slightly different.

Configuring a settable property in the CigiAritculatedParts.xml PropertySet field should trigger your callbacks when the articulated part packet is received by the IG.

Regards,
Clifton
Clifton Crane
Prepar3D® Software Engineer Sr.
wesleylu
Posts: 8
Joined: Thu Aug 05, 2021 1:50 am

Re: How to obtain custom simulation variables through CIGI?

Post by wesleylu »

Thanks, Clifton!
Sorry for not replying in time.

I currently wrote a custom machine model plug-in through the SimObject API,
In which I implemented custom data and its update logic.
This allows me to do everything I need.

Again, thanks!
Post Reply