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

FSX XML: Glass gauges fading in

Messages
204
Country
portugal
Generally, the variable CIRCUIT GENERAL PANEL ON is controlling the PFD and MFD visibility, so when we fire this circuit the glass gauges lit so suddenly…

I'd like to add them some delay and make them fading in smoothly...

How could that be done? Passing multiple transparent bitmaps with different alpha layers?
 
Last edited:
Actually, you can create Rectangles that use 'Fill' with the color black, and make the transparency a Element layer. Now create several of these. Have them all turn on at once so that you barely see the gauge graphics beneath them. Next attach timers to each layer, so that after 1 or 3 seconds (whatever you like), a layer disappears, then another, then another, and if smoothly done, it will appear to blend and become bright.


I use this for tinting adjustment. Works brilliant. Yours would use this like a 'boot up screen' appearence, but with many, with varied times on their timers.

If only one could incorporate one timer for all layers, if you had say 7 rectangle layers that begin disappearing. Would save some computer resource, I would think.


Bill
 
Actually, you can create Rectangles that use 'Fill' with the color black, and make the transparency a Element layer. Now create several of these. Have them all turn on at once so that you barely see the gauge graphics beneath them. Next attach timers to each layer, so that after 1 or 3 seconds (whatever you like), a layer disappears, then another, then another, and if smoothly done, it will appear to blend and become bright.


I use this for tinting adjustment. Works brilliant. Yours would use this like a 'boot up screen' appearence, but with many, with varied times on their timers.

If only one could incorporate one timer for all layers, if you had say 7 rectangle layers that begin disappearing. Would save some computer resource, I would think.


Bill
We can try diferent opacity layers as elements, and use only one timer, that aplies the elements one by one from dark black to full transparent over the gauge by means of a case statement, instead of a stack of elements with a timer for each. Maybe that will be less resource consuming...
 
I managed to build a sucession of bitmaps with diferent transparency (alpha), about seven, from full black to a light shadow, and I can make them show sequencialy using a case statement, and run it with a mouse click, no problem with that. That produces a realistic fade in/fade out effect.

But I'm not very good with timers, counters and updates and I don't know how to put this in practice:

I want the bitmaps to show sequencialy, once (from dark to clear), when I switch the electric circuitry on the panel, thus getting the desired PFD switch on/fade in effect.

Help?
 
The following should work for you. The script's logic is simple:

The variable (L:FadeIn,enum) is used to control your semi-transparent layers (drives the "case" condition).

The universal timer function is set to "fire" (in other words be "True") every 0.1 seconds. You can adjust the numbers as desired to speed up or slow down the sequence. The first number is the total time frame, the second number is the modulo for the desired flip-flop interval. As set now, the timer is set to be OFF for 9/10ths of a second, and ON for 1/10th of a second.

If the counter is less than 7 AND the universal timer is true, then the counter is incremented by 1.

Code:
<Code>
  (L:FadeIn,enum) 7 &lt;
  (P:Absolute time,seconds) 1.0 % 0.1 > !
  and
  (L:FadeIn,enum) ++ (>L:FadeIn,enum)
</Code>
 
The following should work for you. The script's logic is simple:

The variable (L:FadeIn,enum) is used to control your semi-transparent layers (drives the "case" condition).

The universal timer function is set to "fire" (in other words be "True") every 0.1 seconds. You can adjust the numbers as desired to speed up or slow down the sequence. The first number is the total time frame, the second number is the modulo for the desired flip-flop interval. As set now, the timer is set to be OFF for 9/10ths of a second, and ON for 1/10th of a second.

If the counter is less than 7 AND the universal timer is true, then the counter is incremented by 1.

Code:
<Code>
  (L:FadeIn,enum) 7 &lt;
  (P:Absolute time,seconds) 1.0 % 0.1 > !
  and
  (L:FadeIn,enum) ++ (>L:FadeIn,enum)
</Code>

