Board index FlightGear Development Aircraft Liveries

livery setup aircraft.livery.update.new(...) not running.

Discussion of aircraft textures and liveries

livery setup aircraft.livery.update.new(...) not running.

Postby hvengel » Fri Jul 25, 2014 3:08 am

OK I am trying to follow the steps on the wiki for setting up livery support. My model is a little more complex than most and I am running into some issues. Most of it seems to be OK and I have it to the point where it is displaying the default livery I have set when FG starts up. Although performance is absolutely atrocious when things first start up as it seems to not load the default livery until I try to move the view around. The main issue I am having is that it appears that the nasal code in the model xml is not being executed as I see this:

Nasal runtime error: No such member: dialog at /sim/bindings/menu/binding[102], line 3


When I click on the livery select menu item. Here is the relevant code perhaps someone can give me a clue about what I am doing wrong.

p51d/Models/p51d.xml:

Code: Select all
  <nasal>
    <load>
      var self = cmdarg();
     print("LOAD P-51D-25NA ", self.getPath());  # I never see this in the console???
      var livery_update = aircraft.livery_update.new("Aircraft/p51d/Models/Liveries", 10);
    </load>
 
    <unload>
      print("UNLOAD P-51D-25NA ", self.getPath());
      livery_update.stop();
    </unload>
 </nasal>

 <animation>
  <type>material</type>
   <object-name>wingRight</object-name>
   <object-name>flapsRight</object-name>
   <object-name>aileronRight</object-name>
   <object-name>aileronTrimTabRight</object-name>
   <object-name>innerGearDoorRight</object-name>
   <object-name>outerDoorRight</object-name>
   <object-name>AN-104A</object-name>
   <object-name>gunBastTubeFairingRight</object-name>
   <object-name>gunBastTubeFairingLeft</object-name>
   <object-name>tailFaringLeft</object-name>
   <property-base>sim/model/livery</property-base>
   <texture-prop>texture-wing1</texture-prop>
   <texture>Liveries/DDwing1.png</texture>
 </animation>
 
 <animation>
  <type>material</type>
   <object-name>wingLeft</object-name>
   <object-name>flapsLeft</object-name>
   <object-name>aileronLeft</object-name>
   <object-name>aileronTrimTabLeft</object-name>
   <object-name>innerGearDoorLeft</object-name>
   <object-name>outerDoorLeft</object-name>
   <object-name>tailLightfixture</object-name>
   <object-name>rudder</object-name>
   <object-name>rudderTrimTab</object-name>
   <object-name>rudderTrimLinkageFairing</object-name>
   <object-name>VerticalStab</object-name>
   <object-name>elevatorTrimTabLeft</object-name>   
   <object-name>elevatorTrimTabRight</object-name>
   <object-name>elevator</object-name>
   <object-name>horizontalStabilizer</object-name>
   <object-name>rudderTrimTab</object-name>
   <object-name>rudderTrimLinkageFairing</object-name>
   <object-name>VerticalStab</object-name>
   <object-name>elevatorTrimTabLeft</object-name>
   <property-base>sim/model/livery</property-base>
   <texture-prop>texture-wing2</texture-prop>
   <texture>Liveries/DDwing2.png</texture>
 </animation>
 
 <animation>
  <type>material</type>
   <object-name>fuselage</object-name>
   <object-name>wingFilletLeft</object-name>
   <object-name>wingFilletRight</object-name>
   <object-name>cowl</object-name>
   <object-name>tailWheelDoorLeft</object-name>
   <object-name>tailWheelDoorRight</object-name>
   <object-name>coolingDoor</object-name>
   <object-name>oilCoolerDoor</object-name>
   <object-name>tailFaringLeft</object-name>
   <object-name>tailFaringLeft</object-name>
   <object-name>dogHouse</object-name>
   <property-base>sim/model/livery</property-base>
   <texture-prop>texture-fuselage</texture-prop>
   <texture>Liveries/DDfuselage.png</texture>
 </animation>


Default (and only) livery, p51d/Models/Liveries/DD.xml:

Code: Select all
<?xml version="1.0"?>
 
 <PropertyList>
  <sim>
   <model>
    <livery>
     <name type="string">Delivery Day - March 1944</name>
     <texture-fuselage>Liveries/DDfuselage.png</texture-fuselage>
     <texture-wing1>Liveries/DDwing1.png</texture-wing1>
     <texture-wing2>Liveries/DDwing2.png</texture-wing2>
     <texture-spinner>Liveries/DDspinner.png</texture-spinner>
     <texture-spinner2>Liveries/DDspinner2.png</texture-spinner2>
     <texture-enclosure>../Liveries/DDenclosure.png</texture-enclosure>
    </livery>
   </model>
  </sim>
 </PropertyList>


