Hello
I want to use the CIGI.
Is the following method suitable?
[Usage of IG function]
Host:Existing simulator(sender)
Client:Prepare3D IG(reciver)
[Software]
Host: Send program(.exe) is created by SimConnect API.
Client:Recive and Update program(.dll) is created by SimObject API.
The dll is added to Prepare3D.
[Send program]
I use SimConnect_SetDataOnSimObject function to send position and attitude to Prepare3D.
[Recive program]
I call GetCigiService function of PdkServices class, and I can get ICigiServiceV430 class pointer.
I call RegisterCigiPacketCallBack function, and I register ICigiPacketCallbackV440 as argument.
Thus, I create new class thatinherits from ICigiPacketCallbackV440.
This new class has overrided OnRecive function.
OnRecive function call GetSimObjectManager function of PdkServices class, and I can get ISimObjectManagerV440 class pointer.
I can get IBaseObjectV400 class pointer when I call GetObject function of ISimObjectManagerV440 class.
I call SetPosition function of IBaseObjectV400 class for update position and attitude on prepare3D.
Best Regards
How to create CIGI App
-
- Posts: 1
- Joined: Tue Jan 26, 2021 7:29 am
Re: How to create CIGI App
Thanks for sharing such great information, I highly appreciate your hard-working skills as the post you published have some great information which is quite beneficial for me, I hope you will post more like that in the future
Re: How to create CIGI App
Thank you for reply!
Sorry. I'm late to update my post.
After posting, I looked up SimConnet.
In fact, I knew it easier to achieve.
Our existing simulator sends the position and attitude by UDP.
I created a sample program that received a UDP packet and reflects position in P3D.
The sample program is made with SimConnect. It was easy to create based on "OpenAndClose" SDK sample.
[After calling SimConnect_Open]
SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_PLANE_LATITUDE, "PLANE LATITUDE", "degrees", SIMCONNECT_DATATYPE_FLOAT64);
SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_PLANE_LONGITUDE, "PLANE LONGITUDE", "degrees", SIMCONNECT_DATATYPE_FLOAT64);
SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_PLANE_ALTITUDE, "PLANE ALTITUDE", "meters", SIMCONNECT_DATATYPE_FLOAT64);
SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_PLANE_PITCH_DEGREES, "PLANE PITCH DEGREES", "degrees", SIMCONNECT_DATATYPE_FLOAT64);
SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_PLANE_BANK_DEGREES, "PLANE BANK DEGREES", "degrees", SIMCONNECT_DATATYPE_FLOAT64);
The second argument is just a number.
The ID can be freely assigned to associate with the variable.
enum DATA_DEFINE_ID {
DEFINITION_PLANE_LATITUDE,
DEFINITION_PLANE_LONGITUDE,
DEFINITION_PLANE_ALTITUDE,
DEFINITION_PLANE_PITCH_DEGREES,
DEFINITION_PLANE_BANK_DEGREES,
DEFINITION_PLANE_HEADING_DEGREES_TRUE
}
The third argument is the variable name.
I'm beginner. Initially, I didn't know what variables P3D had.
The variable is the following URL.
http://www.prepar3d.com/SDKv5/sdk/refer ... rview.html
[Periodic processing]
I called it while receiving UDP packets, but can call on timer.
Recive process was realized in asio of C++ boost liblary.
double latitude, longitude, altitude; // UDP packet content
double pitch, roll, yaw; // UDP packet content
SimConnect_SetDataOnSimObject(hSimConnect, DEFINITION_PLANE_LATITUDE, SIMCONNECT_OBJECT_ID_USER, 0, 0, sizeof(double), &latitude);
SimConnect_SetDataOnSimObject(hSimConnect, DEFINITION_PLANE_LONGITUDE, SIMCONNECT_OBJECT_ID_USER, 0, 0, sizeof(double), &longitude);
SimConnect_SetDataOnSimObject(hSimConnect, DEFINITION_PLANE_ALTITUDE, SIMCONNECT_OBJECT_ID_USER, 0, 0, sizeof(double), &altitude);
SimConnect_SetDataOnSimObject(hSimConnect, DEFINITION_PLANE_PITCH_DEGREES, SIMCONNECT_OBJECT_ID_USER, 0, 0, sizeof(double), &pitch);
SimConnect_SetDataOnSimObject(hSimConnect, DEFINITION_PLANE_BANK_DEGREES, SIMCONNECT_OBJECT_ID_USER, 0, 0, sizeof(double), &roll);
SimConnect_SetDataOnSimObject(hSimConnect, DEFINITION_PLANE_HEADING_DEGREES_TRUE, SIMCONNECT_OBJECT_ID_USER, 0, 0, sizeof(double), &yaw);
It's important to note that P3D is still accepting input.
Therefore, I set "IS POSITION FREEZE ON" to 1.
int posFreezeOn = 1;
SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_POSITION_FREEZE_ON, "IS POSITION FREEZE ON", NULL, SIMCONNECT_DATATYPE_INT32);
SimConnect_SetDataOnSimObject( hSimConnect, DEFINITION_POSITION_FREEZE_ON, SIMCONNECT_OBJECT_ID_USER, 0, 0, sizeof(int), &posFreezeOn);
As an aside, I set "GEAR POSITION:*" after the flight.
I just controlled the aircraft and couldn't use the true CIGI function.
But, I'm happy. I understand P3D a little.
I hope to learn knowledge from everyone.
Thanks.
Sorry. I'm late to update my post.
After posting, I looked up SimConnet.
In fact, I knew it easier to achieve.
Our existing simulator sends the position and attitude by UDP.
I created a sample program that received a UDP packet and reflects position in P3D.
The sample program is made with SimConnect. It was easy to create based on "OpenAndClose" SDK sample.
[After calling SimConnect_Open]
SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_PLANE_LATITUDE, "PLANE LATITUDE", "degrees", SIMCONNECT_DATATYPE_FLOAT64);
SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_PLANE_LONGITUDE, "PLANE LONGITUDE", "degrees", SIMCONNECT_DATATYPE_FLOAT64);
SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_PLANE_ALTITUDE, "PLANE ALTITUDE", "meters", SIMCONNECT_DATATYPE_FLOAT64);
SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_PLANE_PITCH_DEGREES, "PLANE PITCH DEGREES", "degrees", SIMCONNECT_DATATYPE_FLOAT64);
SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_PLANE_BANK_DEGREES, "PLANE BANK DEGREES", "degrees", SIMCONNECT_DATATYPE_FLOAT64);
The second argument is just a number.
The ID can be freely assigned to associate with the variable.
enum DATA_DEFINE_ID {
DEFINITION_PLANE_LATITUDE,
DEFINITION_PLANE_LONGITUDE,
DEFINITION_PLANE_ALTITUDE,
DEFINITION_PLANE_PITCH_DEGREES,
DEFINITION_PLANE_BANK_DEGREES,
DEFINITION_PLANE_HEADING_DEGREES_TRUE
}
The third argument is the variable name.
I'm beginner. Initially, I didn't know what variables P3D had.
The variable is the following URL.
http://www.prepar3d.com/SDKv5/sdk/refer ... rview.html
[Periodic processing]
I called it while receiving UDP packets, but can call on timer.
Recive process was realized in asio of C++ boost liblary.
double latitude, longitude, altitude; // UDP packet content
double pitch, roll, yaw; // UDP packet content
SimConnect_SetDataOnSimObject(hSimConnect, DEFINITION_PLANE_LATITUDE, SIMCONNECT_OBJECT_ID_USER, 0, 0, sizeof(double), &latitude);
SimConnect_SetDataOnSimObject(hSimConnect, DEFINITION_PLANE_LONGITUDE, SIMCONNECT_OBJECT_ID_USER, 0, 0, sizeof(double), &longitude);
SimConnect_SetDataOnSimObject(hSimConnect, DEFINITION_PLANE_ALTITUDE, SIMCONNECT_OBJECT_ID_USER, 0, 0, sizeof(double), &altitude);
SimConnect_SetDataOnSimObject(hSimConnect, DEFINITION_PLANE_PITCH_DEGREES, SIMCONNECT_OBJECT_ID_USER, 0, 0, sizeof(double), &pitch);
SimConnect_SetDataOnSimObject(hSimConnect, DEFINITION_PLANE_BANK_DEGREES, SIMCONNECT_OBJECT_ID_USER, 0, 0, sizeof(double), &roll);
SimConnect_SetDataOnSimObject(hSimConnect, DEFINITION_PLANE_HEADING_DEGREES_TRUE, SIMCONNECT_OBJECT_ID_USER, 0, 0, sizeof(double), &yaw);
It's important to note that P3D is still accepting input.
Therefore, I set "IS POSITION FREEZE ON" to 1.
int posFreezeOn = 1;
SimConnect_AddToDataDefinition(hSimConnect, DEFINITION_POSITION_FREEZE_ON, "IS POSITION FREEZE ON", NULL, SIMCONNECT_DATATYPE_INT32);
SimConnect_SetDataOnSimObject( hSimConnect, DEFINITION_POSITION_FREEZE_ON, SIMCONNECT_OBJECT_ID_USER, 0, 0, sizeof(int), &posFreezeOn);
As an aside, I set "GEAR POSITION:*" after the flight.
I just controlled the aircraft and couldn't use the true CIGI function.
But, I'm happy. I understand P3D a little.
I hope to learn knowledge from everyone.
Thanks.
-
- Posts: 151
- Joined: Mon Jun 12, 2017 6:14 pm
Re: How to create CIGI App
I just wanted to say "thanks" for the very detailed and clearly written post!
All comments and opinions are my own.