• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

FSXA Coding a 3D-XML warning light

Vitus

Resource contributor
Messages
1,480
Country
newzealand
Hi all,

I need to create some warning lights for my VC. The lights are modeled in 3D (as everything else) and I was wondering how to program the different states in the modeldef.xml file.
I made two warning light parts, one is textured with a light-off texture, the other with a light-on texture. I thought about this problem and my solution was the following code:
Code:
  //light_gear_left_red_on
  <PartInfo>
    <Name>light_gear_left_red_on</Name>
    <Visibility>
      <Parameter>
        <Code>
          (L:ELEC BUS GEAR MOTOR, enum) 0 &gt;
          (A:GEAR POSITION:2,enum) 1 &gt;
          and
          if{ 1 }
          els{ 0 }
        </Code>
      </Parameter>
    </Visibility>
  </PartInfo>

  //light_gear_left_red_off
  <PartInfo>
    <Name>light_gear_left_red_off</Name>
    <Visibility>
      <Parameter>
        <Code>
          (L:ELEC BUS GEAR MOTOR, enum) 0 &gt;
          (A:GEAR POSITION:2,enum) 1 &gt;
          and
          if{ 0 }
          els{ 1 }
        </Code>
      </Parameter>
    </Visibility>
  </PartInfo>

As you can see, I coded one entry for each light-state. It works quite well but I was wondering if there is an easier way of doing it.

Regards
Vitus
 
Really, that is the only way I've ever been able to figure out! :D
 
I just came across this thread while searching for a solution to a problem I currently have. The code in the first post looks like it may work for my situation but I am not sure how or what to change to tailor it to my needs as my XML coding skills are weak at the moment (but getting better).

I have four lights in the VC (3D modelled), the parts are duplicated and one set are mapped to the light off texture and the other set are mapped to the light on texture. I understand that I can control the lights using visibility tags it's just the coding I am missing.

My set-up is as follows:

Three of the lights are green and will illuminate when the gear is down (one each for left gear, right gear and nose gear).

One light is red and will either illuminate when the gear is up OR it will illuminate during the gear transition up/down (depending on how it can be coded). Ideally the second option would be more preferable but I can live with the first.

Can anyone suggest how I can modify the above code to meet my needs.

Thanks.
 
Something like this for replacing the Code sections? (not tested)

Green lights (this is for center (nose) gear, use equivalent L: variables for left and right gear):

On:

Code:
<Code>
          (L:GEAR CENTER POSITION, percent) 99 &gt;
          if{ 1 }
          els{ 0 }
        </Code>

Off:

Code:
<Code>
          (L:GEAR CENTER POSITION, percent) 99 &gt;
          if{ 0 }
          els{ 1 }
        </Code>


Red light:

On:

Code:
<Code>
          (L:GEAR CENTER POSITION, percent) 99 &lt; (L:GEAR CENTER POSITION, percent) 1 &gt; and
          if{ 1 }
          els{ 0 }
        </Code>

Off:

Code:
<Code>
          (L:GEAR CENTER POSITION, percent) 99 &lt; (L:GEAR CENTER POSITION, percent) 1 &gt; and
          if{ 0 }
          els{ 1 }
        </Code>

Hope this helps,
 
Can anyone suggest how I can modify the above code to meet my needs.

Larry, I'd suggest the following as the easiest way:

Code:
  <PartInfo>
    <Name>Gear Left Intransit</Name>
    <Visibility>
      <Parameter>
        <Code>
           (A:GEAR LEFT POSITION,percent) 0 &gt;
           (A:GEAR LEFT POSITION,percent) 100 &lt;
           and
        </Code>
      </Parameter>
    </Visibility>
  </PartInfo>
The conditions above will cause the "light" to only be seen while the left main gear is "intransit"...

If you leave the unlighted polygon alone, and simply move the lighted polygon on the Local axis a tiny amount above the unlighted poly, no one will notice it at all!
 
Thanks for the replies guys I really appreciate it.

I did some deep exploration work in the modeldef file and discovered that there are in fact stock codes to turn on gear indicator lights when the left, right and centre (nose or tail) gear are down. They also turn off when the gear is up. I couldn't find stock code for a gear in transition light though.

That got me to thinking (always a dangerous thing! :rolleyes:) so I fired up FS2004 in the hope of finding an aircraft with a suitable arrangement using XML gauges. I hit pay dirt on the first attempt (pure luck) so I copied the key line of 2D gauge code into the FSX modeldef file and ended up with the following section of code:

