Howto:Add shared models manually: Difference between revisions

Jump to navigation Jump to search
m
replace <tt> with <code>
m (replace <tt> with <code>)
Line 1: Line 1:
You can add objects to FlightGear's world by making use of "models" of those objects.  This howto explains one way to do so, especially with the shared models that are distributed with FlightGear.  These models are called "shared" because they are used to define many objects in different places.  (There are also "static models" which represent unique objects, such as famous buildings, that only exist in one place, but we won't have much to say about them.)  Shared models are stored in the <tt>[[$FG_ROOT]]/Models</tt> directory.
You can add objects to FlightGear's world by making use of "models" of those objects.  This howto explains one way to do so, especially with the shared models that are distributed with FlightGear.  These models are called "shared" because they are used to define many objects in different places.  (There are also "static models" which represent unique objects, such as famous buildings, that only exist in one place, but we won't have much to say about them.)  Shared models are stored in the <code>[[$FG_ROOT]]/Models</code> directory.


You can also create your own models; see [[Modeling - Getting Started]].  Most Flightgear models are in the .ac (AC3D) format.
You can also create your own models; see [[Modeling - Getting Started]].  Most Flightgear models are in the .ac (AC3D) format.
Line 9: Line 9:
If you plan to use one of the standard FG shared models, skip to step 4.
If you plan to use one of the standard FG shared models, skip to step 4.


If you have created your own model, create a new directory for it under <tt>[[$FG_ROOT]]/Models</tt> (to keep your models separate from the standard ones).  We'll use <tt>$FG_ROOT/Models/MyModels</tt> as an example.
If you have created your own model, create a new directory for it under <code>[[$FG_ROOT]]/Models</code> (to keep your models separate from the standard ones).  We'll use <code>$FG_ROOT/Models/MyModels</code> as an example.


=== Step 2 ===
=== Step 2 ===
Copy the file (usually has an .ac extension) containing your model into the <tt>$FG_ROOT/Models/MyModels</tt> directory. We'll use <tt>MyModel.ac</tt> as the name of that file.
Copy the file (usually has an .ac extension) containing your model into the <code>$FG_ROOT/Models/MyModels</code> directory. We'll use <code>MyModel.ac</code> as the name of that file.


=== Step 3 (optional) ===
=== Step 3 (optional) ===
If you intend to include animation, create an XML file called <tt>MyModel.xml</tt> inside the <tt>$FG_ROOT/Models/MyModels</tt> directory with the following contents:
If you intend to include animation, create an XML file called <code>MyModel.xml</code> inside the <code>$FG_ROOT/Models/MyModels</code> directory with the following contents:


  <?xml version="1.0"?>
  <?xml version="1.0"?>
Line 42: Line 42:
Here, though, we'll continue by describing a manual way to do it, for people who may need or want to know the inside details.   
Here, though, we'll continue by describing a manual way to do it, for people who may need or want to know the inside details.   


Start FG and fly to the location where you want to place the object (or use [[command line options]] to start in that location). Open up the property browser in FG (File->Browse Internal Properties), and the <tt>/position</tt> key.  Check that the values for <tt>latitude-deg</tt> and <tt>longitude-deg</tt> are what you want, or write them down if you're positioning things visually, and also note the <tt>ground-elev-m</tt>. If you want to place the object above ground level (or partially bury it), then adjust the number appropriately.  Then, go to the <tt>/environment</tt> key and write down the tile number (current-tile-id) for that location.
Start FG and fly to the location where you want to place the object (or use [[command line options]] to start in that location). Open up the property browser in FG (File->Browse Internal Properties), and the <code>/position</code> key.  Check that the values for <code>latitude-deg</code> and <code>longitude-deg</code> are what you want, or write them down if you're positioning things visually, and also note the <code>ground-elev-m</code>. If you want to place the object above ground level (or partially bury it), then adjust the number appropriately.  Then, go to the <code>/environment</code> key and write down the tile number (current-tile-id) for that location.


