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

Two Position Gmax Animation Code

Messages
10,163
Country
us-arizona
Hey guys,

How would one do a custom animation, FS2004 Gmax XML code, for a part to move to key frame point 50, and 100, and click again and it goes back to zero?

So, another words, I click on a part, and it moves 50%, and I click it again, and it moves another 50% to point 100% or key frame 100. I then click it a 3rd time, and it goes ALL THE WAY BACK to key frame zero, 0%.



Bill
 
I wonder if a 'case' animation call would work on this with an L:var?

Example;

30 25 20 10 5 1 0 7 (A:Flaps handle index, number) case

How..
the numbers 30 25 20 10 5 1 0 are pushed down the stack, 7 says how much entries, based on the result of (A:Flaps handle index, number) ”case” extracts one of the seven numbers. If (A:Flaps handle index, number) is 0 -> 0, 1->1, 2->5,... 6->30.


So I wonder if this might work.

100 50 0 3 (L:Window_LHF, number) case


Would that give me KF 0, 50, and 100 points movement?



Bill ohhh
 
Well, I tried this. It crashes the parts sheet.


Code:
<part>
          <name>lhc_window_lhf</name>
            <animation>
              <parameter>
                <code>100 50 0 3 (L:Electric Window LHF:1, enum) case 25 *</code>
                <lag>400</lag>
              </parameter>
            </animation>
            <mouserect>
                <tooltip_text>LHF Electric Window</tooltip_text>
                <callback_code>
                   (L:Electric Window LHF, bool) ! (>L:Electric Window LHF, bool)
                   1 (&gt;L:XMLSND4,enum)
                   1 (&gt;L:XMLSND53,enum)
                </callback_code>
           </mouserect              
</part>


arrgh... code.. grumble grumble..
 
So, another words, I click on a part, and it moves 50%, and I click it again, and it moves another 50% to point 100% or key frame 100. I then click it a 3rd time, and it goes ALL THE WAY BACK to key frame zero, 0%.

???????????????????

Bill, this was asked and answered several weeks ago...

...in another thread you started with the same question! :confused:
 
Bill,

It didnt work.

<bangs head on desk>

I have been trying to get these things working this entire time. Nothing seems to work.


I figured I would make it even more simpler and just start at a basic level, see if I can get them to move to a 50% point, then 100 KF point, and back to zero or even half again. What ever will help these dang things to operate.

I can then use a 2D gauge to get them to auto-roll-up when its over 100 knots..


Me and dwight have been fighting with this code the past 3 days, trying things.

I am at the point of just making a single code for one window instead of a switch, and a window animation code set; just making one complete 'clickable' animation code. Simplification..
 
Keyframe 0 - 50 - 100

Leftclick once, var changes from 0 to 1, click again changes to 2, click again changes to 0...

