2,733
edits
(→Related content: + Aircraft-set.xml, Howto:Edit a livery, $FG_ROOT/Nasal/aircraft.nas) |
Red Leader (talk | contribs) (Cleanup, although there are some more bits & pieces that could still be improved) |
||
| Line 1: | Line 1: | ||
[[File: | [[File:Livery selection dialog.jpg|thumb|270px|The livery selection dialog of the [[Sikorsky S76C]].]] | ||
On this page we describe how you make use of a script to get a '''livery selection dialog''' for an [[aircraft]] or [[vehicle]] in [[FlightGear]]. To get new liveries, you need to have them available with this script. | On this page we describe how you make use of a script to get a '''livery selection dialog''' for an [[aircraft]] or [[vehicle]] in [[FlightGear]]. To get new liveries, you need to have them available with this script. | ||
If you want to add a new livery to a plane that already makes use of the livery select system, you'll only have to follow the steps under [[#Models/Liveries|Models/Liveries]]. | |||
== A note to those who wish to make a livery == | == A note to those who wish to make a livery == | ||
| Line 9: | Line 9: | ||
A paintkit is where you create a blank livery which shows only constructional elements like bolts, rivets, windows, doors and panels. This is done so any other users looking to create their own livery can make a realistic looking livery with these construction elements, without having to redraw them or trying to avoid painting over them. This makes the process of creating a livery a more fun and less stressful task. | A paintkit is where you create a blank livery which shows only constructional elements like bolts, rivets, windows, doors and panels. This is done so any other users looking to create their own livery can make a realistic looking livery with these construction elements, without having to redraw them or trying to avoid painting over them. This makes the process of creating a livery a more fun and less stressful task. | ||
Paintkits are usually provided within the aircraft's < | Paintkits are usually provided within the aircraft's <code>Models/</code> directory and/or at [http://liveries.flightgear.org/paintkits.php the livery database]. | ||
== Files to edit == | == Files to edit == | ||
There are a few files we need to make (or edit), namely: | There are a few files we need to make (or edit), namely: | ||
* < | * <code>aircraft/[[aircraft-set.xml]]</code> | ||
* < | * <code>aircraft/Models/model.xml</code> | ||
* < | * <code>aircraft/Nasal/liveries.nas</code> | ||
We also have to make a new directory to store our liveries in. Let's make it < | Where ''aircraft'' is the name of the aircraft. | ||
We also have to make a new directory to store our liveries in. Let's make it <code>aircraft/Models/Liveries</code>. | |||
=== Models/Liveries === | === Models/Liveries === | ||
For every livery we need to make a file. | For every livery, we need to make a file. For example, if you have made a KLM livery, then you need to make a file called <code>KLM.xml</code> in the <code>Models/Liveries</code> 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 base of the property tree (<code>/</code>), and on all remote machines on the MP network it's one of the multiplayer branches in <code>/ai/models/multiplayer[''n'']</code>. The structure of livery XML files is completely free. There just has to be a property containing a name for the selection dialog, and <code>aircraft.livery.init()</code> must be told which it is. By default it is <code>sim/model/livery/name</code>. | ||
<syntaxhighlight> | <syntaxhighlight lang="xml"> | ||
<?xml version="1.0" encoding="UTF-8"?> | |||
<PropertyList> | |||
<sim> | |||
<model> | |||
<livery> | <livery> | ||
<name type="string">KLM Royal Dutch Airlines</name> | |||
<texture>Liveries/KLM.png</texture> | |||
</livery> | </livery> | ||
</model> | |||
</sim> | |||
</PropertyList> | |||
</syntaxhighlight> | </syntaxhighlight> | ||
In the example above, the texture files are also stored in the < | In the example above, the texture files are also stored in the <code>Models/Liveries/</code> directory of the aircraft; the texture path is relative to the model's xml in which it is used. | ||
=== Models/ | === Models/model.xml === | ||
The first part is related to the nasal script. < | The first part is related to the nasal script. <code>aircraft.livery_update.new("Aircraft/747/Models/Liveries");</code> 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 model.xml file: | ||
<syntaxhighlight> | <syntaxhighlight lang="xml"> | ||
<nasal> | <?xml version="1.0" encoding="UTF-8"?> | ||
<load> | |||
<PropertyList> | |||
</load> | |||
<nasal> | |||
<load><![CDATA[ | |||
var livery_update = aircraft.livery_update.new("Aircraft/747/Models/Liveries"); | |||
]]></load> | |||
<unload> | <unload><![CDATA[ | ||
livery_update.stop(); | |||
</unload> | ]]></unload> | ||
</nasal> | |||
<!-- ... --> | |||
</PropertyList> | |||
</syntaxhighlight> | </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 < | 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 <code><texture>Liveries/KLM.png</texture></code> part points FlightGear to the livery that should be shown on startup. | ||
{{caution|Be sure you don't have a slash (/) in front of <code>sim/model/livery</code> in the <code><property-base></code> tag! Otherwise, all planes will get the same livery!}} | |||
<syntaxhighlight lang="xml"> | |||
<!-- ... --> | |||
<animation> | |||
<type>material</type> | <type>material</type> | ||
<object-name>Fuselage</object-name> | |||
<object-name>Hstab</object-name> | |||
<object-name>Vstab</object-name> | |||
<property-base>sim/model/livery</property-base> | |||
<texture-prop>texture</texture-prop> | |||
<texture>Liveries/KLM.png</texture> | |||
</animation> | |||
<!-- ... --> | |||
</syntaxhighlight> | </syntaxhighlight> | ||
=== Nasal/liveries.nas === | === Nasal/liveries.nas === | ||
The only thing you might change in the nasal file is the directory of the liveries. If you don't have the livery name in < | The only thing you might change in the nasal file is the directory of the liveries. If you don't have the livery name in <code>sim/model/livery/name</code>, then you have to add this as second function argument. | ||
<syntaxhighlight lang="nasal"> | |||
aircraft.livery.init("Aircraft/.../Models/Liveries"); | |||
</syntaxhighlight> | |||
=== aircraft-set.xml === | |||
The following part is really important. If this is not included, the livery changes will not be visible over MP! | |||
<syntaxhighlight lang="xml"> | |||
<sim> | |||
<!-- ... --> | |||
<model> | |||
<path>Aircraft/.../Models/model.xml</path> | |||
<livery> | |||
<file type="string"/> | |||
</livery> | |||
</model> | |||
<!-- ... --> | |||
</sim> | |||
</syntaxhighlight> | </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> | <syntaxhighlight lang="xml"> | ||
<file type="string">KLM</file> | |||
</syntaxhighlight> | </syntaxhighlight> | ||
To make a nice button in the [[menubar]] we need to add the following code | To make a nice button in the [[menubar]] we need to add the following code: | ||
<syntaxhighlight lang="xml"> | |||
<sim> | |||
< | <!-- ... --> | ||
<menubar> | |||
<default> | |||
<menu n="100"> | |||
<label>...</label> | |||
<enabled type="bool">true</enabled> | |||
<item> | |||
<label>Select Livery</label> | |||
<binding> | |||
<command>nasal</command> | |||
<script>aircraft.livery.dialog.open();</script> | |||
</binding> | |||
</item> | |||
</menu> | |||
</default> | |||
</menubar> | |||
<!-- ... --> | |||
</sim> | |||
</syntaxhighlight> | </syntaxhighlight> | ||
== Multiple texture files per livery == | == Multiple texture files per livery == | ||
Some models use multiple textures file (e.g. separate files for fuselage and wings). Every texture needs it own property. You can add as many textures as you like. | Some models use multiple textures file (e.g., separate files for fuselage and wings). Every texture needs it own property. You can add as many textures as you like. | ||
=== Nasal/liveries.nas === | === Nasal/liveries.nas === | ||
This is the same as "ordinary" aircraft with just one texture. You will find the content of this file earlier in this article. | This is the same as "ordinary" aircraft with just one texture. You will find the content of this file [[#Nasal/liveries.nas|earlier]] in this article. | ||
=== 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> | <syntaxhighlight lang="xml"> | ||
<?xml version="1.0" encoding="UTF-8"?> | |||
<PropertyList> | |||
<sim> | |||
<model> | |||
<livery> | <livery> | ||
<name type="string">KLM Royal Dutch Airlines</name> | |||
<texture-fuselage>KLM-Livery-fuselage.png</texture-fuselage> | |||
<texture-wings>KLM-Livery-wings.png</texture-wings> | |||
</livery> | </livery> | ||
</model> | |||
</sim> | |||
</PropertyList> | |||
</syntaxhighlight> | </syntaxhighlight> | ||
=== Models/....xml === | === Models/....xml === | ||
<syntaxhighlight> | <syntaxhighlight lang="xml"> | ||
<!-- ... --> | |||
<animation> | |||
<type>material</type> | |||
<object-name>hull</object-name> | |||
<object-name>nosecone</object-name> | |||
<property-base>sim/model/livery</property-base> | |||
<texture-prop>texture-fuselage</texture-prop> | |||
<texture>KLM-Livery-fuselage.png</texture> | |||
</animation> | |||
<animation> | |||
<type>material</type> | |||
<object-name>left-flap</object-name> | |||
<object-name>left-aileron</object-name> | |||
<property-base>sim/model/livery</property-base> | |||
<texture-prop>texture-wings</texture-prop> | |||
<texture>KLM-Livery-wings.png</texture> | |||
</animation> | |||
<!-- ... --> | |||
</syntaxhighlight> | </syntaxhighlight> | ||
=== | Note that the texture-prop in both animations are different. They should match the tags around the textures in your <code>Models/Liveries/</code> files. | ||
=== aircraft-set.xml === | |||
Is the same as "ordinary" aircraft with just one texture. You will find the content of this file earlier in this article. | Is the same as "ordinary" aircraft with just one texture. You will find the content of this file earlier in this article. | ||
== Performance Improvements == | == Performance Improvements == | ||
For livery changing it seems to be important to parent all objects with the same texture. | For livery changing it seems to be important to parent all objects with the same texture. | ||
In Blender select all objects and press {{Key press| | In Blender select all objects and press {{Key press|Ctrl|p}} to make it parent to the last selected. E.g.: fuselage and doors with the same texture: select at first the doors and then at last the fuselage and press {{Key press|Ctrl|p}}. | ||
Depending on your model and their object origins, the model can be a mess afterwards. | Depending on your model and their object origins, the model can be a mess afterwards. | ||
To fix this, you have to reset your objects' origin, having them at a 0 offset in relation to the parent. | To fix this, you have to reset your objects' origin, having them at a 0 offset in relation to the parent. | ||
* Use {{Key press| | * Use {{Key press|Shift|c}} to reset the cursor to scene origin (0,0,0). | ||
* Next, select the parent -> Object -> Transform -> Origin to 3d-cursor. | * Next, select the parent -> Object -> Transform -> Origin to 3d-cursor. | ||
* Then, with the parent still selected-> {{Key press| | * Then, with the parent still selected-> {{Key press|Shift|g}} -> Children (to select all children objects). | ||
* {{Key press| | * {{Key press|Alt|p}} -> Clear parent and keep transform (to clear the "wrong" parent relationship) | ||
* then keeping all the children selected: Object -> Transform -> Origin to 3d Cursor. | * then keeping all the children selected: Object -> Transform -> Origin to 3d Cursor. | ||
* Then with the children still selected, shift select the parent, {{Key press| | * Then with the children still selected, shift select the parent, {{Key press|Ctrl|p}} -> Object (to re-parent them). | ||
Do not parent glass and/or other transparent objects to the main parent. Also, if using different effects on different objects, those with a different effect cannot be parented to the main parent (they will have their effect overwritten by the parent's) | Do not parent glass and/or other transparent objects to the main parent. Also, if using different effects on different objects, those with a different effect cannot be parented to the main parent (they will have their effect overwritten by the parent's) | ||
Also prevent transparency where possible | Also prevent transparency where possible — it will prevent lags while switching the views. | ||
Also see the [[Grumman F-14 Tomcat| | Also see the [[Grumman F-14 Tomcat|F-14B]] as a very good example! | ||
== Testing == | == Testing == | ||
To ensure that your livery setup works correctly over MP, start two instances of FlightGear locally | To ensure that your livery setup works correctly over MP, you can start two instances of FlightGear locally. See [[Howto:Multiplayer#Local setup for testing|Howto:Multiplayer § Local setup for testing]] for details | ||
== Sharing your liveries == | == Sharing your liveries == | ||
| Line 187: | Line 222: | ||
We have some FlightGear hosts, where you can upload your liveries to: | We have some FlightGear hosts, where you can upload your liveries to: | ||
* [http://liveries.flightgear.org FlightGear Liveries] largest FG repository with (almost) all available liveries, based on real aircraft | * [http://liveries.flightgear.org FlightGear Liveries] — ''largest FG repository with (almost) all available liveries, based on real aircraft'' | ||
* [http://unitedfreeworld.com UnitedFreeWorld] repository with lots of liveries (and scenery/aircraft), both realistic and fictional | * [http://unitedfreeworld.com UnitedFreeWorld] — ''repository with lots of liveries (and scenery/aircraft), both realistic and fictional'' | ||
== Related content == | == Related content == | ||
| Line 198: | Line 233: | ||
* {{fgdata file|Nasal/aircraft.nas|l=491}} | * {{fgdata file|Nasal/aircraft.nas|l=491}} | ||
[[es: | [[es:Livery over MP]] | ||
[[Category:Aircraft enhancement]] | [[Category:Aircraft enhancement]] | ||