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

P3D v4 3D Model Switch Code; Starting at 50% point?

Messages
10,158
Country
us-arizona
Hey all,

This one is beyond me. Hoping for some advice and help.

Part (dial and part) start in the 50% point. You turn the knob and the part slides up or down, depending on mouseup or mousedown, or by right click/left click.

But... It has to start at the 50% point.

How does one write that into the code for the part to begin at KF point 50 out of 100 KF's?

I have a zillion (ok, only a begillion) codes in my inventory, and none have something like this, though I do remember similar. It was my Learjet generator switch, but it used mouse drag and M:Y movements. Totally different. On this, the part is a dial and a wing alignment on a Attitude gauge. You turn the dial and the wings slide upwards or downwards.

Any idea's?

This is what I am starting with.


Code:
  <PartInfo>
        <Name>CH70_attitude_wings</Name>
        <AnimLength>100</AnimLength>
        <Animation>
            <Parameter>
                <Code>(L:ATTITUDE WINGS ALIGNMENT SETTING,bool) 100 *</Code>
                <Lag>950</Lag>
            </Parameter>
        </Animation>
   <MouseRect>
    <Cursor>Hand</Cursor>
        <MouseFlags>LeftSingle+WheelUp+WheelDown+RightSingle</MouseFlags>
        <CallbackCode>
            (M:Event) 'LeftSingle' scmp 0 ==
            if{
                   (>L:ATTITUDE WINGS ALIGNMENT SETTING,bool)
                }
            (M:Event) 'RightSingle' scmp 0 ==
            if{
                   (>L:ATTITUDE WINGS ALIGNMENT SETTING,bool)
                }
            (M:Event) 'WheelUp' scmp 0 ==
            if{
                   (>L:ATTITUDE WINGS ALIGNMENT SETTING,bool)
              }
            (M:Event) 'WheelDown' scmp 0 ==
            if{
                   (>L:ATTITUDE WINGS ALIGNMENT SETTING,bool)
              }
    <TooltipText>Attitude Wings Adjustment</TooltipText>
      </CallbackCode>
   </MouseRect>
    </PartInfo>
 
Hi Bill,
First, I would move the Tooltip up to sit under the Cursor line. And you probably do not need a Lag.

Next, I am not sure you want your L variable to be bool (and at the moment you are not assigning any value to it anyway) . If you want a graded adjustment, as the value '50' and Wheelup and Wheeldown suggest, make it enum. In this case you also have to fence the values in ensuring that they do not exceed 100 or go less than 0. In other words, somewhat like this (careful, not tested):

Code:
    (M:Event) 'LeftSingle' scmp 0 ==
     if{  (L:ATTITUDE WINGS ALIGNMENT SETTING,enum) -- 0 max (>L:ATTITUDE WINGS ALIGNMENT SETTING,enum)  }

    (M:Event) 'RightSingle' scmp 0 ==
     if{  (L:ATTITUDE WINGS ALIGNMENT SETTING,enum) ++ 100 min (>L:ATTITUDE WINGS ALIGNMENT SETTING,enum)  }

etc. Also, if LeftSingle and Wheeldown (for example) trigger the identical action you could 'or' the Mouse scmp's for a less verbose script. Like so:

Code:
    (M:Event) 'LeftSingle' scmp 0 == (M:Event) 'WheelDown' scmp 0 == or
     if{  (L:ATTITUDE WINGS ALIGNMENT SETTING,enum) -- 0 max (>L:ATTITUDE WINGS ALIGNMENT SETTING,enum)  }
    els{  (L:ATTITUDE WINGS ALIGNMENT SETTING,enum) ++ 100 min (>L:ATTITUDE WINGS ALIGNMENT SETTING,enum)  }

This would actually cover all of your four drafted ifs (if indeed that is the combo you want).

And finally, to ensure your L var starts at 50 you could put this assignment into your general initialize section, which I am sure you have anyway. Or maybe trigger it when your avionics switch is turned on, and revert to zero when off.
 
Last edited by a moderator:
My goodness man....! I am humbled... Ten thousand thanks.

Code:
And finally, to ensure your L var starts at 50 you could put this assignment into your general initialize section, which I am sure you have anyway. Or maybe trigger it when your avionics switch is turned on, and revert to zero when off.

Why didnt I think of that. Beautifully simple. arghhh..

Many many many thanks, Manfred.
 
Hope you can make it work...

Just a reminder, don't forget to kill the 100 * factor in the Animation section thus:

Code:
<Code>(L:ATTITUDE WINGS ALIGNMENT SETTING, enum)</Code>
 
Many thanks for that last post, Manfred. Its not working beautifully. Another 10 thousand thanks.