p51d/Models/propDisk.xml:

Code: Select all
 <animation>
  <type>material</type>
   <object-name>spinner2</object-name>
   <property-base>sim/model/livery</property-base>
   <texture-spinner2>texture-spinner</texture-spinner2>
   <texture>Liveries/DDspinner2.png</texture>
 </animation>


p51d/Models/prop.xml:

Code: Select all
 <animation>
  <type>material</type>
   <object-name>spinner</object-name>
   <property-base>sim/model/livery</property-base>
   <texture-prop>texture-spinner</texture-prop>
   <texture>Liveries/DDspinner.png</texture>
 </animation>


p51d/Models/Cockpit/enclosure.xml:

Code: Select all
 <animation>
   <type>material</type>
   <object-name>canopyLowerSkin</object-name>
   <object-name>exteriorWindshieldBow</object-name>
   <property-base>sim/model/livery</property-base>
   <texture-prop>texture-enclosure</texture-prop>
   <texture>../Liveries/DDenclosure.png</texture>
 </animation>


p51d/Dialogs/menuBar.xml:

Code: Select all
<default>
      <menu n="1100">
          <label>Livery</label>
          <enabled type="bool">true</enabled>
          <item>
             <label>Select Livery</label>
             <binding>
                 <command>nasal</command>
                 <script>
                     print("open livery dialog");
                     aircraft.livery.dialog.open()
                 </script>
              </binding>
          </item>
       </menu>
.......


p51d/p51d-set.xml:

Code: Select all
  <model>
   <path>Aircraft/p51d/Models/p51d.xml</path>
   <livery>
     <file type="string">DD</file>
   </livery>
  </model>
hvengel
Retired
 
Posts: 1127
Joined: Sun Dec 24, 2006 5:35 am
Location: Minden Nevada

Re: livery setup aircraft.livery.update.new(...) not running

Postby Philosopher » Fri Jul 25, 2014 2:10 pm

Go look at yourself over MP ;)

I think I remember (from the bug tracker) that the <nasal><load> is only executed over MP, not locally. See issue #366: https://code.google.com/p/flightgear-bu ... ail?id=366

Doesn't the Wiki say to run this (at some time during init)?
Code: Select all
aircraft.livery.init("Aircraft/.../Models/Liveries");
Philosopher
 
Posts: 1593
Joined: Sun Aug 12, 2012 7:29 pm

Re: livery setup aircraft.livery.update.new(...) not running

Postby hvengel » Fri Jul 25, 2014 4:56 pm

That explains why the <nasal> <load> stuff is not being run.

And no the wiki does not say to run aircraft.livery.init(...). It says to create a livery.nas file with that command (which I did but I missed showing this in the code I posted - sorry) but it does not say anything about how it is invoked. So I guess that means I need to add that file to the <nasal> section of the *set.xml file?

I found the wiki a little hard to read and understand in part because it does not follow normal conversions for documentation. For example it uses ... in a number of different locations with different meanings. This took several readings for me to unravel. For example the nasal command above should probably be documented like this:

Code: Select all
aircraft.livery.init("Aircraft/<aircraft directory>/Models/Liveries");


So that it is totally unambiguous. There are locations where ... is used to denote the livery file name and still other meanings in other locations. I will do some work on the wiki to make this easier for the next person to understand.

Also do I need the <nasal> <load>... section in only the main model xml or do I need this in every model xml that is affected by the livery system (I have 4 models that use a total of 6 textures that need to participate in the livery system)?
hvengel
Retired
 
Posts: 1127
Joined: Sun Dec 24, 2006 5:35 am
Location: Minden Nevada

Re: livery setup aircraft.livery.update.new(...) not running

Postby Philosopher » Fri Jul 25, 2014 5:06 pm

you just need to create one instance of the livery updater, whichever file you want to use. It's basically a remote version of the regular selector dialog.

and of course you need to run the Nasal liveries snippet somehow ;). Personally I would find a snippet embedded in the -set.xml more clean than a 1-line file though...
Philosopher
 
Posts: 1593
Joined: Sun Aug 12, 2012 7:29 pm

Re: livery setup aircraft.livery.update.new(...) not running

Postby hvengel » Fri Jul 25, 2014 5:23 pm

