Segfault > IT > Games > X-Plane 9 terrain textures

Note 1: this article is deprecated. Still showing it just for historical reference.

Note 2: the contents are very raw - more for my reference rather then a guide.


I am using overlay polygons as described here.

The needed software is:

  • The VirtualEarth Satellite Downloader to get the satellite images of the ground and a file listing their coordinates.
  • The nice, fast and lightweight sqlite database - I'm using version 3. I use the database to manage the list of filenames and coordinates downloaded using the tool above.
  • Imagemagick which will "glue" using the utility "montage" all small ".jpg"-files to large ".png"-files.
  • The Scenery tools of X-Plane. We'll need DDSTool.exe and DSFTool.exe.
  • My bash script which loads the values into the database.
  • My C/C++ program which 1) generates the ".pol"-files, 2) the ".dsf" scenery file and an additional bash-script which when run will collate using Imagemagick all single small ".jpg" textures into large 2048x2048 ".png"-files and later convert them using the X-Plane tool "DDStool.exe" to ".dds"-files which will contain the mipmaps.
  • Potentially the nVidia texture tools: The "Windows Texture Viewer" is a very handy tool to look at the ".dds"-files, including the single mipmaps (move to the left/right) and the "nvDXT" utility generates e.g. with the command nvdxt.exe -dxt1c -nmips 12 -quality_production -Kaiser -file 0x0.png ".dds"-files containing mipmaps (12 in this case) (nvdxt is much faster than DDStool, but I didn't try it out yet). 

START:

 


So, first of all download install and buy a license for the utility MS VirtualEarth Satellite Downloader (mvsd).
You can use the map of this fantastic tutorial to visually select on the map an area you're interested in (not too large!!) and get below it the coordinates you have to insert into mvsd - e.g. if you get...

12.812805,47.656138,0
13.146515,47.656138,0
13.146515,47.397420,0
12.812805,47.397420,0

...insert into the left/right longitude the coords 12.812805/13.146515 and into the top/bottom latitude the coords 47.656138/47.397420.
Now select the Zoom-level, e.g. 17 and the number of parallel threads for the downloads, e.g. 4. Once the images have been downloaded double-check with "Tools => Combine Images" that you're not missing too many "jpg"s. If yes, download the single ones (have a look at the log file to know which ones you're missing).

The next step is to create a database which will store the informations contained in the file "[yourproject]_list.txt". Use e.g. this bash script. That script is terrible, and has two really big problems:

  • Where it says "#Eventually use...", review which EOL you have to use.
  • Change the line "echo "insert into filedata select substr(filename, 1, 6), substr(filename, 8, 6)..." to match the filename visible in the logs. E.g. if the filenames are something like "12345_12345.jpg", use "1, 5" and 7, 5" ([start], [length]) but if the filenames are "123456_123456.jpg" then use "1, 6" and 8, 6", and so on.

Ok, now you should have a database called "scenery.db" and by issuing a "select * from filedata;" you should get the long listing of all the filenames contained in your "[yourproject]_list.txt"-file. Doublecheck this.

Download this program.
Now open up with GIMP or any other program any of the files that were downloaded, e.g. "gimp 123456_123456.jpg" and check that its resolution is 256x256. If not, modify accordingly with a text editor the line int iInputImgSize=256; of the file xplane_texture_scen.cpp.
You could modify as well int iFinalImgSize = 2048; if for any reason you want smaller polygons in X-Plane. Once you're done execute "./compile" and you should end up getting the executable "xplane_texture_scen".

Once you got the executable "xplane_texture_scen", copy it to the directory where the database scenery.db and execute it. It should run very fast, generating 1) the ".pol" files, a "generated_dsf.txt"-file and a "runme_create_textures"-file.

Copy the "DDSTool.exe" (contained in the Scenery Tools package - see above) to the directory where you placed all the small ".jpg"-files, together with the script "runme_create_textures". and run the script - from this point onwards you'll need WINE to be installed!!

It will run for a while. If you have to generate a lot of textures and have multiple CPU-cores available, split up the file "runme_create_textures" into smaller pieces and run them concurrently.

Copy the file "DSFTool.exe" to the directory where the file "generated_dsf.txt" appeared previously and with a text editor open "generated_dsf.txt" and edit the lines...

#START-MODIFY ACCORDINGLY THE COORDINATES OF THE NEXT FOUR LINES!!!
PROPERTY sim/west +008
PROPERTY sim/east +009
PROPERTY sim/north 48
PROPERTY sim/south 47
#END-MODIFY ACCORDINGLY THE COORDINATES OF THE PREVIOUS FOUR LINES!!!

...by looking at the next ones:

POLYGON_DEF 0x0.pol
BEGIN_POLYGON 0 65535 4
BEGIN_WINDING
POLYGON_POINT   7.60847473144531 51.41322032645658      1 0
POLYGON_POINT   7.60847473144531 51.41693745292289      1 1
POLYGON_POINT   7.60298156738281 51.41693745292289      0 1
POLYGON_POINT   7.60298156738281 51.41322032645658      0 0
END_WINDING
END_POLYGON

In this case I would change the above to:

#START-MODIFY ACCORDINGLY THE COORDINATES OF THE NEXT FOUR LINES!!!
PROPERTY sim/west +007
PROPERTY sim/east +008
PROPERTY sim/north 52
PROPERTY sim/south 51
#END-MODIFY ACCORDINGLY THE COORDINATES OF THE PREVIOUS FOUR LINES!!!

After you're done you can compile it by issuing e.g. the command "wine DSFTool.exe --text2dsf generated_dsf.txt +51+007.dsf" (the south and the west coords).

Go to your "Custom Scenery"-directory of X-Plane and create inside it a directory structure for your new scenery. E.g.

my_new_scenery

Earth nav data

+50+000 (<=the vertical coords rounded to 40, 50, etc...)

Copy all "*.pol" and "*.dds" to the "my_new_scenery"-directory. Copy the file "+51+007.dsf" to the directory "my_new_scenery => Earth nav data => +50+000".

At this point, before starting up X-Plane, start up the "Overlay Editor" (see http://www.x-plane.org) and load your brand new scenery to see if the texture was loaded.