Changes

Jump to navigation Jump to search
m
no edit summary
Line 1: Line 1: −
{{Languages|Howto: 3D Aircraft Models}}
   
This [[:Category:Howto|howto]] explains how to add 3D [[aircraft]] models to [[FlightGear]], and how to animate and position those models. No C++ programming is required, but the user will need some knowledge of FlightGear's property system and [[XML]] markup, and will need to understand the coordinate system FlightGear uses for its models:
 
This [[:Category:Howto|howto]] explains how to add 3D [[aircraft]] models to [[FlightGear]], and how to animate and position those models. No C++ programming is required, but the user will need some knowledge of FlightGear's property system and [[XML]] markup, and will need to understand the coordinate system FlightGear uses for its models:
   Line 16: Line 15:     
==Loading the model==
 
==Loading the model==
Through plib, FlightGear supports many different 3D file formats, including VRML1, AC3D, DXF, MDL (from Microsoft Flight Simulator), and many others. The property /sim/model/path in the main FlightGear property tree controls what model will be loaded; it takes a string value giving the relative path of the model from FG_ROOT (the root of the base package, such as /usr/local/share/FlightGear or C:\FLIGHTGEAR\).
+
Through plib, FlightGear supports many different 3D file formats, including VRML1, AC3D, DXF, MDL (from Microsoft Flight Simulator), and many others. However, .ac is the standard used in most FG models.  
   −
The easiest way to load a new model is to set the property at startup with the --prop: [[Command Line Parameters|command line option]]; for example, to use a 3D aircraft model that you have installed in $FG_ROOT/Models/my-cessna.wrl, you could invoke FlightGear like this (under Unix-like systems):
+
The property /sim/model/path in the main FlightGear property tree controls what model will be loaded; it takes a string value giving the relative path of the model from [[$FG_ROOT]].
   −
fgfs --prop:/sim/model/path=Models/my-cessna.wrl
+
The easiest way to load a new model is to set the property at startup with the --prop: [[Command Line Parameters|command line option]]; for example, to use a 3D aircraft model that you have installed in <tt>$FG_ROOT/Models/my-cessna.ac</tt>, you could invoke FlightGear like this (under Unix-like systems):
   −
(Note: Normally all textures used by the model must appear in the same directory. If my-cessna.wrl uses the textures cessna01.rgb and cessna02.rgb, you should also install those textures in $FG_ROOT/Models/. It is howerever possible to specify a path (relative to the model path) to specify where the textures could be found.)
+
fgfs --prop:/sim/model/path=Models/my-cessna.ac
   −
When you want to set a 3D model permanently as the default for an aircraft rather than specifying it on the [[command line]], you need to edit an aircraft settings file. In the $FG_ROOT/Aircraft/ directory there is a series of files ending in -set.xml, such as c172-set.xml, dc3-yasim-set.xml, and beech99-uiuc-set.xml. When you start FlightGear with the --aircraft option, it reads the properties from one of these files; for example
+
(Note: Normally all textures used by the model must appear in the same directory. If my-cessna.ac uses the textures cessna01.rgb and cessna02.rgb, you should also install those textures in <tt>$FG_ROOT/Models/</tt>. It is howerever possible to specify a path (relative to the model path) to specify where the textures could be found.)
 +
 
 +
When you want to set a 3D model permanently as the default for an aircraft rather than specifying it on the [[command line]], you need to edit an aircraft settings file. In the <tt>$FG_ROOT/Aircraft/</tt> directory there is a series of files ending in -set.xml, such as c172-set.xml, dc3-yasim-set.xml, and beech99-uiuc-set.xml. When you start FlightGear with the --aircraft option, it reads the properties from one of these files; for example
    
  fgfs --aircraft=dc3-yasim
 
  fgfs --aircraft=dc3-yasim
   −
Loads the properties from $FG_ROOT/Aircraft/dc3-yasim-set.xml into the main FlightGear property tree. These files are in the same XML property-list format as $FG_ROOT/preferences.xml and the FlightGear save files. There may be many XML files with different startup conditions, sounds, panels, 3D models, etc. for any single aircraft type, so you are best off copying an existing one, renaming it, then changing the value inside the path element inside model inside sim:
+
Loads the properties from <tt>$FG_ROOT/Aircraft/dc3-yasim-set.xml</tt> into the main FlightGear property tree. These files are in the same XML property-list format as <tt>$FG_ROOT/preferences.xml</tt> and the FlightGear save files. There may be many XML files with different startup conditions, sounds, panels, 3D models, etc. for any single aircraft type, so you are best off copying an existing one, renaming it, then changing the value inside the path element inside model inside sim:
    
  <PropertyList>
 
  <PropertyList>
 
  <sim>
 
  <sim>
 
   <model>
 
   <model>
   <path>Models/my-cessna.wrl</path>