Thanks I will try these things out this evening. After getting this working and putting together at least one OK livery I will migrate things to the 3.2 branch and that will be it for the 3.2 release. Hopefully I can get someone to test things out so that any needed bug fixes can be done before the release.
hvengel
Retired
 
Posts: 1127
Joined: Sun Dec 24, 2006 5:35 am
Location: Minden Nevada

Re: livery setup aircraft.livery.update.new(...) not running

Postby Hooray » Fri Jul 25, 2014 5:25 pm

hvengel wrote in Fri Jul 25, 2014 4:56 pm:For example the nasal command above should probably be documented like this:
Code: Select all
aircraft.livery.init("Aircraft/<aircraft directory>/Models/Liveries");


FWIW, we can probably even do better than that, simply because /sim should have some kind of fg-aircraft property, analogous to $FG_HOME, i.e. $FG_AIRCRAFT - so it could be simplified to something like this (or even done internally in the init method):

Code: Select all
aircraft.livery.init( getprop('/sim/fg-aircraft') ~ '/Models/Liveries');
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: livery setup aircraft.livery.update.new(...) not running

Postby hvengel » Sat Jul 26, 2014 7:09 pm

OK I have the livery stuff basically working. Will start making updates to the wiki page soon. But I have one issue. The wiki says:

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".


I did that and indeed the performance at start up is very much improved. But it takes the various parts of the aircraft and scatters them all over the place in sim. The parts stay in the same place in Blender when setting up the parenting so it is not apparent that something funny is happening when doing this in Blender. What's up with that and how do I prevent it?
hvengel
Retired
 
Posts: 1127
Joined: Sun Dec 24, 2006 5:35 am
Location: Minden Nevada

Re: livery setup aircraft.livery.update.new(...) not running

Postby cbendele » Sat Jul 26, 2014 7:50 pm

Yes, I've had similar problems when setting parents with recent blender versions (starting with 2.6, maybe, but i'm not sure). It also happens when loading files from older blender versions. It THINK it might be because the ac3d export script I'm using (and probably you're using the same) ignores blender's "Parent Inverse" Information. This is a correction matrix that blender sets up when you "parent" some object so that the object's previous transformations do not have to be changed, even though they should now be calculated in relation to the new parent.

