• 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 Gauge Needles Animations, Tutorial or SDK Local?

Messages
10,088
Country
us-arizona
Hey all,

So, for the first time, I am doing gauges with actual 3D needles. I am working on another gentlemans plane and some of the gauges (needles) arent calibrated.

Is there a tutorial or post or SDK location that describes how this is done with the various gauges? For instance, the VSI and how to link it to actual speeds. For instance, this VSI readout has up to 2,000 FPM climb/descent, so max top/bottom would be 2K FPM instead of 3K or 4K FPM. Any way to calibrate that?

Same for ASI...
Same for the artificial horizon disc inside the Attitude instrument.

Many thanks for any direction on these.

So funny... Ive been doing planes for 20 years, there abouts, and never did 3D gauges, lolol...
 

Vitus

Resource contributor
Messages
1,480
Country
newzealand
Hey Bill,
It's really not much different from the 2d gauges. You simply need to define the animation code in the modeldef.xml and choose the range wisely. Here's my approach:
Code:
  <PartInfo>
    <Name>needle_vsi</Name>
    <AnimLength>100</AnimLength>
    <Animation>
      <Parameter>
        <Code>
          (A:VERTICAL SPEED,feet per minute) 2000 + 0.025 * 100 min 0 max
        </Code>
      </Parameter>
    </Animation>
  </PartInfo>

This is designed to use a 100KF animation for -2000..+2000 feet per minute.

First, you add any offset - in this example 2000 feet, since keyframes are necessarily positive. The 0.025 multiplication normalizes the indicated range to 100 keyframes (100 / 4000). Lastly I clamp the resulting value inside the 0-100kf bracket.

For the ASI you have to deal with the non-linearity of the scale. But I would argue that this is actually much easier doing it in 3d, because you can do it without any math. Let's say you have an indicated range of 0 to 200 kts. Your animation code comes down to this:
Code:
  <PartInfo>
    <Name>needle_asi</Name>
    <AnimLength>100</AnimLength>
    <Animation>
      <Parameter>
        <Code>
          (A:INDICATED AIRSPEED,knots) 0.5 * 100 min 0 max
        </Code>
      </Parameter>
    </Animation>
  </PartInfo>

Animation Length is 100, so we need to divide the 100kf by our usable range, 200 kts to get the factor 0.5, and just for good measure the value gets clamped within the 0-100 bracket again. Now adjust your animation, based on the texture of the scale you're using and set new keyframes at exactly half the indicated value. So lock in a point at 25 and animate the needle to show 50 knots. at kf 50, the needle needs to show 100kts, at kf 75, the needle should be at 150 etc. Let the animation play and if at some point your 1:2 scale is out of whack, simply add another KF and adjust the animation.

Does this make sense?
 
Messages
10,088
Country
us-arizona
I miss the Graphics end with basic XML, but this will work. Something new to play with.
 
Messages
10,088
Country
us-arizona
Vitus, I wonder what might be keeping the ASI needle from working? I have tried and tried to get this to function and its just not happening.

I thought maybe it was a part that didnt wish to animate, so I deleted its animations, created a Dummy, animated that, connected the needle to the Dummy, assigned it your animation, and again, nothing. I have reexported things, reset KF's, and nothing happens. In Max its fine. In P3D, its stationary.

I have looked through the config to see if there is a setting somewhere for ASI's, thinking perhaps something in the config is causing this, but I do not see anything that might be doing this.

Any idea's? Can the code be off?
 
Messages
10,088
Country
us-arizona
This is the needle ASI in the stock XML code section;


Code:
  <PartInfo>
    <Name>needle_asi</Name>
    <AnimLength>70</AnimLength>
    <Animation>
      <Parameter>
        <Code>(A:AIRSPEED INDICATED, mph) 10 /</Code>
      </Parameter>
    </Animation>
    <MouseRect>
      <TooltipID>TOOLTIPTEXT_BACKUP_AIRSPEED_KNOTS</TooltipID>
    </MouseRect>
  </PartInfo>

How does one read this equation in the code section? It says 'divided by 10. Would this be a 70 MPH ASI?

This is the EH code block. Also like yours, for 200 knots.

Code:
  <PartInfo>
    <Name>needle_asi_eh101</Name>
    <AnimLength>200</AnimLength>
    <Animation>
      <Parameter>
        <Sim>
          <Variable>AIRSPEED INDICATED</Variable>
          <Units>knots</Units>
        </Sim>
      </Parameter>
    </Animation>
    <MouseRect>
      <TooltipID>TOOLTIPTEXT_AIRSPEED_KNOTS</TooltipID>
    </MouseRect>
  </PartInfo>

odd...
 
Messages
10,088
Country
us-arizona
Guess what... The EH101 code worked. I thought I would try it out and it worked. I guessed it used '200' as the 'knots quantity' as well as the animation length.
 

Vitus

Resource contributor
Messages
1,480
Country
newzealand
This is odd. Have you checked the definition of the variable? You know, this section:
Code:
    <Animation name="needle_asi" guid="129da46d-136a-4807-a5d4-f9e9e36ed8b5" length="100" type="Sim" typeParam2="needle_asi" typeParam="AutoPlay" />
Don't forget to change the length= setting according to the <AnimLength> of the declaration.

Other than that, I don't know what else could cause this. There's nothing special about a needle animation from any other custom animation, so your guess is as good as mine.
 