=== Step 5 ===
=== Step 5 ===
Next, locate a .stg file into which you will place a reference to the object's model and its position.  
Next, locate a .stg file into which you will place a reference to the object's model and its position.  


The .stg files are named according to tile number and stored under the scenery directories.  The default installation places a limited amount of scenery (for the area around San Francisco) in <tt>[[$FG_ROOT]]/scenery</tt> but you may have scenery in other directories, as specified in <tt>[[$FG_SCENERY]]</tt>.  (See [[Howto: Install scenery]].)  Under each scenery directory, you will find directories called <tt>Objects</tt> and <tt>Terrain</tt>, and under them directories that group tiles into larger and smaller quadrants.  Thus, if the tile number is 942058, you will find <tt>942058.stg</tt> under <tt>$FG_ROOT</tt> as <tt>$FG_Root/Scenery/Objects/w130n30/w123n37/942058.stg</tt> (and possibly elsewhere).
The .stg files are named according to tile number and stored under the scenery directories.  The default installation places a limited amount of scenery (for the area around San Francisco) in <code>[[$FG_ROOT]]/scenery</code> but you may have scenery in other directories, as specified in <code>[[$FG_SCENERY]]</code>.  (See [[Howto: Install scenery]].)  Under each scenery directory, you will find directories called <code>Objects</code> and <code>Terrain</code>, and under them directories that group tiles into larger and smaller quadrants.  Thus, if the tile number is 942058, you will find <code>942058.stg</code> under <code>$FG_ROOT</code> as <code>$FG_Root/Scenery/Objects/w130n30/w123n37/942058.stg</code>.


There is generally more than one .stg file for a given tile, in different directories.  It's important to edit one that will actually be read by flightgear (see below).  One thing you can do is create a personal customized scenery directory separate from the standard installation.  That way, if you upgrade FG your customizations won't get overwritten.  If you create such a directory, list it first in <tt>[[$FG_SCENERY]]</tt>, create a directory structure inside it parallel to the one in the standard scenery story, and create a .stg file in the appropriate place. Similarly, it is best not to edit the .stg files in the folder where [[TerraSync]] stores the scenery it has fetched, since TerraSync may overwrite them with newer versions.  Objects associated with airports are usually put into a .stg file under a "Terrain" directory; other objects are put under "Objects".
There is generally more than one .stg file for a given tile, in different directories.  It's important to edit one that will actually be read by flightgear (see below).  One thing you can do is create a personal customized scenery directory separate from the standard installation.  That way, if you upgrade FG your customizations won't get overwritten.  If you create such a directory, list it first in <code>[[$FG_SCENERY]]</code>, create a directory structure inside it parallel to the one in the standard scenery story, and create a .stg file in the appropriate place. Similarly, it is best not to edit the .stg files in the folder where [[TerraSync]] stores the scenery it has fetched, since TerraSync may overwrite them with newer versions.  Objects associated with airports are usually put into a .stg file under a "Terrain" directory; other objects are put under "Objects".


=== Step 6 ===
=== Step 6 ===
Line 59: Line 59:
  type path longitude latitude altitude rotation
  type path longitude latitude altitude rotation


* Most of the time you'll use OBJECT_SHARED as the type; this is for models that are used over and over again in many places, and are normally fetched from <tt>$FG_ROOT/Models</tt>.  (If you have a one-of-a-kind object, you might want to use OBJECT_STATIC instead; see an explanation of it in <tt>$FG_ROOT/Docs/README.scenery</tt>.)
* Most of the time you'll use OBJECT_SHARED as the type; this is for models that are used over and over again in many places, and are normally fetched from <code>$FG_ROOT/Models</code>.  (If you have a one-of-a-kind object, you might want to use OBJECT_STATIC instead; see an explanation of it in <code>$FG_ROOT/Docs/README.scenery</code>.)
* The path points to the file that contains the model, relative to the $FG_ROOT directory. If you have an XML file for the model, specify it here, otherwise specify the .ac file.   
* The path points to the file that contains the model, relative to the $FG_ROOT directory. If you have an XML file for the model, specify it here, otherwise specify the .ac file.   
* Latitude and longitude are in decimal degrees.
* Latitude and longitude are in decimal degrees.
Line 71: Line 71:


