[RESOLVED] Can you dynamically create waypoints in P3D

SDK supports Prepar3D’s philosophy of an open development architecture and encourages third parties to bring new innovations with improved add-ons and training content.
Locked
Barney_LM
Posts: 46
Joined: Tue Apr 03, 2018 10:49 am

[RESOLVED] Can you dynamically create waypoints in P3D

Post by Barney_LM »

Hello

I am just wondering if it is possible to dynamically create waypoints in P3D. Without having to access the flight planner menu option.

Basically I have a c++ console application which takes coordinates from another external application

I want my application to update a gps.xml with those coordinates and create two waypoints based on those coordinates.

Is this possible?

Regards,
Barney
User avatar
ronh991
Posts: 724
Joined: Sat Jan 19, 2013 1:46 am
Location: Ontario, Canada

Re: Can you dynamically create waypoints in P3D

Post by ronh991 »

Yes look at the waypoint example in the SDK. This is how I made my livingworld program.

Look in ver 3 of the SDK and the v4 only has a C# version.

See Reference samples AI Objects and Waypoints Managed AI Waypoints
Ron
Barney_LM
Posts: 46
Joined: Tue Apr 03, 2018 10:49 am

Re: Can you dynamically create waypoints in P3D

Post by Barney_LM »

Awesome!

Are there any tutorials on how to do this?

Regards,

Barney
Barney_LM
Posts: 46
Joined: Tue Apr 03, 2018 10:49 am

Re: Can you dynamically create waypoints in P3D

Post by Barney_LM »

And what is the.cs program called again?

Regards,
Barney
User avatar
ronh991
Posts: 724
Joined: Sat Jan 19, 2013 1:46 am
Location: Ontario, Canada

Re: Can you dynamically create waypoints in P3D

Post by ronh991 »

look at

Managed AI Waypoints

in the samples area of the SDK v4

tutorials: look at the SDK Simconnect API overview. It's right there ;-)
Ron
Barney_LM
Posts: 46
Joined: Tue Apr 03, 2018 10:49 am

Re: Can you dynamically create waypoints in P3D

Post by Barney_LM »

Awesome

I have followed these tutorials.

I have created the appropriate waypoint data and can connect to P3d and receive messages using SimConnect. I can get lat, lon and altitude of my aircraft as well as the destination of my waypoint.

However I am not sure which sim connect function I use in order to see the waypoints in my instance of P3d that is open.

Is it simConnect.SetDataOnSimObject? Or is there another function that I use?

Regards,
Barney
User avatar
ronh991
Posts: 724
Joined: Sat Jan 19, 2013 1:46 am
Location: Ontario, Canada

Re: Can you dynamically create waypoints in P3D

Post by ronh991 »

Don't follow ... you said you created the waypoints. Then list them out?
Ron
Barney_LM
Posts: 46
Joined: Tue Apr 03, 2018 10:49 am

Re: Can you dynamically create waypoints in P3D

Post by Barney_LM »

Yes I have created the data for the waypoints.

However when I run p3d and the c# application I created I cannot see the waypoints on my gps or flight planner

Regards,
Barney
Barney_LM
Posts: 46
Joined: Tue Apr 03, 2018 10:49 am

Re: Can you dynamically create waypoints in P3D

Post by Barney_LM »

In other words

I have created the waypoints for my own aircraft (not ai)

I have passed them to my aircraft.

However when I run p3d I cannot see my waypoints.

Code:

SIMCONNECT_DATA_WAYPOINT[] waypoints = new SIMCONNECT_DATA_WAYPOINT[2];

// vehicle pos
waypoints[0].Flags = (uint)SIMCONNECT_WAYPOINT_FLAGS.SPEED_REQUESTED;
waypoints[0].ktsSpeed = 100;
waypoints[0].Latitude = s1.latitude;
waypoints[0].Longitude = s1.longitude;
waypoints[0].Altitude = s1.altitude;

// destination pos
waypoints[1].Flags = (uint)SIMCONNECT_WAYPOINT_FLAGS.SPEED_REQUESTED;
waypoints[1].ktsSpeed = 100;
waypoints[1].Latitude = 50.95;
waypoints[1].Longitude = 1.35;
waypoints[1].Altitude = s1.altitude;



Object[] objv = new Object[waypoints.Length];
waypoints.CopyTo(objv, 0);




simConnect.AddToDataDefinition(DEFINITIONS.Struct1, "AI WAYPOINT LIST", "number", SIMCONNECT_DATATYPE.WAYPOINT, 0.0f, SimConnect.SIMCONNECT_UNUSED);
simConnect.SetDataOnSimObject(DEFINITIONS.Struct1, dwRequestID, SIMCONNECT_DATA_SET_FLAG.DEFAULT, objv);


Regards,
User avatar
ronh991
Posts: 724
Joined: Sat Jan 19, 2013 1:46 am
Location: Ontario, Canada

Re: Can you dynamically create waypoints in P3D

Post by ronh991 »

So I misunderstood what your ultimate goal was. Creating waypoints is more for AI than the user aircraft. I would create a FlightPlan and do a loadflightplan. Create a template flightplan, and use that to dynamically add the waypoints. But that the same functionality as the flight planner in P3D.

You can even add/load a flightplan to an AI and have them follow it.
Ron
Barney_LM
Posts: 46
Joined: Tue Apr 03, 2018 10:49 am

Re: Can you dynamically create waypoints in P3D

Post by Barney_LM »

Awesome! Thank you!
Barney_LM
Posts: 46
Joined: Tue Apr 03, 2018 10:49 am

Re: Can you dynamically create waypoints in P3D

Post by Barney_LM »

It was more about me creating a flight plan dynamically which I could then see on the gps. My bad!
Locked