Hi fellow wiki editors!

To help newly registered users get more familiar with the wiki (and maybe older users too) there is now a {{Welcome to the wiki}} template. Have a look at it and feel free to add it to new users discussion pages (and perhaps your own).

I have tried to keep the template short, but meaningful. /Johan G

Difference between revisions of "Howto:Add shared models manually"

From FlightGear wiki
Jump to: navigation, search
m (remove todo's)
Line 1: Line 1:
TODO - Document the new (0.9.10) UFO-based scenery object placement technique
You may want to read about FGSD before you start with this tutorial.
Note: You may include scenery objects in any format that PLIB supports. Currently, this means in addition to the 3ds models mentioned, you may use AC3D and other formats.
Note: You may include scenery objects in any format that PLIB supports. Currently, this means in addition to the 3ds models mentioned, you may use AC3D and other formats.

Revision as of 16:32, 26 June 2006

Note: You may include scenery objects in any format that PLIB supports. Currently, this means in addition to the 3ds models mentioned, you may use AC3D and other formats.

Adding Share Models

Here is a quick rundown on how to add a shared model to the current version of FlightGear.

Step 1

Create a directory under the FlightGear data/Models directory. I'm going to use data/Models/MyModels as an example.

Step 2

Inside the data/Models/MyModels drirectory create an xml file called foomodel.xml with the following contents :

IMPORTANT: The wiki does not allow raw XML code to be displayed. It will remove it. This explains why the original XML example posted here is missing. An XML file is only necessary if you are intending to include animation. An XML file is not required to render a model at a location in FlightGear. Instead of specifying an XML file in the STG file as stated below, merely give the path to the 3d model file (such as path/to/foomodel.ac).

Step 3

Create an 3ds model called foomodel.3ds and save it into the data/Models/MyModels directory. Notice that the xml file references the 3ds model file and tells FG that it must be visible from 0 meters up to 25 km.

Step 4

Start FG and fly (or use UFO model and move) to the location where you want to place the model. Open up the property browser in FG and write down the lat, lon and altitude where you want to place the model. (File->Browse Internal Properties->Position) After that write down the tile number. You can found it in the property browser (File->Browse Internal Properties -> Environment -> current-tile-id[0])

A really useful resource at this stage is http://www.terraserver-usa.com Enter a street name, city, and state. Then you can choose from several types of public-domain aerial photography from the US Geological Survey. When you get a good photo of your feature, click on the Info link. Your image will be broken into tiles with latitude and longitude of the edges of the tiles. This is good way to precisely place objects. Google Earth or Google Maps are also both excellent ways to obtain position information.

Step 5

In CVS there is a perl program called calc-tile.pl that works out what stg file a geodetic coordinate falls in. You can get it here if you don't feel like playing with CVS and don't have the CVS branch installed : http://cvs.flightgear.org/cgi-bin/viewcvs/viewcvs.cgi/*checkout*/FlightGear/scripts/perl/scenery/calc-tile.pl?rev=HEAD&cvsroot=FlightGear-0.9&content-type=text/x-perl Run the perl script in a terminal window passing it the longitude and latitude that you wrote down in step 4. You'll probably have to install perl first if you run on a MS OS's. Example :

paul@localhost scenery?$ ./calc-tile.pl -55.5 30.3
Longitude: -55.5
Latitude: 30.3
Tile: 2039314
Path:  "w060n30/w056n30/2039314.stg"

Step 6

Open the corresponding stg file in your scenery directory (in my case SceneryDir/w060n30/w056n30/2039314.stg)

Step 7

Add the following lines to the stg file replacing the parameters with your own :

OBJECT_SHARED Models/MyModels/foomodel.xml -55.5 30.3 1000.0 0.00 

The format is : OBJECT_SHARED relative path to model xml file LON LAT ALTITUDE above wgs84 ellipsoid ROTATION

Step 8

Start FG and fly to where you added the model and it should be there.

You can use FGSD for steps 4 to 7

STG File Format

Currently, no documention exists for the .stg files used by FlightGear other than this. There is none in the 'mini-docs' folder bundled with the source.

Each line of the STG file has the following format:



RELATIVE_PATH is the location of the scenery object.

LON is the Longitude

LAT is the Lattitude

ALT is the altitude above the surface of FlightGear world model.

ROT is the amount of rotation applied to the model in degrees. For example, if your model had a window that should face north, but it should face south, you could adjust the rendering of the model to face south by rotating 180 degrees.

About Altitude. Looking at the files shipped with FG, there are some strange, to me, figures for altitude. Some are negative numbers. That seems odd, since objects are being placed on the surface. It suggests that above surface may be negative on the Z axis. COMMENT : Much more likely these are objects which are purposely sunk into the terrain to adjust their height.

I ran across a comment: 3D object need scenery to compute their height. This is why scenery must be associated with an existing land surface file (whatever you call it).


This is what a line with an XML file specifying the model looks like.

OBJECT_SHARED Models/MidAtl/cape-may-light.xml   -74.959970 38.933332 -93.0 0.00

This is what a line specifying the model file directly looks like.

OBJECT_SHARED Models/MidAtl/cape-may-light.ac   -74.959970 38.933332 -93.0 0.00

A second example from the FlightGear KSFO scenery. Although taken from different STG files for the same area, you can see the mix of objects.

OBJECT_STATIC KSFO-terminal-fb.ac -122.3859635 37.61748958 3 90
OBJECT_SHARED Models/Airport/windsock.xml -122.360843 37.613877 1 0
OBJECT_SHARED Models/Structures/vordme.xml -122.37389 37.61948 -0.404 0
OBJECT_STATIC KSFO-maint-1-fb.ac -122.377127 37.62647917 0.5 62
OBJECT_STATIC candlestickpark-fb.xml -122.3838418 37.71570833 1.756719854 0