Using FSMesh to generate high resolution mesh scenery.

FS2000 has changed the structure of the FS terrain completely compared to the previous versions. Instead of flat tiles, which can carry three dimensional objects, a mesh of three dimensional points was introduced. Comparing to a model railway its as if FS1 to FS98 is built on a flat board while FS2000, and the later versions, is built free in three dimensional space.

This has made all addons and tools for FS5 to FS98 obsolete. If it is base scenery, there is no way to update or patch it - it has to be built completely new. This became clear rather quickly. To ease the transition Microsoft gave the "flatten" instruction that allows to make parts of the scenery as flat as a stamp. This is of course a complete backward move but it does allow you to place old 3D-Objects, airports, buildings, 3D-mountains, and FS98 type mesh onto these plains. Most addons you can buy today use this technique and use FS2000 as nothing more than a slow FS98 emulator which can use 16 bit textures.

It became clear quite quickly that the new mesh does not use the instructions available in FS98 (TexRelief). It is also widely unknown which files contain the mesh data and how they are organized. I think that the files under scenedb\world\scenery contain the mesh. No tool exists to read or modify these files. Microsoft told us that a 1 km resolution was used for the default mesh. Knowing that the only free data covering all the world has a resolution of 30 arc seconds (900 m) it is very likely that this data has been used. While this may be good for the bulk of scenery there are areas were a much higher terrain resolution is required. The consequences of the low resolution are rather small slopes, which makes tunnels very difficult, and narrow steep valleys that just look wrong with the coarse mesh. Look at the Rhine River. It has already been shown that the way Microsoft used this data is not the optimal one much better results can be obtained.

The first months of 2000 passed with trials on what can be done with flattening. Some modifications of the terrain could be done using elevation polygons.

Biggest problem often is the coarse resolution of the mesh. There is a lot of space between two points that are 900m apart; a steep rock or a deep valley can be in between. Long deep valleys are a special problem as you'll see if you look in FS2000 at the Rhine or the Nile. With steep borders, mesh points are randomly down or up and the surface in between must jump widely. A 1 km mesh can only form objects of larger dimensions, like 5 km. This small fraction of a FSMesh screen, a part of the Rhine valley, shows the root of the problem. You see the mesh points of the 30 sec mesh, the altitude is coded in the colors. Blue is below 100m, brown-green above 400. You see the blue line of the river but any extrapolation of these few points cannot form a proper valley - the result will be hills with lakes in between. This is not the result of a bad product but just the limitation of the data.

The situation changed in summer 2000 when Microsoft published the Terrain SDK. Those who hoped for information on how to read the mesh data were disappointed. The SDK contains four small programs and a manual on how to use them. The following assumes that you have downloaded these tools. Users of FSRail or FSMesh should copy them to the ..\terrain directory. The following table describes the four programs. For more details I'm afraid you'll have to read the SDK tutorial.

Program Input file Output file Function
resample.exe DEM file

INF file

TMF file A DEM, descibed in the INF file, is read and converted into TMF Format. The resolution is fixed by the parameter LOD in the INF file.
tmfcompress.exe TMF file TMF file A TMF file is compressed. I think that neighboring mesh fields of same orientation are combined.
tmfmerge.exe several TMF files TMF file Merges several TMF files to one new. Not used by me up to now.
tmf2bgl.exe TMF file BGL file A BGL header is placed in front of the TMF file - FS2000 can use this file.
Explanation: DEM means Digital Elevation Map and is an array of altitude points on a fixed grid. TMF is a Terrain Mesh File, similar to a DEM with additional information plus the option to be compressed. Do any of you know the format of TMF files?

This table is taken from the SDK and shows the meaning of the parameter LOD. By increasing LOD by 1 the CPU load and memory usage go up a factor of 4 if compression cannot reduce the size again.

Mesh scenery is produced the following way:

Having got these tools all we need is a DEM. Higher resolution mesh data (typically 5 arc seconds) is available free for only a small part of the world. The sceneries obtained from them with the Terrain SDK from Microsoft show a clear improvement and show that the new terrain engine is powerful - provided your system is powerful enough and you have enough memory. What to do with the rest of the world?

The approach described here is intended to give a very high resolution mesh scenery for small areas of special interest like a valley or the area along a railway line, or to combine information from different sources.

