Livery over MP: Difference between revisions

Jump to navigation Jump to search
m
cleaner multi-texture solution
m (remove CVS reference)
m (cleaner multi-texture solution)
Line 1: Line 1:
[[Image:Livery_selection_dialog.jpg|thumb|270px|The livery selection dialog of the [[Sikorsky S76C]].]]
[[Image: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 a [[Aircraft|plane]] 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]].'''
'''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]].'''
Line 7: Line 6:
==Files==
==Files==
There are a few files we need to make (or edit), namely:
There are a few files we need to make (or edit), namely:
* <tt>dr400-set.xml</tt>
* <tt>...-set.xml</tt>
* <tt>Models/dr400.xml</tt>
* <tt>Models/....xml</tt>
* <tt>Nasal/liveries.nas</tt>
* <tt>Nasal/liveries.nas</tt>
We also have to make a new directory to store our liveries in. Let's make it <tt>Aircraft/DR400/Models/Liveries</tt>.
We also have to make a new directory to store our liveries in. Let's make it <tt>Aircraft/.../Models/Liveries</tt>.


===Models/Liveries===
===Models/Liveries===
For every livery we need to make a file. Let's say we got a Rescue livery, we then need to make a file called Rescue.xml in our <tt>Models/Liveries</tt> directory. When a particular livery gets 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 Rescue 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>.


  <?xml version="1.0"?><nowiki>
  <?xml version="1.0"?>
</nowiki>
  <PropertyList>
  <PropertyList>
   <sim>
   <sim>
   <model>
   <model>
     <livery>
     <livery>
     <name type="string">Default</name>
     <name type="string">KLM Royal Dutch Airlines</name>
     <texture>texture.rgb</texture>
     <texture>Liveries/KLM.png</texture>
     </livery>
     </livery>
   </model>
   </model>
Line 28: Line 27:
  </PropertyList>
  </PropertyList>


===Models/dr400.xml===
In the example above, the texture files are also stored in the <tt>Models/Liveries/</tt> directory of the aircraft.
 
===Models/....xml===
The first part is related to the nasal script. <tt>("Aircraft/DR400/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/DR400/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:


Line 41: Line 42:
  </nasal>
  </nasal>


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 software like [[Blender]] or [[AC3D]]. The <tt><texture>S76livery.rgb</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!'''
Line 47: Line 48:
  <animation>
  <animation>
   <type>material</type>
   <type>material</type>
   <object-name>LHgeardoor</object-name>
   <object-name>Fuselage</object-name>
   <object-name>RHgeardoor</object-name>
   <object-name>Hstab</object-name>
   <object-name>S76C</object-name>
   <object-name>Vstab</object-name>
  <object-name>RF.door</object-name>
  <object-name>LF.door</object-name>
  <object-name>Rr.Door</object-name>
  <object-name>Lr.Door</object-name>
  <object-name>RHbaggage</object-name>
  <object-name>LHbaggage</object-name>
  <object-name>RHfrtgeardoor</object-name>
  <object-name>LHfrtgeardoor</object-name>
   <property-base>sim/model/livery</property-base>
   <property-base>sim/model/livery</property-base>
   <texture-prop>texture</texture-prop>
   <texture-prop>texture</texture-prop>
   <texture>texture.rgb</texture>
   <texture>Liveries/KLM.png</texture>
  </animation>
  </animation>


Line 66: Line 59:
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 <tt>sim/model/livery/name</tt>, then you have to add this as second function argument.
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 <tt>sim/model/livery/name</tt>, then you have to add this as second function argument.


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


===dr400-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!


  <model>
  <model>
   <path>Aircraft/DR400/models/dr400.xml</path>
   <path>Aircraft/.../models/....xml</path>
   <livery>
   <livery>
   <file type="string"/>
   <file type="string"/>
Line 87: Line 80:
   <default>
   <default>
   <menu n="100">
   <menu n="100">
     <label>Robin DR 400</label>
     <label>...</label>
     <enabled type="bool">true</enabled>
     <enabled type="bool">true</enabled>
     <item>
     <item>
Line 103: Line 96:
Some models use multiple textures file (eg. seperate files for wings and fuselage). Every texture needs it own property. You can add as many textures as you like.  
Some models use multiple textures file (eg. seperate files for wings and fuselage). Every texture needs it own property. You can add as many textures as you like.  


The given examples are based on the [[Boeing 787]].
===Nasal/liveries.nas===
Is the same as "ordinary" aircraft with just one texture. You will find the content of this file 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.  


  <?xml version="1.0"?><nowiki>
  <?xml version="1.0"?>
</nowiki>
  <PropertyList>
  <PropertyList>
   <sim>
   <sim>
Line 115: Line 109:
     <livery>
     <livery>
     <name type="string">All Nippon Airways</name>
     <name type="string">All Nippon Airways</name>
     <texture>ANA-Livery.rgb</texture>
     <texture>ANA-Livery.png</texture>
    <lights>ANA-Lights.rgb</lights>
     </livery>
     </livery>
    <lights>
    <texture>ANA-Lights.rgb</texture>
    </lights>
   </model>
   </model>
   </sim>
   </sim>
  </PropertyList>
  </PropertyList>


Remember the names (<livery> and <lights>), as you will need them in the model file in the next step.
Remember the names (<texture> and <lights>), as you will need them in the model file in the next step.


===Models/787.xml===
===Models/....xml===
     <animation>
     <animation>
         <type>material</type>
         <type>material</type>
Line 138: Line 130:
         <type>material</type>
         <type>material</type>
         <object-name>lightedfin_0</object-name>
         <object-name>lightedfin_0</object-name>
         <property-base>sim/model/lights</property-base>
         <property-base>sim/model/livery</property-base>
         <texture-prop>texture</texture-prop>
         <texture-prop>lights</texture-prop>
         <texture>ANA-Lights.rgb</texture>
         <texture>ANA-Lights.rgb</texture>
     </animation>
     </animation>


===Performance Improvements===
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.
 
===...-set.xml===
Is the same as "ordinary" aircraft with just one texture. You will find the content of this file earlier in this article.
 
==Performance Improvements==
For livery changing it seems to be  important to parent all objects with the same texture. In Blender select all objects and press "ctr-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 "ctr-p".  
For livery changing it seems to be  important to parent all objects with the same texture. In Blender select all objects and press "ctr-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 "ctr-p".  


Line 165: Line 162:


[[Category:Aircraft enhancement]]
[[Category:Aircraft enhancement]]
[[Category:Menubar]]
[[Category:Modeling]]
[[Category:Modeling]]
[[Category:Menubar]]

Navigation menu