Ok, understood.
But I got the (A:CIRCUIT GENERAL PANEL ON, bool) controlling the visibility of the gauge. Your bit of code should run when (A:CIRCUIT GENERAL PANEL ON, bool) gets value 1 - the PFD shows up, but at the same time (L:FadeIn,enum) gets from 0 to 7, displaying the fade in effect.
So where do I place that bit of code?
 
Hello Joao,


I might be able to help with that. You need a basic Logic string added.


Code:
  (A:CIRCUIT GENERAL PANEL ON, bool) 1 ==
       if{
           (L:FadeIn,enum) 7 &lt;
           (P:Absolute time,seconds) 1.0 % 0.1 > !
           and
           (L:FadeIn,enum) ++ (>L:FadeIn,enum)
         }

This will run when your A:CIRCUIT GENERAL PANEL ON is running or '1'.
 
Just one more condition to check!
Code:
<Code>
  (A:CIRCUIT GENERAL PANEL ON, bool)
  (L:FadeIn,enum) 7 &lt;
  and
  (P:Absolute time,seconds) 1.0 % 0.1 > !
  and
  (L:FadeIn,enum) ++ (>L:FadeIn,enum)
</Code>
Or, you can use the other Bill's suggestion if it's more clear! ;)
 
I am always intriqued Bill at how you can simplify code so well.
Yeah, although I can't help to feel illiterate...:(

By the way, thoses <code></code> tags mean I can put it anywhere in the code? Or should I create an element for that?
 
Last edited:
Yeah, although I can't help to feel illiterate...:(

By the way, thoses <code></code> tags mean I can put it anywhere in the code? Or should I create an element for that?

It can go in an <Update> section, or a <Code> section of an <Element> or even a <Click> or <CallbackCode> section of a <Mouse> or <MouseRect> section!
 
It can go in an <Update> section, or a <Code> section of an <Element> or even a <Click> or <CallbackCode> section of a <Mouse> or <MouseRect> section!

Just some more enlightenment:

Does some of these sections expend more resources than others? I'm always a bit afraid of an <Update>, as I keep thinking this bit is kept running over and over... is the only aim of the <Update> to give the ability to change the update cyles?
 
Just some more enlightenment:

Does some of these sections expend more resources than others? I'm always a bit afraid of an <Update>, as I keep thinking this bit is kept running over and over... is the only aim of the <Update> to give the ability to change the update cyles?

Unless you specify otherwise, the <Update> is executed at every gauge cycle (~18Hz).

You can only have one <Update> section per gauge, so obviously you can only specify one update rate. It is for that very reason why I recommend using a "universal timer" to control the update rate for selected XML scripts, because you can have as many "universal timers" as you wish!

Code:
  <Update Hidden="Yes">
    <!-- 1 SECOND UPDATE -->
    (P:Absolute time,seconds) 1 % 1 > !
    if{
          (* XML script goes in here *)
      }

    <!-- 1/2 SECOND UPDATE -->
    (P:Absolute time,seconds) 1 % 0.5 > !
    if{
          (* XML script goes in here *)
      }

    <!-- STUFF TO BE UPDATED @18Hz -->
          (* XML script goes in here *)
  </Update>
 
Here is my final code, fade in and fade out of a glass gauge when you switch in and out the instruments panel.

First the "control" section:
Code:
        <Update id="Update">
            <Script>
                (A:CIRCUIT GENERAL PANEL ON, bool)
                if{
                (L:Fade, enum) 10 &lt;                
                (P:Absolute time, seconds) 1.0 % 0.1 &gt; ! &amp;&amp;
                (L:Fade, enum) ++ 10 min (&gt;L:Fade, enum)
                }
                (A:CIRCUIT GENERAL PANEL ON, bool) !
                if{
                (L:Fade, enum) 0 &gt;
                (P:Absolute time, seconds) 1.0 % 0.1 &gt; ! &amp;&amp;
                (L:Fade, enum) -- 0 max (&gt;L:Fade, enum)
                }
            </Script>
        </Update>