High resolution geographical information is available on topographical maps which often can be found a in digital form. For Germany the most suitable digital maps (TOP 50) are in the scale 1:50000 where 1 km is 2 cm on the screen. Since, typically, 50 pixels belong to a cm on screen the resolution of these maps is 20m or about 1 arc second. Lines of equal altitude have a 1 or 2 pixel width so the information on these maps is comparable to a 2 arc seconds DEM.

So a way to transport the altitude information from such a map to a DEM is the only missing item to start real world scenery design. A tool that can transport data from a bitmap to scenery design has been in FSRail from the beginning and is called Markers. Markers are identified by coordinates and colors. So some new FSRail-language objects were invented called trigonometrical points. Trigonometrical points are identified by their coordinates and altitude. So the bitmap interface was extended to produce optional markers or trigonometrical points and a routine written that interpolates a DEM from this list of trigonometrical points. When the DEM is written an INF file is created with the exact information. Then you just start the SDK tools and - bingo - the terrain is were you clicked it to be.

The first try was already surprising. In this example the river shore was located with blue markers. Along the river trigonometrical points of 67 m height were placed, I added the characteristic 200 m line, some tops of mountains, generated a 256x256 mesh, repainted the polygons of the river, excluded the MS scenery - ready. A few hours of work after many hours of programming. A much bigger example with moving trains following the river can be downloaded from www.fsrail.com .

Some hints:

To get an area exactly flat place a dense line of trigonometrical points arround it. They should be less distance apart than the next line of equal altitude. A high DEM resolution only makes sense if a lot of information is available.

 

The current version of FSMesh can create DEMs of up to 2048x2048. Some new features could be added, one of them the import of USGS DEMs. Even if 30 seconds are not enough for many places this forms already a base relief which can be improved in the most important places.

So, how do you use it?

First, copy the three programs from the Terrain SDK: resample.exe, tmfcompress.exe, tmf2bgl.exe into the menu ..\terrain. Edit the file Terrainmaker.bat to copy the bgl file to your location in FS2000. NOTE: It seems you always have to leave FS2000 before you can change any terrain file. With self-made terrain files I often found FS2K crashed while reloading scenery, independent of the source of the DEM. There are rumors that a proper choice of the the area priority can cure this.

Working with FSMesh

In the following I section I will describe how a scenery with a volcanic lake can be made using FSMesh. The example is the "Laacher See" in Germany.

We need the following materials:

When unpacking the DEM please make sure it really has a size of exactly 57600000 bytes.

We copy the USGS files to the ..\terrain folder. We make a screen shot of the map as a bitmap and cut away the borders. Here you see a scaled down example. We write down the coordinates of the four borders. Map software has the advantage of showing them when moving the mouse. In our example the borders are:
North 50:25:46
South 50:23:26
West 07:13:51
East 07:19:05
It is my experience that a scenery always has to be created larger to be shown completely. To be safe we make a border of 5 minutes. This can only cause damage if another high resolution mesh is nearby; the borders prepared from the UGS DEM cannot be worse than the scenery from the CD.

We start FSMesh and create a new scenery with the following coordinates:

Only a visit to the location in FS2000 can answer the question of whether we want to keep the objects of the MS scenery. We find a lake there, with more or less the right shape, perched on top of the mountains - so we keep it.

Next we select "Import trig" "USGS DEM", a dialog lets us select the file W020N90.dem. Now W020N90.dem and W020N90.hdr are read and all points, that are inside the limits of the scenery, are read. This will take some seconds. The result is a mesh of trigonometrical points with 30 seconds distance. This step gives us a terrain for all the area that is no worse than the original one and with smooth transitions to the CD terrain. By the way the blue band at the top right is the Rhine River.
In the third step we call "Map commands" "Load Bitmap", search for the bitmap we produced above and enter its coordinates. Now bitmap and scenery are aligned with a precison of 1 second. We see the bitmap as a background image.
Under "Mesh" "Altitude value" you enter the altitude of the following points you want to place - 275.00 m in our example. If you only have it in feet then check the box and FSMesh does the calculation for you.
Now we follow with the mouse alongside the lake shore and place trigonometrical points with quite dense clicking. When we are completely round the lake we click with the right mouse button so we can see the result better. If we've left holes we can fill them now with more leftclicks. Within the lake there are 5 USGS DEM points. We click on each of them with the right mouse button and change them to 275.00. If the border points are in doubt we can change or delete them.
We now open the bitmap again, set the altitude value to 300 and follow the lines of that altitude. Now we've already defined the flat and steep shore parts. The 400 m lines define the higher hills around. We get the tops of the hills from the map and place them properly with their altitude value and maybe enter some other characteristic lines. The more contours we take the better the result but we've already done enough now for a beginning. We select "Mesh" "Create FS DEM" and let it place a DEM of 1024x1024 points over the scenery, save the DEM and accept the value of LOD. Do not forget to save the scenery before leaving the program,
Using the SDK tools we obtain our first scenery. Now the lake is surrounded by hills, as expected. The narrow peak in the foreground is based on one USGS DEM point that was wrong. More trigonometrical points will improve the result but that experiment is left to you now.