Code:
  <PartInfo>
        <Name>CH70_attitude_wings</Name>
        <AnimLength>100</AnimLength>
        <Animation>
            <Parameter>
                 <Code>(L:ATTITUDE WINGS ALIGNMENT SETTING, enum)</Code>
            </Parameter>
        </Animation>
   <MouseRect>
    <Cursor>Hand</Cursor>
        <TooltipText>Attitude Wings Adjustment</TooltipText>
        <MouseFlags>LeftSingle+WheelUp+WheelDown+RightSingle</MouseFlags>
        <CallbackCode>
        (M:Event) 'LeftSingle' scmp 0 == (M:Event) 'WheelDown' scmp 0 == or
     if{  (L:ATTITUDE WINGS ALIGNMENT SETTING,enum) -- 0 max (>L:ATTITUDE WINGS ALIGNMENT SETTING,enum)  }
        (M:Event) 'RightSingle' scmp 0 == (M:Event) 'WheelUp' scmp 0 == or
     if{  (L:ATTITUDE WINGS ALIGNMENT SETTING,enum) ++ 100 min (>L:ATTITUDE WINGS ALIGNMENT SETTING,enum)  }
      </CallbackCode>
   </MouseRect>
    </PartInfo>

I will probably lower it to something like 20 clicks instead of 100. That is a ton of clicks. That is quite a few clicks to do a small amount of adjustment.

Being that I do most of everything, I tend now to have long periods between departments like graphics, then polygons, then gauge coding. So my skills get a little rusty when they are dormant for a bit. Not good.
 
One simple mod would be to replace the -- and ++ by, say, 5 - and 5 + respectively. Then you'd have your 20 steps for the full range. Or 10 - and 10 + for 10 steps etc., very easy to adjust for best effect.
 
Interesting.. Many thanks, Manfred. I'll add that to the notes I took on this.


I just want to post the final code for those that might need it long from now...

This is the Reset to Zero Position (Zero Point) for the dial, which I embedded in a main gauge in the planes gauges, XML;

Code:
<!-- WINGS ATTITUDE ADJUSTMENT ZERO POINT RESET -->
<Element>
<Select>
<Value>
(L:Has_Initialized, bool) ! if{
      (A:ELECTRICAL MASTER BATTERY,bool) 1 ==
          if{
             1 (>L:Attitude Wings Adj Zero,bool)
           10 (>L:ATTITUDE WINGS ALIGNMENT SETTING, enum)
             1 (>L:Has_initialized, bool)
             }
           }
  </Value>
</Select>
</Element>


This is the ModelDef part code which I used for both the Dial and the Needle assembly (wings symbol) in the Attitude Gauge (3d gauge made of polygons, animated).


Code:
// TOP SECTION

    <Animation name="CH70_attitude_wings" guid="fac2d5ad-5bd2-4f27-85c1-47cb0faa6f82" length="20" type="Sim" typeparam2="CH70_attitude_wings" typeparam="AutoPlay" />
  
    // BOTTOM SECTION
  
      <PartInfo>
        <Name>CH70_attitude_wings</Name>
        <AnimLength>20</AnimLength>
        <Animation>
            <Parameter>
                 <Code>(L:ATTITUDE WINGS ALIGNMENT SETTING, enum)</Code>
            </Parameter>
        </Animation>
   <MouseRect>
    <Cursor>Hand</Cursor>
        <TooltipText>Attitude Wings Adjustment</TooltipText>
        <MouseFlags>LeftSingle+WheelUp+WheelDown+RightSingle</MouseFlags>
        <CallbackCode>
        (M:Event) 'LeftSingle' scmp 0 == (M:Event) 'WheelDown' scmp 0 == or
     if{  (L:ATTITUDE WINGS ALIGNMENT SETTING,enum) -- 0 max (>L:ATTITUDE WINGS ALIGNMENT SETTING,enum)  }
        (M:Event) 'RightSingle' scmp 0 == (M:Event) 'WheelUp' scmp 0 == or
     if{  (L:ATTITUDE WINGS ALIGNMENT SETTING,enum) ++ 20 min (>L:ATTITUDE WINGS ALIGNMENT SETTING,enum)  }
      </CallbackCode>
   </MouseRect>
    </PartInfo>

This is set to 20 Key Frames (KF's) and works smoothly. When you boot up into the plane, and you have your gauge XML code present, this will show up at the 50% point, KF 10.

Many many thanks, Manfred.

A cool feature of this code is that right clicks and left clicks as well as wheelup and wheeldown controls are in the dial. The dial animates as well. Note, you will need 4 KF rotation points for the dial. 3 points for the wings symbol, 0, 10, and 20.


Bill
LHC
 
Back
Top