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

Unusual Switch!

n4gix

Resource contributor
Messages
11,674
Country
unitedstates
I've finally found what has to be the most "unusual switch" ever, and I'm at a loss to figure out just how to animate it! I have four of these switches to animate.

yPBv6.png

This is a FOUR position switch.
  1. Center is OFF
  2. Down is AUTOMATIC (latched)
  3. Up-Left is OPEN (spring loaded, center OFF)
  4. Up-Right is CLOSE (spring loaded, center OFF)
Right at the moment, the only viable control method I can think of would be to create three invisible mouse rectangles instead of the actual switch lever.

The animation however will be a major problem with the switch lever going in three independent directions! Assuming that I key-framed thusly
  1. down = 0
  2. center = 5
  3. Up-left = 10
  4. Up-right = 15
Clicking on the CLOSE mouse rectangle would cause the switch to first move Up-left, then snap over to the Up-right position, which frankly would look rather silly. Now I'm wondering if it might not be better to have FOUR separate switch levers, and use <Visibility> to control positions...

Does anyone have any other ideas for this?
 
Last edited:
What if you just placed dummy objects to act as mouse rectangles on each position that the switch needs to go, and then used visibility conditions like in the last sequence that you mentioned? That’s the only way I can think of doing it...Animating a nonlinear switch like this with keyframes that are linear in nature (using only one object at least) seems impossible.
 
Left click: "Open"
Right click: "Close"
LeftRelease or RightRelease: "Off"
Middle click: Toggle "Auto - Off"

Don't forget an appropriate tooltip. ;)
 
What if you just placed dummy objects to act as mouse rectangles on each position that the switch needs to go, and then used visibility conditions like in the last sequence that you mentioned? That’s the only way I can think of doing it...Animating a nonlinear switch like this with keyframes that are linear in nature (using only one object at least) seems impossible.
That is the precise problem. It's a non-linear animation.

I will be going with three transparent 'mouse rectangles' and use simply left-click + release for the CLOSE and OPEN labels, and a left-click toggle for the AUTOMATIC position. I will clone the switch lever and have each of them at the four positions using <Visibility> conditions to control appearance.
 
Left click: "Open"
Right click: "Close"
LeftRelease or RightRelease: "Off"
Middle click: Toggle "Auto - Off"

Don't forget an appropriate tooltip. ;)
While that would work for the majority, I've found that there are still a minority who's mouse does not have a clickable wheel, and some with no wheel at all!

Tooltips will be included for certain.
 
While that would work for the majority, I've found that there are still a minority who's mouse does not have a clickable wheel, and some with no wheel at all!

Well, in that case...

Right click and drag left - with ClickRepeat (or wheel up): "Open"
Right click and drag right - with ClickRepeat (or wheel down): "Close"
LeftRelease or RightRelease: "Off"
Left click: Toggle "Auto - Off"
 
Maybe do it like we animate a sidestick controller with the controller as a child of a part which is animated seperately in a linear fashion and so on. It is certainly possible just maybe observe how the switch works in real life. That should give you some inspiration.
 
Terence, I've done what you suggest with small joystick controls on MCD units, but those are strictly four axis, center neutral actions. I'd love to observe this particular switch in action, but not having a C130J in my backyard, that will have to remain just a dream... :rotfl:
 
That actually wouldn't be a bad way of doing it, having the independent axis like a joystick.

  • X1 Y1 would be off
  • X1 Y0 would be auto
  • X0 Y2 would be open
  • X2 Y2 would be close
You just have logic that states the switch cannot move to any position other than off unless it is already in the off position. If it's done right, you should end up with one combined clickspot/mouserect and two animations per switch.
 
Well if you had enough space for elephants.....maybe a c130 is not that much of a stretch :D. That was a great recipe BTW
I've only fixed that recipe once myself. I omitted the elephant and simply had "hare stew". That way I didn't have to worry about storing leftovers... :rotfl:
 
Actually these types of switches are not that uncommon. Here are two spill valve switches on the Vickers VC10. They form part of the pressurisation system.
spill.jpg

They also operate the spill valve eyes to the the right. The verticle line rotates to the horizontal when the spill valves are closed and you can see the white quarter disc that expands or contracts by how much the valve is open or closed. The switches themselves work very much like a spring loaded joystick with the neutral position in the centre "off" to which the switch always moves to once the mouse is removed. There are four positions: Off, which I have just explained is the spring loaded return. Norm: The switch is moved to this position and stays there after mouse removal until critiria is met and then returns to the Off position automatically. Shut: closes the spill valve incrementally by holding the mouse continuously in that direction. Spill: does the opposite.
Here is the code for the left spill valve switch
Code:
<Gauge Name="LEFT SPILL VALVE" Version="1.0">
<Update>
(L:SetSpill,bool) 0 ==
   if{
      2 (>L:SPILL, number) 100 (>L:spill_segment,enum)
      1 (>L:SetSpill, bool)
   }
