This is now in cvs. A "material" animation can manipulate all material
properties of a an ssgSimpleState. These are:

  diffuse-{red,green,blue,factor,offset}    \
  ambient-{red,green,blue,factor,offset}    |  see "man glMaterial"
  specular-{red,green,blue,factor,offset}   |
  emission-{red,green,blue,factor,offset}   /

  transparency              = 1.0 - alpha
  threshold                 = alpha-clamp (see "man glAlphaFunc";
                                           func is always GL_GREATER)
  texture                   string, relative to "texture-path"

Numbers are clamped to 0.0-1.0, except "shininess", which is clamped to 0-128.


This sets the fuselage color to a warm yellow. If one sets the "global"
property to "true", then not only the fuselage color is changed, but the
fuselage *material*. That is: all objects using this material will be yellow.
This is preferred to listing several objects in <object-name> tags. It's not
only faster, but also doesn't break animations by forcing objects together.
Fixed values are mainly useful for cases where two *-set.xml files use the
same 3D model. One can then make the aircraft shiny blue, and the other dull.
This couldn't be done by changing the textures only!

By appending "-prop", each of the properties can also read its value from
another property. This is for live-update: 

      <global type="bool">true</global>

It's a good idea to set these referred properties in the *-set.xml file:


It's not necessary to name these properties with the material animation's
terminology ("diffuse-red" etc.), but if you do so, you can open the
material dialog from another Nasal file or a Nasal key binding:


and get a dialog like these:   [44 kB]

In this screenshot I used the material dialog for three materials. It's three
times the same dialog, but it only displays the elements of the respective 
node. (See $FG_ROOT/Aircraft/bo105/ for an example). The "emblem" window, for
example, has only a "texture" property. This texture can be changed at runtime!

It's no longer necessary, for an alternative livery to duplicate *all* textures
and to set the path in <texture-path>. Instead, one can select textures for
particular objects via property. This can save a lot of diskspace. Also, it's
no longer necessary to put several logos into one huge texture file only to
be able to change a logo at runtime (via "textranslate" animation). Instead,
the whole texture can be replaced, and plib frees the memory for no longer
used textures (or at least is supposed to). Of course, this shouldn't be used
for single digits of a number display.

The updated bo105 uses this "texture" feature for the emblems/insignia. (Note
the difference of the emblem when you start from KSFO, from LTAG, and from
LLBG!) With the "Shift-C" key you get a material dialog for the fuselage.
With the "c" key you can switch the whole helicopter to a different variant,
with different colors/emblems. The default machine is still yellow, but there
are others ...  [22 kB]  (no animated
submodels for these toys, yet.  ;-)

Now, this does all sound like a lot of work for plib/sg, and as if a
material animation were expensive in terms of performance. It isn't.


PS: thanks go to Jim for his "material-emission" animation, which I hacked
    for this, and which is now removed.

Flightgear-devel mailing list

Reply via email to