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

Jump to navigation Jump to search
m
no edit summary
mNo edit summary
mNo edit summary
Line 1: Line 1:
This is a tutorial on how to convert Microsoft Flight Simulator scenery objects to Flightgear's .ac format.  
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.
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 FlightGear's native AC3D format. Finally, we extract the lat/lon coordinates from an xml file, and place the object in FlightGear.


This method has been tested OK on a couple of scenery objects made by [http://www.helles-flusi.de Hellfried Miersch] for MSFS 2004. I did not test it with models from other sources, yet.
This method has been tested OK on a couple of scenery objects made by [http://www.helles-flusi.de Hellfried Miersch] for MSFS 2004. I did not test it with models from other sources, yet.
Line 12: Line 12:
* [http://www.blender.org blender] (tested on ver. 2.48a-r3)
* [http://www.blender.org blender] (tested on ver. 2.48a-r3)
* XPlane2Blender (ver 3.09) and fs2xplane (ver 3.11) from [http://marginal.org.uk/x-planescenery/tools.html Jonathan Harris' page]
* XPlane2Blender (ver 3.09) and fs2xplane (ver 3.11) from [http://marginal.org.uk/x-planescenery/tools.html Jonathan Harris' page]
* FG source
* FlightGear source
* and, of course, a MSFS scenery to convert. As an example, I will use a model of [http://en.wikipedia.org/wiki/Blue_Wonder "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 [http://www.helles-flusi.de/index.php/DD-Weitere_19.html here]. Scroll down to the bottom and download "Blaues Wunder Dresden" and "Blaues Wunder_mdl_xml".
* and, of course, a MSFS scenery to convert. As an example, I will use a model of [http://en.wikipedia.org/wiki/Blue_Wonder "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 [http://www.helles-flusi.de/index.php/DD-Weitere_19.html here]. Scroll down to the bottom and download "Blaues Wunder Dresden" and "Blaues Wunder_mdl_xml".


Line 24: Line 24:
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.
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
 
unpack the scripts somewhere, cd there. You should have the following files


  # ls -1
  # ls -1
Line 34: Line 32:


Adjust the paths in msfs2ac.profile according to your setup:
Adjust the paths in msfs2ac.profile according to your setup:
* FG_SRC must point to your FG source,  
 
* FG_SRC must point to your FlightGear source,  
* XPLANE must point to the X-Plane custom scenery folder, e.g.
* XPLANE must point to the X-Plane custom scenery folder, e.g.


Line 46: Line 45:


place the MSFS scenery .zip-files here. Continuing the above example:
place the MSFS scenery .zip-files here. Continuing the above example:
# mv ~/downloads/Bluewonder.zip ~/downloads/Bluewonder_MDL_XML.zip .
# mv ~/downloads/Bluewonder.zip ~/downloads/Bluewonder_MDL_XML.zip .


load environment variables and path:
Load environment variables and path:


# source msfs2ac.profile
# 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!
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, and run the conversation script:


Shut down all applications that could steal focus.
# msfs2ac.sh -1 Bluewonder.zip
Now run the conversation script.:


# msfs2ac.sh -1 Bluewonder.zip
The -1 switch tells the script to pack all objects found in Bluewonder.zip into a single output file named Bluewonder.ac.


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.
This will fire up blender. 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:


You should now have a new folder containing the convertes model:
# ls -l fgfs/Bluewonder/
ls -l fgfs/Bluewonder/
total 220
total 220
-rw-r--r-- 1 tom users 218247 2010-05-03 00:04 Bluewonder.ac
-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
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,
Have a first look at it,


  tom@mango convert-sandbox $ osgviewer fgfs/Bluewonder/Bluewonder.ac
  # osgviewer fgfs/Bluewonder/Bluewonder.ac
  osgDB ac3d reader: could not find texture "Bluewonder.png"
  osgDB ac3d reader: could not find texture "Bluewonder.png"
  osgDB ac3d reader: could not find texture "Bruehl.png"
  osgDB ac3d reader: could not find texture "Bruehl.png"
Line 79: Line 76:
Copy the missing textures:
Copy the missing textures:


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


Now you model should be textured nicely:  
Now you model should be textured nicely:  
Line 86: Line 83:
[[File:bluewonder_textured.jpg]]
[[File:bluewonder_textured.jpg]]


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


unzip -d msfs/Bluewonder/ Bluewonder_MDL_XML.zip
# unzip -d msfs/Bluewonder/ Bluewonder_MDL_XML.zip
# xml2stg.sh msfs/Bluewonder/Bluewonder.XML
# xml2stg.sh msfs/Bluewonder/Bluewonder.XML


OBJECT_STATIC Bluewonder.ac            13.8101 51.0535 0  238.5            # e010n50/e013n51/3171139.stg
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, [[Howto:_Calculate_elevations|query the actual elevation]]. A good guess here is 120.
The third number is the object's altitude. In Bluewonder.XML it is given [http://en.wikipedia.org/wiki/Above_ground_level AGL], however, in FlightGear, it is [http://en.wikipedia.org/wiki/Above_mean_sea_level MSL], so we have to guesstimate and correct it later on using the UFO or, even better, [[Howto:_Calculate_elevations|query the actual elevation]]. A good guess here is 120.


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


Now fire up fgfs --airport=EDDC, fly about 4.5 nm hdg 145, you should find this:
Now fire up fgfs --airport=EDDC and fly about 4.5 nm hdg 145. You should find this:


[[File:bluewonder_in_FG.jpg]]
[[File:bluewonder_in_FG.jpg]]
153

edits

Navigation menu