8,807
edits
Paul Richter (talk | contribs) (make all the examples consistent) |
m (Remove airline from texture tag, else people might think they need to make a different tag per airline ;) + syntaxhighlighting) |
||
| Line 20: | Line 20: | ||
=== Models/Liveries === | === Models/Liveries === | ||
For every livery we need to make a file. Let's say we got a KLM livery, we then need to make a file called <tt>KLM.xml</tt> in our <tt>Models/Liveries</tt> directory. When a particular livery is selected, its XML file is copied to the aircraft's property tree. On the pilot's side this is the main property tree <tt>/</tt>, and on all remote machines on the MP network it's one of the multiplayer branches in <tt>/ai/models/multiplayer[]</tt>. The structure of livery XML files is completely free. There just has to be a property containing a name for the selection dialog, and <tt>aircraft.livery.init()</tt> must be told which it is. By default it is <tt>sim/model/livery/name</tt>. | For every livery we need to make a file. Let's say we got a KLM livery, we then need to make a file called <tt>KLM.xml</tt> in our <tt>Models/Liveries</tt> directory. When a particular livery is selected, its XML file is copied to the aircraft's property tree. On the pilot's side this is the main property tree <tt>/</tt>, and on all remote machines on the MP network it's one of the multiplayer branches in <tt>/ai/models/multiplayer[]</tt>. The structure of livery XML files is completely free. There just has to be a property containing a name for the selection dialog, and <tt>aircraft.livery.init()</tt> must be told which it is. By default it is <tt>sim/model/livery/name</tt>. | ||
<syntaxhighlight> | |||
<?xml version="1.0"?> | <?xml version="1.0"?> | ||
| Line 28: | Line 28: | ||
<livery> | <livery> | ||
<name type="string">KLM Royal Dutch Airlines</name> | <name type="string">KLM Royal Dutch Airlines</name> | ||
< | <747-texture>Liveries/KLM.png</747-texture> | ||
</livery> | </livery> | ||
</model> | </model> | ||
</sim> | </sim> | ||
</PropertyList> | </PropertyList> | ||
</syntaxhighlight> | |||
In the example above, the texture files are also stored in the <tt>Models/Liveries/</tt> directory of the aircraft; the texture path is relative to the model's xml in which it is used. | In the example above, the texture files are also stored in the <tt>Models/Liveries/</tt> directory of the aircraft; the texture path is relative to the model's xml in which it is used. | ||
| Line 38: | Line 39: | ||
=== Models/....xml === | === Models/....xml === | ||
The first part is related to the nasal script. <tt>("Aircraft/747/Models/Liveries");</tt> points FlightGear to the directory where we store our liveries. This is a different directory for every plane, but there should be only one folder for one plane, containing all the liveries for that plane. Add the following code to your models .xml file: | The first part is related to the nasal script. <tt>("Aircraft/747/Models/Liveries");</tt> points FlightGear to the directory where we store our liveries. This is a different directory for every plane, but there should be only one folder for one plane, containing all the liveries for that plane. Add the following code to your models .xml file: | ||
<syntaxhighlight> | |||
<nasal> | <nasal> | ||
<load> | <load> | ||
var livery_update = aircraft.livery_update.new("Aircraft/747/Models/Liveries"); | var livery_update = aircraft.livery_update.new("Aircraft/747/Models/Liveries"); | ||
</load | </load> | ||
<unload> | <unload> | ||
livery_update.stop(); | livery_update.stop(); | ||
</unload> | </unload> | ||
</nasal> | </nasal> | ||
</syntaxhighlight> | |||
The second part is very important and probably the hardest of all. We need to set which parts of the model should change when you select a new livery. To find the object-names, you could make use of 3D modelling software like [[Blender]] or [[AC3D]]. The <tt><texture>Liveries/KLM.png</texture></tt> part points FlightGear to the livery that should be shown on startup. | The second part is very important and probably the hardest of all. We need to set which parts of the model should change when you select a new livery. To find the object-names, you could make use of 3D modelling software like [[Blender]] or [[AC3D]]. The <tt><texture>Liveries/KLM.png</texture></tt> part points FlightGear to the livery that should be shown on startup. | ||
'''Warning: be sure you don't have a slash (/) in front of sim/model/livery in the <property-base> tag! Otherwise, all planes will get the same livery!''' | '''Warning: be sure you don't have a slash (/) in front of sim/model/livery in the <property-base> tag! Otherwise, all planes will get the same livery!''' | ||
<syntaxhighlight> | |||
<animation> | <animation> | ||
<type>material</type> | <type>material</type> | ||
| Line 59: | Line 61: | ||
<object-name>Vstab</object-name> | <object-name>Vstab</object-name> | ||
<property-base>sim/model/livery</property-base> | <property-base>sim/model/livery</property-base> | ||
<texture-prop> | <texture-prop>747-texture</texture-prop> | ||
<texture>Liveries/KLM.png</texture> | <texture>Liveries/KLM.png</texture> | ||
</animation> | </animation> | ||
</syntaxhighlight> | |||
=== Nasal/liveries.nas === | === Nasal/liveries.nas === | ||
| Line 70: | Line 73: | ||
=== ...-set.xml === | === ...-set.xml === | ||
The follow part is really important. If this is not included, the livery changes will not be visible over MP! | The follow part is really important. If this is not included, the livery changes will not be visible over MP! | ||
<syntaxhighlight> | |||
<model> | <model> | ||
<path>Aircraft/.../models/....xml</path> | <path>Aircraft/.../models/....xml</path> | ||
| Line 77: | Line 80: | ||
</livery> | </livery> | ||
</model> | </model> | ||
</syntaxhighlight> | |||
If you want the default livery to be something else than the first in the list, replace the file type part with the following, containing the Models/Liveries/....xml file name of the appropriate livery. | If you want the default livery to be something else than the first in the list, replace the file type part with the following, containing the Models/Liveries/....xml file name of the appropriate livery. | ||
<syntaxhighlight> | |||
<file type="string">KLM</file> | <file type="string">KLM</file> | ||
</syntaxhighlight> | |||
To make a nice button in the [[menubar]] we need to add the following code, just above the <tt></sim></tt> tag. | To make a nice button in the [[menubar]] we need to add the following code, just above the <tt></sim></tt> tag. | ||
<syntaxhighlight> | |||
<menubar> | <menubar> | ||
<default> | <default> | ||
| Line 99: | Line 105: | ||
</default> | </default> | ||
</menubar> | </menubar> | ||
</syntaxhighlight> | |||
== Multiple texture files per livery == | == Multiple texture files per livery == | ||
| Line 108: | Line 115: | ||
=== Models/Liveries === | === Models/Liveries === | ||
Instead of just one texture we have to deal with multiple ones now. | Instead of just one texture we have to deal with multiple ones now. | ||
<syntaxhighlight> | |||
<?xml version="1.0"?> | <?xml version="1.0"?> | ||
| Line 122: | Line 129: | ||
</sim> | </sim> | ||
</PropertyList> | </PropertyList> | ||
</syntaxhighlight> | |||
=== Models/....xml === | === Models/....xml === | ||
<syntaxhighlight> | |||
<animation> | <animation> | ||
<type>material</type> | <type>material</type> | ||
| Line 141: | Line 149: | ||
<texture>KLM-Livery-wings.png</texture> | <texture>KLM-Livery-wings.png</texture> | ||
</animation> | </animation> | ||
</syntaxhighlight> | |||
Note that the texture-prop in both animations are different. They should match the tags around the textures in your <tt>Models/Liveries/</tt> files. | Note that the texture-prop in both animations are different. They should match the tags around the textures in your <tt>Models/Liveries/</tt> files. | ||