== STG file format ==
== STG file format ==
There is documention for the .stg files used by FlightGear in <tt>$FG_ROOT/Docs/README.scenery</tt>.  Only information relevant for placing shared objects is included here.
There is documention for the .stg files used by FlightGear in <code>$FG_ROOT/Docs/README.scenery</code>.  Only information relevant for placing shared objects is included here.


Scenery files are loaded by default from <tt>[[$FG_ROOT]]/Scenery</tt>.  Alternate locations (a "scenery path") can be specified in <tt>[[$FG_SCENERY]]</tt> (or from the command line); the first-named directories have highest priority.  Thus, if you create a local directory for storing custom scenery you create, include it first in the scenery path.
Scenery files are loaded by default from <code>[[$FG_ROOT]]/Scenery</code>.  Alternate locations (a "scenery path") can be specified in <code>[[$FG_SCENERY]]</code> (or from the command line); the first-named directories have highest priority.  Thus, if you create a local directory for storing custom scenery you create, include it first in the scenery path.


Lines for shared objects in the .stg file look like this:
Lines for shared objects in the .stg file look like this:
Line 93: Line 93:
|}
|}


The filename path is relative to <tt>$FG_ROOT</tt>.  Longitude and latitude are expressed as decimal numbers (not degrees/minutes/seconds), with negative values representing west and south.  Elevation is in meters above mean sea-level.  Heading is in degrees, '''counter-clockwise''' from North as 0.0 (i.e. when looking from above).  Note that this is opposite from headings in other places in FlightGear, which are clockwise.
The filename path is relative to <code>$FG_ROOT</code>.  Longitude and latitude are expressed as decimal numbers (not degrees/minutes/seconds), with negative values representing west and south.  Elevation is in meters above mean sea-level.  Heading is in degrees, '''counter-clockwise''' from North as 0.0 (i.e. when looking from above).  Note that this is opposite from headings in other places in FlightGear, which are clockwise.


Some more examples:
Some more examples:
Line 102: Line 102:


== XML file format ==
== XML file format ==
Alternately, there is a way to include this same information in XML configuration files that are loaded at runtime; see [[Howto: Place 3D objects with the UFO]] or <tt>$FG_ROOT/Docs/README.scenery</tt> for more details.  This approach has the advantage of keeping your new scenery clearly separate from the standard scenery files without having to create your own custom scenery directory structure.  Further, you can then manually control whether or not to load it at run-time, using the --config option on the command line. You can also include it in one of the standard startup files (such as [[Fgfsrc|.fgfsrc]]) but this will load it into memory every time you start FG, whether or not you are flying in the area.  If you place the scenery information in .stg files, it is only loaded into memory when needed.
Alternately, there is a way to include this same information in XML configuration files that are loaded at runtime; see [[Howto: Place 3D objects with the UFO]] or <code>$FG_ROOT/Docs/README.scenery</code> for more details.  This approach has the advantage of keeping your new scenery clearly separate from the standard scenery files without having to create your own custom scenery directory structure.  Further, you can then manually control whether or not to load it at run-time, using the --config option on the command line. You can also include it in one of the standard startup files (such as [[Fgfsrc|.fgfsrc]]) but this will load it into memory every time you start FG, whether or not you are flying in the area.  If you place the scenery information in .stg files, it is only loaded into memory when needed.


[[Category:Howto|Add shared models manually]]
[[Category:Howto|Add shared models manually]]
[[Category:Scenery enhancement|Add shared models manually]]
[[Category:Scenery enhancement|Add shared models manually]]

Navigation menu