The solution I found is, in blender, for each object that looks "broken" in flightgear, clear the parent inverse matrix (select the object, press Alt-P, select "Clear Parent Inverse".
The object will then move to a new position in blender that is "wrong" in exactly the opposite direction from what you saw before in flightgear. [EDIT: actually the object will move to exactly the same "wrong" position that they are in flightgear.] Then reposition the object in blender.

There might be a way to do this more comfortably in blender (clearing the parent inverse and automatically transfer the necessary transformations to keep its position to the objects own transformation matrix).
Unfortunately I'm still looking. Tell me if you find one.

Christian
cbendele
 
Posts: 50
Joined: Fri Jan 14, 2011 11:08 am
Callsign: D-ETRA
Version: 3.0
OS: Archlinux

Re: livery setup aircraft.livery.update.new(...) not running

Postby Gijs » Mon Jul 28, 2014 3:08 pm

hvengel wrote in Fri Jul 25, 2014 4:56 pm:I found the wiki a little hard to read and understand in part because it does not follow normal conversions for documentation.

Feel free to correct it. When you've set up a livery system once it becomes a piece of cake ;-)

Cheers,
Gijs
Airports: EHAM, EHLE, KSFO
Aircraft: 747-400
User avatar
Gijs
Moderator
 
Posts: 9543
Joined: Tue Jul 03, 2007 3:55 pm
Location: Delft, the Netherlands
Callsign: PH-GYS
Version: Git
OS: Windows 10

Re: livery setup aircraft.livery.update.new(...) not running

Postby hvengel » Mon Jul 28, 2014 4:39 pm

Now that I understand what is going on setting up the livery system is fairly simple. If the documentation was not confusing and missing some details then it would have been easy to do the first time. My internet connection was down over the week end and I am hoping that I can get this fixed today and I will fix up the wiki page some time this week.

I have run into a number of issues with the supposedly "perfect" ac3d exporter while doing this project. Unfortunately these issues don't show them selves until after you have done a ton of work so they bite you at the last stages of the project. The major issues with the export are flipping normals on some objects and this latest issue with the export not correctly positioning and rotating (apparently by random amounts) parented objects. When exporting from Blender the resulting ac3d model should look EXACTLY like it does in Blender. That is the result should be WYSIWYG but it is not even close. Normals should not be flipped and objects should not be moved around and rotated. These are both major defects in the exporter. Some of the objects being incorrectly moved and rotated by the exporter are objects that were cut out of the parent object (ailerons, flaps. gear doors that should be parented to the wing they are cut out of) so it makes absolutely no sense that these are being moved around and rotated when being parented to the object they were cut from. Yet this is exactly what is happening to literally dozens of objects.

I should add that I spend copious amounts of time meticulously positioning these objects in Blender and all of them are positioned to an accuracy of < 0.01 inches and some are accurate to < 0.0001 inches. Many of these were modeled in place and I only made minor adjustments when fitting the parts together. So using Christian's "Clear Parent Inverse" solution will involve dozens if not hundreds of hours of work and will made my previous effort at positioning everything a total waist of time. If it was only repositioning things that needed to be done it would be bad enough but the apparently random rotations of objects will be a real pain to deal with and increases the effort needed to fix this considerably. I don't have time to do this before the 3.2 release so the released version will have horrible performance for the livery stuff Fortunately this only impacts livery changes and it will be shipped with only on livery but it does increase start up times considerably.
hvengel
Retired
 
Posts: 1127
Joined: Sun Dec 24, 2006 5:35 am
Location: Minden Nevada

Re: livery setup aircraft.livery.update.new(...) not running

Postby cbendele » Mon Jul 28, 2014 6:13 pm

i4dnf (or what was his nick) in irc recently explained a way how to do the repositioning / clearing parent inverse for old / broken models in a few simple steps for all objects at once. Unfortunatelly I failed to note it down. Are there online logs of the irc channel? Otherwise maybe we can ask him to be patient an explain it again :D

For new models I have made a few small corrections in my workflow so the problem doesn't happen anymore. When I create a new model I immediately set the correct parent before I do anything else, and before any transformation I always make an actual decission whether it should be made in object mode (moving the object root) or in edit mode, while earlier I never paid attention to that.

EDIT: of course another solution would be to fix the exporter script, so it doesn't ignore the parent root, but I actually think the way I create my models now since I know of the parent inverse issue are actually cleaner, since I take more care about the root position of each object and the parent. In my personal opinion (blender experts would probably disagree) it is blender, and not the export script, that is broken. I dislike the whole concept of the parent inverse. Instead of keeping some hidden hush-hush correction matrix and keep the visible, explicit object transformations fixed to their original value when parenting, I'd much rather blender would just explicitly subtract the parent's transformation from the new child's when parenting.

...

YMMV
cbendele
 
Posts: 50
Joined: Fri Jan 14, 2011 11:08 am
Callsign: D-ETRA
Version: 3.0
OS: Archlinux

Re: livery setup aircraft.livery.update.new(...) not running

Postby hvengel » Mon Jul 28, 2014 10:58 pm

cbendele wrote in Mon Jul 28, 2014 6:13 pm:i4dnf (or what was his nick) in irc recently explained a way how to do the repositioning / clearing parent inverse for old / broken models in a few simple steps for all objects at once. Unfortunatelly I failed to note it down. Are there online logs of the irc channel? Otherwise maybe we can ask him to be patient an explain it again :D


Perhaps this should be documented on the wiki. If someone can locate the original irc thread or point me to some on-line source for this info I would be happy to get this on the wiki where people can find it along with screen shots of what this looks like to help people know when they have run into this issue. I just did some googling and was unable to find anything that looked like it was related to this. Also tried to find the logs for the irc channel - no luck.

As long as the exporter is buggy perhaps there should a wiki page that documents the correct Blender workflow to avoid these exporter issues. It would be much better to avoid these things then to have to fix them after the fact. Before I started working on my exterior models I looked over everything on the wiki related to Blender and modeling so if this had been documented I would have found it early in the process and would not be having these exporter issues now.

At its root the exporter is a Blender to ac3d exporter and it should handle what ever Blender throws at it as long as it is something that is supported by or can be converted into ac3d. It currently does not. So I don't think that how Blender is doing things is really the issue even if what it is doing seems to be broken to some. After all the exporter should be a Blender to ac3d exporter not a "Blender if you do everything just right to ac3d exporter" and it should do that correctly no matter what the Blender file looks like as long as Blender thinks the file is correct.

I have done a significant amount of Blender work for FlightGear in the past mostly on cockpit related models (instruments, controls...) and external stores (rockets, bomb racks, drop tanks...) but also mostly with Blender 2.49. This was all on relatively small simple models compared to doing an exterior model. On none of these did I have issues with normals and on none of them did I use parenting so these exporter issues were unknown to me until a few weeks ago. But apparently some here already knew about the exporter issues. In addition these have not been covered in any threads here that I am aware of but I might have missed something

Also my network will be down until the evening of the 30th (that was the soonest my internet provider could get a service tech to my location) so it will be later in the week before I can update the wiki.
hvengel
Retired
 
Posts: 1127
Joined: Sun Dec 24, 2006 5:35 am
Location: Minden Nevada

Re: livery setup aircraft.livery.update.new(...) not running

Postby cbendele » Tue Jul 29, 2014 12:05 am

IIRC blender 2.49 had a native ac3d exporter. I first stumbled on the problem with the parent inverse when I started working on some older models in blender 2.6 after a long hiatus and all my objects were suddenly misplaced in flightgear. I don't even remember if somebody pointed me to to the root of the problem in some forum or other or if I found it myself. I admit I should have written a wiki entry about my findings, and I apologize for not doing so. I might revisit this issue tomorrow after (hopefully) another chat with i4dnf. Fact is that I just didn't consider the problem a show stopper.

Whenever I work with expensive software nowadays, usually some scientific software from a variety of competing companies where the license per user (or per 4 cores) costs several thousand euros per year, I'm quickly annoyed. It usually does not work as advertised, the helpdesk is often not helpful at all, and the documentation, which often took several feet on the shelf a few versions ago gets both slimmer and more incorrect with every new version. In these cases I will get really angry because, after my employer or the chair of my university spent many thousand euros a year for many years, I believe I should really be ENTITLED to receive a product that works, useful help if it doesn't, and a manual that enables me to use it without spending another few thousands to take part in several week-long trainings that progress at glacial pace during unimportant trivia and then skim over the useful detail.

When I work with the blender ac3d exporter and its error message is less than helpful when my model contains an untextured object, or if some of my objects get miraculously misplaced, I also get annoyed. I get annoyed at myself because 20 years after my first little hello world program in C64 Basic and 8 years after I decided to make programming a job and go to university for it, I still didn't manage to learn a language as widespread as python, so I can't just fire up gvim and correct the problem. I'm just learning Nasal as we speak, and as often I find the experience of learning a new programming language a fulfilling one. Maybe I'll even learn python some day. But probably not. I like to hang on to some of my prejudices, and my prejudices against python and those that like to code in it are old and deeply rooted ;)