Code:
  <PartInfo>
    <Name>SwitchWindowLeft</Name>
    <AnimLength>100</AnimLength>
    <Animation>
      <Parameter>
        <Code>
          (L:SwitchWindowLeft,enum) 50 *
        </Code>
        <Lag>40</Lag>
      </Parameter>
    </Animation>
    <MouseRect>
      <Cursor>Hand</Cursor>
      <TooltipText>Window Left</TooltipText>
      <CallbackCode>
        (L:SwitchWindowLeft, enum) ++  2 min 0 max (>L:SwitchWindowLeft, enum)
        (L:SwitchWindowLeft, enum) 2 &gt; if{ 0 (>L:SwitchWindowLeft, enum)
      </CallbackCode>
    </MouseRect>
  </PartInfo>
 
Last edited:
Code:
  <        (L:SwitchWindowLeft, enum) ++  2 min 0 max (>L:SwitchWindowLeft, enum)

:eek:
Jeez Bill, could you please explain how this piece of code goes from 0 to 1 to 2 to 0?
The first part (the increasing bit) i get, but how does it change from 2 to 0 again?

I thought that 2 min returns the value as long as it is below 2 and 0 max returns the value as long as it is above 0.

Thanks!

grt
Willem.
 
I agree with Willem, something's missing here. An option would be to use the modulo operator instead:
Code:
    <MouseRect>
      <Cursor>Hand</Cursor>
      <TooltipText>Window Left</TooltipText>
      <CallbackCode>
        (L:SwitchWindowLeft, enum) ++ 3 % (>L:SwitchWindowLeft, enum)
      </CallbackCode>
    </MouseRect>

0 + click = 1; 1 mod 3 = 1
1 + click = 2; 2 mod 3 = 2
2 + click = 3; 3 mod 3 = 0

I thought that 2 min returns the value as long as it is below 2 and 0 max returns the value as long as it is above 0.

Not quite. The min-function returns the smaller of two numbers, the max-function returns the larger of two numbers. In other words: the functions always return something.
 
Not quite. The min-function returns the smaller of two numbers, the max-function returns the larger of two numbers. In other words: the functions always return something.

Ah yes, thanks for the clarification!

Elegant solution you have there!

BTW: if you are not certain what the outcome of a modulo is, try google!! :teacher:
For instance type in this query : 3 mod 3
The answer google gives is 0, works like a charm!

grt
Willem
 
Last edited:
Thanks guys. I guess this is just not destined to work. The modulo does not function in this code.

I remember trying to get my fuel selectors to work properly in the Kodiak, what a drama that was. No matter what was done, they still didnt function like the real thing.

I am just going to go with a single basic zero-100-zero animation. Spending this long on a single animation is just crazy. Over budget...



Bill
 
:eek:
Jeez Bill, could you please explain how this piece of code goes from 0 to 1 to 2 to 0?
The first part (the increasing bit) i get, but how does it change from 2 to 0 again?

It won't work as I described, since Fr. Stupid forgot to include the reset line:
Code:
    <MouseRect>
      <Cursor>Hand</Cursor>
      <TooltipText>Window Left</TooltipText>
      <CallbackCode>
        (L:SwitchWindowLeft, enum) ++  2 min 0 max (>L:SwitchWindowLeft, enum)
        (L:SwitchWindowLeft, enum) 2 &gt; if{ 0 (>L:SwitchWindowLeft, enum)
      </CallbackCode>
    </MouseRect>
 
Thanks guys. I guess this is just not destined to work. The modulo does not function in this code.

That's strange since after some further digging i found that in modeldef.xml the same setup is being used many times actually.

For instance:
Code:
 <CallbackCode>
        (L:VOR 2 Switch, number) ++ 3 % (&gt;L:VOR 2 Switch, number)
      </CallbackCode>

I just cannot get over how elegant this is... :twocents:

Some copy paste from your earlier post and Vitus's code:

Code:
<part>
          <name>lhc_window_lhf</name>
            <animation>
              <parameter>
                <code>(L:Electric Window LHF:1, enum) 50 *</code>
                <lag>400</lag>
              </parameter>
            </animation>
            <mouserect>
                <tooltip_text>LHF Electric Window</tooltip_text>
                <callback_code>
                  (L:Electric Window LHF:1, enum) ++ 3 % (>L:Electric Window LHF:1, enum)
                </callback_code>
           </mouserect              
</part>

Should work on a 0-100 keyframed part with steps at 0 - 50 -100 (the values that are returned are 0-1-2, times 50 for the animation).

Hope this helps!

Oh and Fr.Bill you have forgotten more than i'll ever know, so that puts things ion perspective i hope...

grt
Willem
 
I just cannot get over how elegant this is... :twocents:

Thanks! Modulo is actually a really awesome operator that can be used in many, many places. It's just not very intuitive, because you don't need it in the real world ;)

Code:
                <code>(L:Electric Window LHF:1, enum) 50 *</code>

Whooohooo! Hold on a second! Can you define L:something:1..4 variables manually?! I wasn't aware of that...

Oh and Fr.Bill you have forgotten more than i'll ever know, so that puts things ion perspective i hope...

hmmmm is that really a compliment? I'm not quite sure yet :D
 
Whooohooo! Hold on a second! Can you define L:something:1..4 variables manually?! I wasn't aware of that...

Aha so maybe that's the problem...
Maybe it's best to use L:Electric Window LHF_1, enum instead if it causes problems.


And yes that was supposed to be a compliment :).

grt
Willem
 
hmmmm is that really a compliment? I'm not quite sure yet :D

Actually, it would have been far more accurate to have said that I've "...forgotten more than I ever learned!" :rotfl:

As for the modulo operator, it is likely dismissed or ignored simply because the way it is used in FS is purely serendipitous, as it is most certainly not how it's defined normally...

...or, there's more going on "under the hood" than is exposed in XML!
 
Back
Top