Then the bitmap handling:
Code:
            <Element id="Fade In/Out">
                <FloatPosition>0.000,0.000</FloatPosition>
                <Select id="Select">
                    <Expression id="Expression">
                        <Minimum>0.000</Minimum>
                        <Maximum>9.000</Maximum>
                        <Script>(L:Fade, enum)</Script>
                    </Expression>
                    <Case id="Case 0">
                        <ExpressionResult>0.000</ExpressionResult>
                        <Image
                                id="pfd_background_0.bmp"
                                Alpha="True"
                                Name="pfd_background_0.bmp">
                            <Transparent>True</Transparent>
                        </Image>
                    </Case>
                    <Case id="Case 1">
                        <ExpressionResult>1.000</ExpressionResult>
                        <Image
                                id="pfd_background_1.bmp"
                                Alpha="True"
                                Name="pfd_background_1.bmp">
                            <Transparent>True</Transparent>
                        </Image>
                    </Case>
                    <Case id="Case 2">
                        <ExpressionResult>2.000</ExpressionResult>
                        <Image
                                id="pfd_background_2.bmp"
                                Alpha="True"
                                Name="pfd_background_2.bmp">
                            <Transparent>True</Transparent>
                        </Image>
                    </Case>
                    <Case id="Case 3">
                        <ExpressionResult>3.000</ExpressionResult>
                        <Image
                                id="pfd_background_3.bmp"
                                Alpha="True"
                                Name="pfd_background_3.bmp">
                            <Transparent>True</Transparent>
                        </Image>
                    </Case>
                    <Case id="Case 4">
                        <ExpressionResult>4.000</ExpressionResult>
                        <Image
                                id="pfd_background_4.bmp"
                                Alpha="True"
                                Name="pfd_background_4.bmp">
                            <Transparent>True</Transparent>
                        </Image>
                    </Case>
                    <Case id="Case 5">
                        <ExpressionResult>5.000</ExpressionResult>
                        <Image
                                id="pfd_background_5.bmp"
                                Alpha="True"
                                Name="pfd_background_5.bmp">
                            <Transparent>True</Transparent>
                        </Image>
                    </Case>
                    <Case id="Case 6">
                        <ExpressionResult>6.000</ExpressionResult>
                        <Image
                                id="pfd_background_6.bmp"
                                Alpha="True"
                                Name="pfd_background_6.bmp">
                            <Transparent>True</Transparent>
                        </Image>
                    </Case>
                    <Case id="Case 7">
                        <ExpressionResult>7.000</ExpressionResult>
                        <Image
                                id="pfd_background_7.bmp"
                                Alpha="True"
                                Name="pfd_background_7.bmp">
                            <Transparent>True</Transparent>
                        </Image>
                    </Case>
                    <Case id="Case 8">
                        <ExpressionResult>8.000</ExpressionResult>
                        <Image
                                id="pfd_background_8.bmp"
                                Alpha="True"
                                Name="pfd_background_8.bmp">
                            <Transparent>True</Transparent>
                        </Image>
                    </Case>
                    <Case id="Case 9">
                        <ExpressionResult>9.000</ExpressionResult>
                        <Image
                                id="pfd_background_9.bmp"
                                Alpha="True"
                                Name="pfd_background_9.bmp">
                            <Transparent>True</Transparent>
                        </Image>
                    </Case>
                </Select>
            </Element>

Thanks all who help me on this.
 
Hi all,

Is it possible to include a <Update> in modeldef.xml file? If so, at what point exactly?

Or if not, can we include a "loop using a Goto" in modeldef.xml file? If so, where and how?

Thank you for all the help that the Gurus of XML will bring me:)
 
Chris,

Most likely not. Never seen any example of such code. For advanced "logic" type code it is better to have an invisible XML gauge mounted on the VC panel sending L:Vars to the modeldef variables as need for visibilities, animations etc.. Then one can use all that XML has to offer.
 
Back
Top