Now you have learned how to create a terrain with FSMesh. If you have access to the DHM-100 data you can also import them. If you have ideas for other data formats to import I am happy to implement the filters.

When importing from different sources points may get defined twice. Since it seems that neighbouring sceneries should overlap you will most likely import trigonometrical points from neighbouring sceneries. A sorting function in the "Mesh" menu can remove the first of two mesh points that are less than 30 cm apart.

A rare candy: DEM created with FSMesh can be read back into the program. So, after creating a DEM, FSMesh knows the altitude values of the terrain and displays them in the lower status lines. When placing small ground polygons they can be tilted with the slope of the terrain.

Usage of mouse buttons in FSMesh:

Left mouse on map creates trigonometrical point
Right mouse on object edits object
Shift right on object extended edit
Control right on some objects moves object as long as right button is pressed

Import and modification of Standard Scenery

We now have got a tool that allows us to freely modify the terrain with a unique level of detail and precision. But when testing this a new problem arose. We can make the terrain very realistic but parts of the default scenery objects may not be as real. Roads and rivers can be off by hundreds of metres and this means that they will not follow the terrain.

The solution of removing all of the standard scenery objects creates its own problem since we would then have to remake all objects, airports, objects in flat areas, etc. So a way had to be found to exclude individual objects in the default scenery. How to do it?

First, we need two tools from the internet. BGLZIP from Microsoft and SCDIS2.1 by Takuya Murakami. You can get the latter from http://www.freesc.org .

The scenery files that come with FS2000 are compressed to save space. As a first step we have to decompress them. We can find the files in the directory FS2000\scenedb\region\scenery. Each of these files covers approximately 2 x 2 degrees. We copy the scenery file, for example F5400111.bgl, to the same directory where we have BGLZIP and SCDIS. Then we uncompress it with:

BGLZIP -d -f F5400111.bgl

The file is bigger now.

Next we dissassemble it:

SCDIS F5400111.bgl.

Some new files are generated. We check first in scdhead.txt to see if we've got the right file. We rename the scasm file scm9-1.scm to F5400111.scm for proper book keeping. Next we have to edit it. Near to the bottom we will most probably find an area with unknown record and data overrun messages. We delete this section complety beginning with the area and ending with the EndA instruction.

Next we start FSMesh and create a scenery. We decide to exclude all default objects inside the limits of the header. We select "file" "Import from SCDIS" and read the scm file. Now all visible objects of the default scenery that are inside the limits of our header are part of our scenery. Each object is represented by a star. Rivers and roads are visible. Roads are gray, rivers are blue, polygons are green, all other objects are white. If we shift+right click to the star we get a dialog that allows us to edit the different objects or delete them.

Now we can delete those rivers and roads that do not fit to the mesh or we can try to modify them. The best is of course to replace the roads with FSRail roads with moving traffic.

Alternatively, with FSMesh1.03ff you can also import code that has been translated with BGLAnalyze. To my knowledge, BGLAnalyze can translate all FS2K instructions, so you can import objects like airports now too. FSmesh can delete single imported objects, so this provides a way to keep those parts of the standard scenery that you want, and exclude individual objects.

The import has been tested only with the default scenery, which uses a very small fraction of all possible options. It is mainly intended to be used for seeing the rivers and roads, and for correcting the terrain according to them. If you decompile code from other sources, it is most likely that it will not display properly, FSMesh is not intended as SCASM-viewer. If you have a code fragment that you consider helpful for mesh design, please send this, future versions may have future updates.

Documentation of Menu items