</Update>

   <Element>
      <Select>
         <Value>(L:SPILLSWITCH,number)</Value>
         <Case Value="0">
            <Image Name="L_spill_off.bmp"/>
         </Case>
         <Case Value="1">
            <Image Name="L_spill_shut.bmp"/>
         </Case>
         <Case Value="2">
            <Image Name="L_spill_norm.bmp"/>
         </Case>
         <Case Value="3">
            <Image Name="L_spill_spill.bmp"/>
         </Case>
      </Select>
   </Element>

  <Mouse>
 <Tooltip>Left Spill Valve %((L:spill_segment,enum) near)%!d!%%</Tooltip>
      <Area Left="0" Top="22" Right="13" Bottom="39">
         <Cursor Type="Hand"/>
         <Click Kind="LeftSingle+LeftRelease" Repeat="Yes">
            (M:Event) 'LeftSingle' scmp 0 == if{ 0 (>L:SPILL,number) 1 (>L:SPILLSWITCH,number) (L:spill_segment,enum) 0 &gt;
if{ (L:spill_segment,enum) -- (>L:spill_segment,enum) } }
         (M:Event) 'LeftRelease' scmp 0 == if{ 0 (>L:SPILL,number) 0 (>L:SPILLSWITCH,number) (L:spill_segment,enum) 0 &gt;
if{ (L:spill_segment,enum) -- (>L:spill_segment,enum) } }
        </Click>
      </Area>

      <Area Top="0" Bottom="12">
         <Cursor Type="Hand"/>
         <Click>1 (>L:SPILL,number) 73 (>L:spill_segment,enum) 2 (>L:SPILLSWITCH,number) 1 (>L:Sound_click,enum)</Click>
      </Area>
      <Area Left="14" Top="22" Right="25" Bottom="39">
         <Cursor Type="Hand"/>
         <Click Kind="LeftSingle+LeftRelease" Repeat="Yes">
            (M:Event) 'LeftSingle' scmp 0 == if{ 2 (>L:SPILL,number) 3 (>L:SPILLSWITCH,number) (L:spill_segment,enum) 100 &lt;
if{ (L:spill_segment,enum) ++ (>L:spill_segment,enum) } }
          (M:Event) 'LeftRelease' scmp 0 == if{ 2 (>L:SPILL,number) 0 (>L:SPILLSWITCH,number) (L:spill_segment,enum) 100 &lt;
if{ (L:spill_segment,enum) ++ (>L:spill_segment,enum) } }
        </Click>
      </Area>

   </Mouse>
</Gauge>

And here is the code for the valve
Code:
<Gauge Name="Left Spill Indicator" Version="1.0">
   <Image Name="spillmask.bmp" Luminous="1"/>

   <Element>
      <Position X="200" Y="206"/>
      <Image Name="L_SPILL_IND.bmp" PointsTo="North" Luminous="1">
         <Axis X="146" Y="146"/>
      </Image>
      <Rotate>
          <Value Minimum="0" Maximum="100">(L:spill_segment,enum)</Value>
 
         <Nonlinearity>
            <Item Value="0" X="200" Y="344"/>
            <Item Value="25" X="146" Y="339"/>
            <Item Value="100" X="60" Y="240"/>
         </Nonlinearity>
         <Delay DegreesPerSecond="30"/>
      </Rotate>
   </Element>

<Element>
      <Position X="0" Y="0"/>
      <Image Name="L_Spill Indicator.bmp"/>
   </Element>

   <Element>
      <Position X="188" Y="188"/>
      <Image Name="bar_1.bmp" PointsTo="North" Luminous="1">
         <Axis X="188" Y="188"/>
      </Image>
      <Rotate>
         <Value>(L:spill_segment,enum) 0 &gt;
if{ 1 } els{ 0 }</Value>
         <Nonlinearity>
            <Item Value="0" X="17" Y="188"/>
            <Item Value="1" X="171" Y="33"/>         
         </Nonlinearity>
         <Delay DegreesPerSecond="160"/>
      </Rotate>
   </Element>

   <Mouse>
      <Tooltip>Left Spill Indicator-%( (L:spill_segment,enum) )%{if}In-Line%{else}Cross_Lined%{end}</Tooltip>
   </Mouse>
</Gauge>
Some of the variables are used elswhere especially in the cabin pressurisation as if they are not properly set ie. continuously spilling after take-off, then the cabin pressure aural warning will go off at 10,000ft. The code is FS9 code.
 
Last edited:
Yes, those are the same "type" of switch, and your scripts look excellent. Thank you for sharing!

Unfortunately, when dealing with 3d objects, animation is a bit more complex than displaying static bitmaps. As well, the XLM scripting scheme is vastly different from 2d gauge XML scripting.
 
It seems to me that you could break up the animations into their separate motions using dummy nodes, since you will only ever have one animation happen at a given time. I have a joystick that controls a cursor on a display panel. It moves from center to up/down/left/right, and if you click the stick itself it pushes in to select a menu item.
 
I went ahead and tried it out. I think this is working like you need it to other than some tweaking to the down position mouserect section.
 

Attachments

Thanks Bob. That's very close to perfect. The STICK_DOWN event needs to 'stick' (pun intended) though. It is binary off/on and not spring loaded center return. :coffee:
 
Last edited:
Back
Top