Howto:Creating 3D instruments: Difference between revisions

Jump to navigation Jump to search
add how to include instrument into aircraft
mNo edit summary
(add how to include instrument into aircraft)
Line 160: Line 160:


Now, if you've managed to stay with us the whole way through, the file should look something like this one, which you can download and compare with. [[Media:itt.xml]]  Notice that under each new opening xml tag (such as <animation>) the text is indented one more level.  Sensible people(!) use one tab to indent each level, others try to use various numbers of spaces to indent; whatever you use, the single most important thing is to be consistent.  Consistent indentation makes the file much easier to read.
Now, if you've managed to stay with us the whole way through, the file should look something like this one, which you can download and compare with. [[Media:itt.xml]]  Notice that under each new opening xml tag (such as <animation>) the text is indented one more level.  Sensible people(!) use one tab to indent each level, others try to use various numbers of spaces to indent; whatever you use, the single most important thing is to be consistent.  Consistent indentation makes the file much easier to read.
'''Including the instrument in an aircraft:'''
Now to the exciting bit, actually seeing the fruits of our labour in FlightGear! 
Including our itt.xml file in the fokker50 is actually an easy step.  The "model" XML file controls the 3d model; this is often called aircraftname-model.xml and nearly always lives in the aircraftname/Models directory.  However, FG is very flexible and in this case, the model XML file is  fokker50/Models/fokker50.xml .  To avoid confusion, it would be preferable for this to be called fokker50-model.xml, and if you're creating one from scratch, please use that convention.
If we open that file in a text editor, it should look quite familiar; you will recognise the way it specifies an ac3d file, and animates the various parts of it.  However, we wish to include an instrument, and that is done very simply.  Below the <offsets> section, add a section like this;
<pre>
  <!-- ITT Gauge -->
  <model>
    <offsets>
      <x-m>-8.9088</x-m>
      <y-m>-0.0811</y-m>
      <z-m>-1.0722</z-m>
      <pitch-deg>-10</pitch-deg>
    </offsets>
  </model>
</pre>
Those numbers can be easily obtained from your 3d modelling app; just open the aircraft model and place an object in the correct position, then use the distances here.  The usual FG model coordinate system is used; x=back, y=right, z=up, from the pilot's perspective; the origin is the one in the 3d model (.ac file).  The "pitch" entry is fairly obvious; pitch of zero is a completely vertical instrument, pitch of -90 is one tilted "top edge forwards" to lie flat.
Now, when you start flightgear, you should see your fully-working instrument in all its glory, situated where it ought to be!  If you need to move it later, it's trivial to tweak the numbers above to suit.
57

edits

Navigation menu