File    
  New Scenery Creates a new FSMesh scenery
  Read Scenery Reads an existing FSMesh/FSRail scenery. If you want to use the scenery with FSRail to create railways or moving highways, I recommend you create it with FSRail.
  Save Scenery Write the scenery to disk. Do this from time to time to save your work.
  Save and compile SCASM Write the scenery to disk and invoke the SCASM compiler to compile the SCASM part of the scenery. If FSMesh is installed into the FSRail structure, you can also compile the railway part from this. Note that this action has nothing to do with terrain creation.
  Import from FSMesh You can read specific information from FSMesh/FSRail files to your new file. Limits of the headers will not be checked for import.
  Import from SCDIS Read a file from SCDIS (.scm) Area-EndA objects from within the limits of the header are imported to the SCASM part of the scenery.
  Import from BGLAnalyze Read a file from BGLAnalyze (.sca). Area-EndA objects from within the limits of the header are imported to the SCASM part of the scenery.
  Close The scenery gets closed. It is Off. This is necessary before you can create a new one. I hope you saved it.
Dialogs    
  Map options You can select which objects are displayed, grid parameters, etc.
  Change Header You can change the limits of the header. This may be very important since some import functions depend on the header. Assume you want a large scenery based on coarse info and a small part where you want to import high detail information. Create it with a full header, import the coarse information, change the header to small and import the high density information.
  Select rectangle Followed by two left mouseclicks to the map, selects all trigonometrical points inside the rectangle defined by the two points. You can make this step several times to select a more complicated shape of points. Selected points are shown as triangles pointing downwards. You can toggle the selection state of individual points with a right-click.
  Deselect All selected trigonometrical points are deselected, they all point upwards again.
  Action on selection You can delete all selected trigonometrical points, force them to a common height level, or lift them by a given amount.
Mesh    
  Altitude value After setting this the trigonometrical points will use this value. If used in background mode it switches the following clicks to use trigonometrical points of this altitude.
  Place trigonometrical point Make one trigonometrical point. Simple left mouse clicks to the map will have the same effect.
  Create FS DEM A DEM gets created. This is a computer intense function.
  Read FS DEM A DEM created by FSMesh or FSRail can be read back to the program. After reading or creating a DEM, FSMesh remembers the altitude of the terrain.
  Remove double trig. points When importing trigonometrical points from several sources some points may be defined twice. This function will remove the point that was defined first.
Import Trig.    
  From FSRail file Trigonometrical points are imported from another FSRail/FSMesh file if they are within the current limits of the header.
  USGS 30 sec DEM USGS-30 DEM are read and trigonometrical points are imported if they are within the current limits of the header. Note that the same directory must contain the .dem and the .hdr file.
  USGS 3 sec DEM Have to be processed by the Read_dem.exe utility first. See below
  DHM-100 DHM-100 files are read if they are within the current limits of the header. See the format below.
  DHM-1000 DHM-1000 files are read if they are within the current limits of the header. See the format below.
  Vertical Neighbor After importing a grid, you can make a geometrical vertical interpolation between two points to get more trigonometric points.
  Horizontal Neighbor After importing a grid, you can make a geometrical horizontal interpolation between two points to get more trigonometric points. Can be applied after the vertical one.
  Diagonal Neighbor After importing a grid, a trig point gets calculated in the center of each mesh. Reduces interference patterns - sometimes called steps. Do not combine with vertical and horizontal.
Map commands    
  Load bitmap A background bitmap is selected and opened. You can place markers or trigonometrical points directly.
  Elevation area You can define a polygon of a given elevation using this command. Elevation instructions seem to overwrite mesh values.
  Scale=1 The scenery is drawn so that the limits of the header fit to fullscreen.
  Zoom in You are asked which part of the screen you want to enlarge. Pressing + enlarges around the center.
  Zoom to mouse Followed by a left mouse click. Zooms in around that click.
  Zoom out Reduces scale. Identical to pressing -.
  Roads or River Simple linear roads or rivers can be placed between the following clicks.
  Poly roads/river Multi-segment roads or rivers can be added by left clicks. A right click defines the last segment. Maximal number of segments is 13.
  Polygon A concave polygon can be placed by left clicks, input is ended by right click. In 3D - designs, be careful. The reference point will be the middle of the form and the height of the polygon will be the height of the terrain at that point. If you make a sharp bend of a river around a mountain in one piece it may happen that the center is on that mountain - and you have a flying river. FS2K is full of these. It's better to make several smaller pieces with the center down in the valley.
  Airport macro This menu item allows to place Airport macros into your scenery to the position of the mouse clicks. This should be used only if you know the complete calling sequence of the macro. Many macros require Parameter 13 to have the value " v2= ". If you experience the compile step going into an eternal loop you will have forgotten this. For placing more macros I recommend using Airport itself or SCCreate - this is not the first task of this program.
  Color of marker You define the color of the markers with this. If used in background mode it switches the clicks after this to use markers of that color.
  Place Marker Places a marker at the following click.
  Reactivate markers You can deactivate markers with a right click. They are still there but unvisible. With this menu item you make all markers of the current color active again.
  Delete markers of current color You can delete all markers of the current color if you no longer need them. This makes the file smaller and all operations faster.
 