+
   <path>Models/my-cessna.ac</path>
 
   <texture-path>./Textures</texture-path>
 
   <texture-path>./Textures</texture-path>
 
   </model>
 
   </model>
Line 39: Line 40:  
  </PropertyList>
 
  </PropertyList>
   −
So far, all of the examples have had the /sim/model/path property point directly at the 3D model file (Models/my-cessna.wrl); however, if you want to be able to reposition or animate the model, you need to point to an intermediate XML file instead, and then put the repositioning and animation information into the XML file. Here's a simple example of a 3D-model wrapper file, with no repositioning or animation information:
+
So far, all of the examples have had the /sim/model/path property point directly at the 3D model file (Models/my-cessna.ac); however, if you want to be able to reposition or animate the model, you need to point to an intermediate XML file instead, and then put the repositioning and animation information into the XML file. Here's a simple example of a 3D-model wrapper file, with no repositioning or animation information:
    
  <PropertyList>
 
  <PropertyList>
<path>my-cessna.wrl</path>
+
  <path>my-cessna.ac</path>
<texture-path>./Textures</texture-path>
+
  <texture-path>./Textures</texture-path>
 
  </PropertyList>
 
  </PropertyList>
   Line 77: Line 78:  
'''/offsets/pitch-deg''' <br>
 
'''/offsets/pitch-deg''' <br>
 
The angle by which to rotate the model around the y-axis. <br>
 
The angle by which to rotate the model around the y-axis. <br>
For example, if you wanted to use the 3D model my-cessna.wrl but found that the nose was pointing to the right instead of straight-ahead and the wheels were 1.5 metres off the ground, you could reorient it in the XML wrapper file like this:
+
For example, if you wanted to use the 3D model my-cessna.ac but found that the nose was pointing to the right instead of straight-ahead and the wheels were 1.5 metres off the ground, you could reorient it in the XML wrapper file like this:
    
  <PropertyList>
 
  <PropertyList>
   <path>my-cessna.wrl</path>
+
   <path>my-cessna.ac</path>
 
   <offsets>
 
   <offsets>
 
     <pitch-deg>0</pitch-deg>   
 
     <pitch-deg>0</pitch-deg>   
Line 128: Line 129:  
  </animation>
 
  </animation>
   −
Note the omission of the leading slash '/' when reffering to the property. This assures that when the model is used for AI traffic the animations will follow that of the AI controller instead of that of the user.
+
Note the omission of the leading slash '/' when reffering to the property. This assures that when the model is used for [[AI traffic]] the animations will follow that of the AI controller instead of that of the user.
    
This example rotates the rudder according to the value of the controls/rudder property (or at least, it will when we specify the center and axis of rotation below); however, controls/rudder is normalized from -1.0 to 1.0, and we probably want to rotate the rudder more than that; as a result, we need to use the factor property to do scaling. For example, if the rudder on the actual aircraft rotates 18 degrees in each direction, we would use a factor of 18 to scale the rudder position from -18 degrees to 18 degrees:
 
This example rotates the rudder according to the value of the controls/rudder property (or at least, it will when we specify the center and axis of rotation below); however, controls/rudder is normalized from -1.0 to 1.0, and we probably want to rotate the rudder more than that; as a result, we need to use the factor property to do scaling. For example, if the rudder on the actual aircraft rotates 18 degrees in each direction, we would use a factor of 18 to scale the rudder position from -18 degrees to 18 degrees:
Line 284: Line 285:  
  </nowiki>
 
  </nowiki>
   −
You can get a lot of your initial measurements and name or rename objects by viewing the model in a 3D editor like Blender or AC3D, so they can be animated in FlightGear. In the end, you'll  most likely have to do a little tweaking by trial and error until everything looks right.
+
You can get a lot of your initial measurements and name or rename objects by viewing the model in a 3D editor like [[Blender]] or [[AC3D]], so they can be animated in FlightGear. In the end, you'll  most likely have to do a little tweaking by trial and error until everything looks right.
     

Navigation menu