Howto:Add shared models manually: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
m (updated link, some corrections)
m (some minor corrections)
Line 1: Line 1:
{{cleanup}}
{{cleanup}}


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. This howto assumes that you already have a model. If not, create one using a suitable modeling program such as [http://www.blender.org/ blender].


== Adding Shared Models ==
== Adding Shared Models ==
Line 10: Line 10:


=== Step 2 ===
=== Step 2 ===
Inside the data/Models/MyModels drirectory create an xml file called foomodel.xml with the following contents :
Inside the data/Models/MyModels drirectory you may 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).
<?xml version="1.0"?>
<PropertyList>
  <path>MyModel.ac</path>
  <animation>
  <type>range</type>
  <min-m>0</min-m>
  <max-m>20000</max-m>
  </animation>
</PropertyList>
 
Note: 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 ===
=== Step 3 ===
Line 26: Line 36:
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/viewvc/source/scripts/perl/scenery/calc-tile.pl?revision=HEAD 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 :
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/viewvc/source/scripts/perl/scenery/calc-tile.pl?revision=HEAD 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
  $ ''./calc-tile.pl -55.5 30.3''
  Longitude: -55.5
  Longitude: -55.5
  Latitude: 30.3
  Latitude: 30.3
  Tile: 2039314
  Tile: 2039314
  Path: "w060n30/w056n30/2039314.stg"
  Path: "w060n30/w056n30/2039314.stg"


=== Step 6 ===
=== Step 6 ===
Line 38: Line 48:
Add the following lines to the stg file replacing the parameters with your own :
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  
  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''. If you have no XML file, just specify the path to your model.
The format is: ''OBJECT_SHARED relative_path_to_model_xml_file LON LAT ALTITUDE_above_wgs84 ellipsoid_ROTATION''.
Note: If you have no XML file, just specify the path to your model.


=== Step 8 ===  
=== Step 8 ===  

Revision as of 16:01, 6 December 2009

Cleanup.png This article may require cleanup to meet the quality standards of the wiki. Please improve this article if you can.

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. This howto assumes that you already have a model. If not, create one using a suitable modeling program such as blender.

Adding Shared 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 you may create an XML file called foomodel.xml with the following contents:

<?xml version="1.0"?>
<PropertyList>
 <path>MyModel.ac</path>
 <animation>
  <type>range</type>
  <min-m>0</min-m>
  <max-m>20000</max-m>
 </animation>
</PropertyList>

Note: 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/viewvc/source/scripts/perl/scenery/calc-tile.pl?revision=HEAD 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 :

$ ./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. Note: If you have no XML file, just specify the path to your model.

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:

OBJECT_STATIC KSFO-maint-1-fb.ac -122.377127 37.71570833 1.756719854 20
Type Relative path Longitude Latitude Elevation Heading

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