Import formats

Every supplier of geographical information seems to have its own format and programs that do nothing but converting from one format to the other cost as much as a complete PC capable of high resolution mesh terrain. FSMesh comes with some import functions. If you know of another format of useful data please tell me and I will write an input filter for the next version.

Hydrocorrection

This is the most important new feature of FSmesh, it took me months to work it out, and it needed more than 2000 lines of code. Even with a perfect mesh, lakes, rivers, and roads may be displayed wrong, if they are displaced against the mesh. To get perfect rivers into FS2000, there are two options: Either you remove all of them and make all of them new, or you adapt the terrain for the existing hydrography. A small survey showed that the first way was not possible, because there are no better digital data available world wide than those used by Microsoft. So I decided for the second way, without excluding the first.

I will use the word lake from now on to describe all ground polygons, river means the blue line MS draws for creeks and rivers. Roads are similar to rivers, all applies to them too. Lakes and rivers can be entered to FSMesh by three ways:

a) Placing ground polygons or poly roads/rivers in FSmesh or FSRail

b) Decompiling the MS scenery with SCDIS

c) Decompiling the MS scenery with BGLAnalyse.

I once added some lines that also allow to use lakes produced with Airport2.60 and than decompiled with SCDIS. Support for further combinations will concentrate on the new BGLAnalyze, since SCDIS seems to be dicontinued.

When you have such a lake of river, you see it displayed on the screen. A cross indicates its center. Right click to the stars of lakes and rivers produced inside FSMesh or FSRail. Shift right click to the decompiled objects.

Example:

Here you have an example in southern Italy (Lago Trinita in Sicily) of information coming from several sources. The trigonometric points are imported from DEM 30. The visible scenery is decompiled from the MS scenery. You see a lake and a small river running into it.

You also can see that this example, without intervention, will have problems. Some trigonometric points inside the lake are higher than others, so the lake will not have its shape, but will be partly covered, maybe also partly flying.

A control view shows that our suspicion was right. Well, you are used to much worse examples.

We make a shift right click to the green star, get a window that displays parts of the code of that object, we press Terrain altitude. After a few seconds, a window pops up like the above. FSMesh has tested all trigonometric points if they are inside the lake, and proposes the value of the lowest one. If FSMesh does not display this dialog and jumps back to normal running, than there is no trigonometric point inside the lake. Create one.

Now we can accept or change the altitude value, and press altitude. Now all trigpoints inside the lake are set to that value, and a band of points is created arround.

Special care is needed case the reference point is outside of the polygon. Than you have to modify the terrain arround the star manually to have the same altitude as the lake itself, outherwise it will fly or dive.

You will see this band now easily, it is forcing the terrain to be flat at this position. We let FSMesh generate a new DEM of 1024x1024, produce the mesh bgl and have a look to it.
Now the terrain has been shaped according to the lake. The unwanted peninsula in the forground is gone. The western shore is gently falling to the sea level.
Next we want to shape the river. We start at the highest point, which is approximately 250m above sea. Since the lower one is near to the sea, that will be at 78m. We enter these values to the end points, we can identify them by there coordinates. A bit of experience may be necessary to get the best values, and not to mix the ends up. If you mixed them up, or entered a wrong value, the new points are still selected, so you can remoce them from the dialogs menu.
Now two things have happened. some of the original trig points have been deleted, and a band of new points has been placed along the river. From the colors you see that they fit into the terrain. The width of the band is taken from the the river width in the RiverStart instruction and multiplied by 6. So you can influence the shape more by making this smaller or bigger.

Still, in mountaineous regions it is necessary to carefully look if there are no original points left which are in conflict with the valley. It may still be necessary to make a control flight over the river to see if it is proper. If not, most often removal of one or two trigonometric points can cure the problem.