Messages
10,088
Country
us-arizona
Yep.

Code:
    <Animation name="needle_vsi_2k_vitus" guid="d7c95e22-07a7-467f-b708-77d019d80086" length="100" type="Sim" typeparam2="needle_vsi_2k_vitus" typeparam="AutoPlay" />
    <Animation name="needle_asi_200kts_vitus" guid="499e41c5-78c1-4b6e-9ea2-dc201db0ea36" length="100" type="Sim" typeparam2="needle_asi_200kts_vitus" typeparam="AutoPlay" />

  <PartInfo>
    <Name>needle_vsi_2k_vitus</Name>
    <AnimLength>100</AnimLength>
    <Animation>
      <Parameter>
        <Code>
          (A:VERTICAL SPEED,feet per minute) 2000 + 0.025 * 100 min 0 max
        </Code>
      </Parameter>
    </Animation>
  </PartInfo>

  <PartInfo>
    <Name>needle_asi_200kts_vitus</Name>
    <AnimLength>100</AnimLength>
    <Animation>
      <Parameter>
        <Code>
          (A:INDICATED AIRSPEED,knots) 0.5 * 100 min 0 max
        </Code>
      </Parameter>
    </Animation>
  </PartInfo>





By the way, the VSI worked perfect right off the bat. Nice coding. :)

I had quite a few problems with the ASI. Just glad I got it working.

I went through and calibrated quite a few of the gauges and tuned them up. Quite a few have their own field of KF lengths, 120, 160, 300, 360, etc, etc. I can see where they use the KF's to work with maximum amounts, like coolant temp, oil temp, etc.

Totally new to me....
 
Messages
10,088
Country
us-arizona
So in testing all these '3d' gauge needles, that are now all working proper except one, I find that my voltage meter needle is just not 'lively enough' or my alternator needs to be changed out... (or the part isnt animating??)

I have reset the animation a few times. I have tried the other voltage code that is stock with the plane, and it refuses to go over 8 volts. It should hover at 12 to 13 volts, per the aircraft config sheet. But no. The lowest voltage point is 'under' where the needle is hovering, so I know its measuring 'something'. Also it twitches. So its alive.. but not proper.

Any idea's?

I might try rigging it to a dummy and animating the dummy to see if that fixes it.

Code created for the needle (not mine);
Code:
        <Name>CH70_ga_VOLTS</Name>
        <AnimLength>160</AnimLength>
        <Animation>
            <Parameter>
                <Code>(A:ELECTRICAL BATTERY VOLTAGE, volts) </Code>
            </Parameter>
        </Animation>
    </PartInfo>

Stock XML code that comes with the SDK;
<Name>needle_voltamp</Name>
<AnimLength>100</AnimLength>
<Animation>
<Parameter>
<Code>(L:VAmp, bool) if{ (A:ELECTRICAL MAIN BUS VOLTAGE, Volts) 3.333 * } els{ (A:ELECTRICAL MAIN BUS AMPS, Amperes) } 0 max 100 min</Code>
<Lag>200</Lag>
</Parameter>
</Animation>
</PartInfo>
 

tgibson

Resource contributor
Messages
11,327
Country
us-california
Does your needle have 160 keyframes? If it has 100 KF it will only animate a little more than halfway.
 
Messages
10,088
Country
us-arizona
Does your needle have 160 keyframes? If it has 100 KF it will only animate a little more than halfway.

I had it set for 160KF with the custom, and 100KF with the stock FSX code. Nothing worked.

I kinda cheated. For now, I just rotated the 'out of it' needle to 12 volts, and now its fine, lolol..

I will try a dummy and see if that will animate.

I had a similar problem with another needle. It was jumping through the roof. In Max it was fine, but in the sim, it rocketed out of the cockpit. Reminds me of animating retractable landing gear with lots of parts. :S I selected all of the polygons, cloned them to a new part, animated that, and it was fine. Go figure.
 

tgibson

Resource contributor
Messages
11,327
Country
us-california
It all depends on the maximum voltage value you have set on your gauge bitmap. The needle will point to that spot (i.e. keyframe 160) when when the voltage reaches 160. The output of the Code section is the keyframe number the sim will use for the part's animation. As you see in the default code you posted, the author multiplies the bus voltage by 3.333 to get the correct 100 keyframes. Thus his gauge needle has a maximum deflection at 30 volts (30 x 3.333 = 100 keyframes). Yours will have a maximum deflection at 160 volts (160 x 1.0 = 160 keyframes).
 
Messages
913
Country
indonesia
try add 1 * on simple modeldef.xml code
XML:
<Code>(A:ELECTRICAL BATTERY VOLTAGE, volts) 1 *</Code>

Mostly my gauge animation maximum 100 KF, then use math function on modeldef.xml code or dll gauge to get correct deflection value.
With that could get time saving while updating model animation code. Only need to recompile x and xanim if only change on <Code> </Code>
 

n4gix

Resource contributor
Messages
11,674
Country
unitedstates
try add 1 * on simple modeldef.xml code
XML:
<Code>(A:ELECTRICAL BATTERY VOLTAGE, volts) 1 *</Code>

With that could get time saving while updating model animation code. Only need to recompile x and xanim if only change on <Code> </Code>
<Thud> Now why have I never thought about this "short cut?" :eek:
Brilliant! :wizard:
 
Top