I've just enhanced the aircraft.livery class with methods for
easier livery handling over MP. (You also need to update fgfs
to make it work).



Livery HOWTO
------------

(1) add a livery dir, let's say $FG_ROOT/Aircraft/foo/Models/Liveries/
    and put an XML file fore every livery in it. For example, a file
    $FG_ROOT/Aircraft/foo/Models/Liveries/pink.xml with the following
    contents:

      <?xml version="1.0"?>

      <PropertyList>
          <sim>
              <model>
                  <livery>
                      <name type="string">Pink Foo</name>
                      <!--  <index type="int">100</index>   see (3) -->
                      <texture>ugly_pink.png</texture>
                  </livery>
              </model>
          </sim>
      </PropertyList>



(2) initialize the /sim/model/livery/file property in the foo-set.xml file
    (this property will be transmitted over MP):

      <sim>
          <model>
              <path>Aircraft/foo/Models/foo.xml</path>

              <livery>
                  <file type="string">pink</file>
              </livery>
          </model>
      </sim>

    The file property shall contain the base name of a livery file, that
    is "pink" for $FG_ROOT/Aircraft/foo/Models/Liveries/pink.xml. (This
    is to keep the MP package small.)



(3) initialize the livery class somewhere in a Nasal context (but *not*
    embedded in the animation XML file!)

      aircraft.livery.init("Aircraft/foo/Models/Liveries");

    As second, optional argument you can specify the property path in
    the livery file that contains the livery name for the dialog.
    Default is "sim/model/livery/name". The entries in the selection
    box will be sorted by name.

    If you need more control over the sorting order, you can add a
    third argument (default: "sim/model/livery/index"). This property
    should contain sequential numbers, by which the entries in the
    dialog box will be sorted. It's probably better to use 100, 200, 300,
    so that you can later easily insert new liveries without having to
    adjust the indices in all files.



(4) in the animaion XML file add a <nasal> block like so:

      <nasal>
          <load>
              var livery_update = 
aircraft.livery.update("Aircraft/foo/Models/Liveries");
          </load>

          <unload>
              livery_update.stop();
          </unload>
      </nasal>

    This code will then be called when the model is loaded or unloaded.
    It will check the livery every 10 seconds and whenever it changed,
    copy the livery file to the MP aircrafts property branch, from which
    animations will pick up the parameters.

m.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to