Code:
<PartInfo>    
    <Name>Navion_lamp_gear_trans</Name>
    <Visibility>
      <Parameter>
        <Code>
	(A:GEAR POSITION, percent) d (G:Var1) - r (&gt;G:Var1) 0 != 4 * (G:Var2) max -- 0 max d (&gt;G:Var2) 0 !=
        </Code>
      </Parameter>
    </Visibility>
    <MouseRect>
      <TooltipID>TOOLTIPTEXT_GEAR_TRANSITION_LIGHT</TooltipID>
    </MouseRect>
  </PartInfo>

The above code works and I now have a red light that illuminates only when the gear is in transition from up to down and vice versa.

I have absolutely no idea what the line of code means and would really appreciate it if someone could explain what it is doing so that I can get a better understanding of what is going on.

Larry, I'd suggest the following as the easiest way:
Code snipped for brevity.

Thanks Bill that looks a lot neater than the way I tried to solve the problem. I am assuming that if I change 'GEAR LEFT POSITION' to 'GEAR POSITION' then it will read all three gear states rather than just the left gear, is that correct?

If you leave the unlighted polygon alone, and simply move the lighted polygon on the Local axis a tiny amount above the unlighted poly, no one will notice it at all!
Ah yes! I had forgotten about that bit! :o

My polys are currently co-aligned as I cloned the parts to make the new ones and left them in the same position. I will nudge the illuminated polys aft by a few thousandths of an inch so they are clear of the non-illuminated ones. I am not seeing an issue with the polys at the moment but better safe than sorry. :)
 
I am assuming that if I change 'GEAR LEFT POSITION' to 'GEAR POSITION' then it will read all three gear states rather than just the left gear, is that correct?
I know it's bad form to quote my own post but I just tested for this and it does indeed work.

Thanks for all the help guys, I now have working gear lights.
 
Larry, it may work, but still it's better to have separate script for each of the gear, since landing gear are rarely synchronized in their operation. In fact, there are entries in each of the contact point lines for individual extension and retraction times...

...all to better simulate reality of course! ;)
 
Larry, it may work, but still it's better to have separate script for each of the gear, since landing gear are rarely synchronized in their operation. In fact, there are entries in each of the contact point lines for individual extension and retraction times...

Ah but.....is it possible to have three visibility codes attached to the same mesh (I have a feeling this can't be done) or would I need a 'light on' mesh for each one superimposed one over the other (with a tiny spacing)? I only have one red 'gear in transition' light so it would need to be lit for each gear in the above case unless I re-think my design and have three reds and three greens instead of one red and three greens.

...all to better simulate reality of course! ;)

This is true! :)
 
I decided to go with 6 lights in the end (3 of each) and I am happy with the way they work now. I have attached a couple of shots, one shows the nose gear down and locked and the mains in transition, the other shows the nose and left main are up (i.e. the lights are off) and the right main is still in transition.
 

Attachments

  • gear_ind_1.jpg
    gear_ind_1.jpg
    106.5 KB · Views: 448
  • gear_ind_2.jpg
    gear_ind_2.jpg
    106.1 KB · Views: 495
Nice, Larry! Now that gives real meaning to the checklist callout "three green!" :D
 
I was implementing Fr. Bill's suggestion on making lights visible only when the master battery switch is ON as discussed in post #7 of this thread:

http://www.fsdeveloper.com/forum/showthread.php?t=310153

Unfortunately doing that has now messed up the working 'gear in transition' light code in post #6 above. Here is my new code:

Code:
<Code>
		(A:GEAR RIGHT POSITION,percent) 0 &gt;
		(A:GEAR RIGHT POSITION,percent) 100 &lt;
		(A:ELECTRICAL MASTER BATTERY,bool)
		and
        </Code>

While the lights do in fact turn on/off in conjunction with the master battery switch the lights remain lit with the gear up and the battery on when they should be off. The transition lights do go off when the gear is down and the battery is on (the greens come on in this case and they work fine using the stock code).

I have spent several hours playing with this problem assisted by Robert 'N2056' via the TeamSpeak channel a number of FSX developers gather on and we could not find a solution to this issue.

Can anyone see why the lights are not going out when the gear is up in the above code?
 
Larry, you must have a conjunction after each pair of conditions:

Code:
       <Code>
		(A:GEAR RIGHT POSITION,percent) 0 &gt;
		(A:GEAR RIGHT POSITION,percent) 100 &lt;
		and
		(A:ELECTRICAL MASTER BATTERY,bool)
		and
       </Code>
Because of the "missing conjunction" only the last test was being evaluated...

Don't feel too badly though...

...just this afternoon it took nearly an hour to finally "notice" my mistake!

Code:
    (L:B737_ZeroFuelFlapSelect,enum) == 5
    if{ 123 (>L:ZERO_FUEL_Vfe,number) }

Damn "reverse Polish notation!" That's what always happens to me when I spend a few hours working on a C++ project, then switch back to XML scripting...
:censored:
 
Last edited:
Back
Top