Howto:Convert objects from X-Plane: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 93: Line 93:


Now fire up fgfs --airport=EDDC, fly about 4.5 nm hdg 145, you should find this:
Now fire up fgfs --airport=EDDC, fly about 4.5 nm hdg 145, you should find this:
[[File:Example.jpg]]
[[File:bluewonder_in_FG.jpg]]

Revision as of 21:22, 3 May 2010

This is a tutorial on how to convert Microsoft Flight Simulator scenery objects to Flightgear's .ac format.

We will use the fs2xplane package by Jonathan Harris to first convert the model from MSFS to X-Plane. Then, we import this X-Plane model in blender, using the XPlane2Blender import filter (also by Jonathan Harris), from which we export the model to FG's native AC3D format. Finally, we extract the lat/lon coordinates from an xml file, and place the object in FG.

This method has been tested OK on a couple of scenery objects made by Hellfried Miersch for MSFS 2004. I did not test it with models from other sources, yet.

I've written some bash scripts to ease the conversation a bit. They have been tested on Gentoo Linux. I have no idea about Windows or Mac scripting, however, the manual procedure of conversation should work on Windows, Mac and Linux.

You will need the following tools:

  • an X-Plane installation (demo works for me)
  • blender (tested on ver. 2.48a-r3)
  • XPlane2Blender (ver 3.09) and fs2xplane (ver 3.11) from Jonathan Harris' page
  • FG source
  • and, of course, a MSFS scenery to convert. As an example, I will use a model of "Das Blaue Wunder" (The Blue Wonder), a historic bridge over the Elbe river in Dresden, Germany. It has been created by Hellfried Miersch, you may get it here. Scroll down to the bottom and download "Blaues Wunder Dresden" and "Blaues Wunder_mdl_xml".

Plus, if you want to semi-automate things using my bash scripts, you will need - xte from Steve Slaven's xautomation package.

1. Semi-automatic conversation using msfs2ac.sh

For the impatient, here's how you convert the model semi-automatically using my scripts. You will find the manual step-by-step tutorial below.

Since I couldn't find an easy way to control blender from the command line, I decided to do a really dirty hack: emulate mouse clicks and key strokes using "xte" from Steve Slaven's xautomation package. Of course, this has some limitations: we rely heavily on the exact Blender screen/menu layout. I'm sure there's a better solution. Feel free to enlighten me.

Installation:

unpack the scripts somewhere, cd there. You should have the following files

# ls -1
bin/
doc/
msfs2ac.profile

Adjust the paths in msfs2ac.profile according to your setup:

  • FG_SRC must point to your FG source,
  • XPLANE must point to the X-Plane custom scenery folder, e.g.
# cat msfs2ac.profile
export FG_SRC=/home/tom/daten/fgfs/src-release/fg-cvs/
export XPLANE="/home/tom/X-Plane 9 Demo/Custom Scenery/"

Install fs2xplane here. This should add a directory lib/ plus some files in bin/.

Now we are ready to convert a MSFS scenery:

place the MSFS scenery .zip-files here. Continuing the above example:

  1. mv ~/downloads/Bluewonder.zip ~/downloads/Bluewonder_MDL_XML.zip .

load environment variables and path:

  1. source msfs2ac.profile

Open your default web browser, move it to the bottom right corner of your screen, covering as little screen area as possible, but do not minimize it!

Shut down all applications that could steal focus. Now run the conversation script.:

  1. msfs2ac.sh -1 Bluewonder.zip

This will fire up blender. Wait. Do not touch the mouse nor keyboard until blender closes again. Import and Export of a single model might take some 30 seconds or so.

You should now have a new folder containing the convertes model: ls -l fgfs/Bluewonder/ total 220 -rw-r--r-- 1 tom users 218247 2010-05-03 00:04 Bluewonder.ac lrwxrwxrwx 1 tom users 58 2010-05-03 00:03 objects -> /home/tom/X-Plane 9 Demo/Custom Scenery/Bluewonder/objects

Have a first look at it, it should look like this: <PIC>

tom@mango convert-sandbox $ osgviewer fgfs/Bluewonder/Bluewonder.ac osgDB ac3d reader: could not find texture "Bluewonder.png" osgDB ac3d reader: could not find texture "Bruehl.png"

Copy the missing textures:

cp fgfs/Bluewonder/objects/Bluewonder.png fgfs/Bluewonder/ cp fgfs/Bluewonder/objects/Bruehl.png fgfs/Bluewonder/

Now you model should be textured nicely: <PIC>

Last, we need to extract the coordinates of the model and generate a .stg line for placement in FGFS. Run:

unzip -d msfs/Bluewonder/ Bluewonder_MDL_XML.zip

  1. xml2stg.sh msfs/Bluewonder/Bluewonder.XML

OBJECT_STATIC Bluewonder.ac 13.8101 51.0535 0 238.5 # e010n50/e013n51/3171139.stg

The third number is the object's altitude. In Bluewonder.XML it is given AGL, however, in FGFS, it is in absolute meters, so we have to guesstimate and correct it later on using the UFO or, even better, query the actual elevation. A good guess here is 120.

Add this line to FGFS scenery/objects/e010n50/e013n51/3171139.stg and move the model and textures from fgfs/Bluewonder to FGFS scenery/objects/e010n50/e013n51/

Now fire up fgfs --airport=EDDC, fly about 4.5 nm hdg 145, you should find this: Bluewonder in FG.jpg