Christian
cbendele
 
Posts: 50
Joined: Fri Jan 14, 2011 11:08 am
Callsign: D-ETRA
Version: 3.0
OS: Archlinux

Re: livery setup aircraft.livery.update.new(...) not running

Postby TheTom » Wed Jul 30, 2014 4:06 pm

Which ac3d exporter are you using? Besides my core activities I'm working (currently not really active) on two Blender plugins for exporting to ac3d and animations/fdm xml files:

https://github.com/majic79/Blender-AC3D

https://github.com/tomgey/blender-io_scene_fdm

Especially the animations export is quite experimental, but I'm using both sucessfully for my own aircraft. If I find a problem (or know of it) usually I try to fix them...
TheTom
 
Posts: 322
Joined: Sun Oct 09, 2011 11:20 am

Re: livery setup aircraft.livery.update.new(...) not running

Postby hvengel » Wed Jul 30, 2014 10:35 pm

About 8 months ago I tried https://github.com/majic79/Blender-AC3D but I had significant issues with it not exporting textures. When I posted about this http://helijah.free.fr/blender/io_scene_ac.tar.gz was recommended on the Blender ac3d thread. I suspect that this is what most are using since at least at one point it worked better than https://github.com/majic79/Blender-AC3D and was and still is being widely promoted.

My comments in this thread are about http://helijah.free.fr/blender/io_scene_ac.tar.gz. If there have been updates to https://github.com/majic79/Blender-AC3D in the last 8 months then I will give it a try. But having a look at github it appears it was last changed 9 months ago so I was using the current version. The one at http://helijah.free.fr/blender/io_scene_ac.tar.gz has a number of bugs. Some of these are more than minor and are causing me major headaches that have set my new exterior model project back by several weeks.

I am not sure why we have two export/import add ins and why all of that effort was not focused on doing one that really worked rather than two that sort of work.

I am not using Blender for animation since I find doing animation in FG to be fairly simple.
hvengel
Retired
 
Posts: 1127
Joined: Sun Dec 24, 2006 5:35 am
Location: Minden Nevada

Next

Return to Liveries

Who is online

Users browsing this forum: No registered users and 1 guest