• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

Reading Local Terrain Mesh

Messages
25
Country
england
Hi all,

I'm one of those who rarely goes near the SDK but I'm willing to have a go if I can't find what I need elsewhere. So far I've drawn blanks on this so I'd appreciate any pointers?

I want to read the terrain mesh local to the aircraft (up to 80nm away) so I can map terrain threats on a Nav Display.

Trouble is I have no idea at all how to go about reading the data. Although I'm fluent in VB6 it's the BGL structure that beats me. Is there a tool out there that will return a table of mesh coords and altitudes if you give it a start point? Or perhaps someone could point me to a tutorial on how to quickly retrieve the local mesh info?

Thanks for any advice any of you can provide!

All the best

Ian
 
The only method I'm aware of is to use simconnect to create an AI object within FSX as the user plane flies around the landscape, move it to the lat/long you are interested in (typically relative to the position of the user aircraft), and read the AI object's ground elevation.

This technique is used in sim_probe (simconnect Visual C++) http://carrier.csi.cam.ac.uk/forsterlewis/soaring/sim/fsx/dev/sim_probe/ which actually places four probes on the landscape. The *source* of sim_probe is included in the package. The technical paper has a section describing the technique in more detail. The bulk of sim_probe is concerned with processing the elevation data it gets back, but hopefully you will be able to work out the basic message loop that picks up the elevations from the probes.

With 4 probes I have not been able to detect any framerate impact on FSX at all, but your requirement could need more samples and I have no idea when the processing would begin to impact FSX. The noob thing to do would be to sample the elevations every frame, but sim_probe uses a slower cycle - once per second I think - which is more than adequate for the application and reduces processing by a factor of 20 or more. It would also be a very inefficient approach to re-probe the same landscape many times within range of the user aircraft - you only need to probe the forward edges of the region in the direction of travel of the user aircraft, and update your internal data structure accordingly.

To sample the terrain in multiple places you can either create one AI probe and move it around during the sample cycle, or you can create many probes, move them all, and sample the ground elevation of each (sim_probe does the latter, and the former is really a simplification of that).

This work is *not* for the faint-hearted. You have to learn C++, the simconnect API, work our how to set up Visual Studio to compile and link the code, learn how to create and manipulate AI objects in simconnect particularly suspending the FSX control that would normally happen, and not least program for the situation where FSX 'culls' your AI object as a normal part of its optimization. You will almost certainly need a set of routines that calculate offsets and distances given a lat/long starting point and maybe a bearing. sim_probe does these things, including a 'heartbeat' that re-creates the AI objects when they've dropped off the map.

By the way if you want to include this data in a *gauge* you will need to create an executable that is *both* a simconnect client and a gauge dll. This is doable but if it's your first time you'd need to create a c++ gauge (or vb?) and get that working (using the panels/gauges SDK), create a c++ (or vb?) simconnect client and get that working (referring to the simconnect SDK), and then merge the two sets of code into a common source file. Even though you know VB, my advice would be to use C++, and *don't* used 'managed code'. Then you'll be able to take advantage of all the samples in the SDK's, and you won't be trying to get users to install the right version of .NET just to get your dopey gauge to run.

The good news is once you get the basic framework working, you can play around with how you process the elevation data that comes streaming back from around the aircraft, and that's actually quite entertaining.

Good luck,

B21
 
Thanks B21, must've taken ages to write all that - appreciate the help!

I'll investigate with trepidation!!

Many thanks again for taking the time to reply,

All the best

Ian
 
Back
Top