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

MSFS Manage needle animation in VC

Messages
503
Country
france
Hello,

My aircraft has "steam" instrument, such as airspeed indicator, that works with a needle. In my interior XML model, I could animate it according to the aircraft airspeed by using Asobo templates, exactly like it is done in the Cessna. To be honest, I didn't understand everything I did but it (almost) works fine. The problem I have is the non-linearity, the airspeed indicator is not linear, so the speed indication is correct below 160 kts and wrong after.
For this reason, and for other reasons, I would like to have the needle animated using a local variable. I mean that I would like to have a variable that just indicates the rotation angle for the needle, and my code will set the necessary value to have it animated correctly.
Is that possible? (I guess the answer is yes)
Would you have a sample XML code that shows how to do this?

Any help is welcome, I am not an expert in this area...
 

Lagaffe

Resource contributor
Messages
715
Country
france
Hi,

If your steam isn't linear, you have the possibility to use a dedicated template for this.
One example for non-linear steam gauge that I use in my Canso:

<UseTemplate Name="ASOBO_GT_Helper_Non_Linear_Animation_Code">
<ANIM_NAME>fuel_qty_eng1</ANIM_NAME>
<ANIM_LENGTH>100</ANIM_LENGTH>
<SELECTION>(A:FUEL TANK RIGHT MAIN LEVEL, Percent)</SELECTION>
<MIN_VALUE>0</MIN_VALUE>
<MAX_VALUE>100</MAX_VALUE>
<MIN_DISPLAYABLE>0</MIN_DISPLAYABLE>
<MAX_DISPLAYABLE>100</MAX_DISPLAYABLE>
<ANIM_VALUE_0>0</ANIM_VALUE_0>
<REF_VALUE_0>0</REF_VALUE_0>
<ANIM_VALUE_1>25</ANIM_VALUE_1>
<REF_VALUE_1>25</REF_VALUE_1>
<ANIM_VALUE_2>50</ANIM_VALUE_2>
<REF_VALUE_2>50</REF_VALUE_2>
<ANIM_VALUE_3>75</ANIM_VALUE_3>
<REF_VALUE_3>75</REF_VALUE_3>
<ANIM_VALUE_4>100</ANIM_VALUE_4>
<REF_VALUE_4>100</REF_VALUE_4>
<MAX_POINT_INDEX>5</MAX_POINT_INDEX>
</UseTemplate>
Min and Max value are the dynamic of the needle.
REF_VALUE_x is the keyframe number and ANIM_VALUE_x the real value what the needle should indicate.
It is a very simple template which function in most of cases.

Warning: the first couple of data is indexed at 0 so the MAX_POINT_INDEX is equal to the last reference +1
 
Messages
503
Country
france
Hi Didier,
Thanks for the info.
In your example, I understand the value varies from 0 to 100 (it is a percentage), I understand the REF_VALUE, that is clear.
But I don't understand how the non-linearity is managed here. From what I see, several interval are defined: 0 to 25, 25 to 50, 50 to 75 and 75 to 100. And I see the REF_VALUEs correspond to these interval values, so I don't see how MSFS will know how to animate the needle in these intervals, unless your example is not really non-linear.
Did I miss something?
 

Lagaffe

Resource contributor
Messages
715
Country
france
In my case, the animation could have been done in a conventional way, but I had found this template and wanted to try it.
Its primary function is to make several linear interpolations between pre-defined steps (the linearity breaks).

Who can do more can do less and it works even when the animation is strictly linear
 
Messages
927
Country
australia
I just keyframe any non-linear into the needle animation itself and then use this code:

Code:
        <UseTemplate Name="ASOBO_GT_Anim_Code">
            <ANIM_NAME>tm_Airspeed_knots</ANIM_NAME>
            <ANIM_CODE>
                (A:Partial Panel Airspeed,enum) (A:Partial Panel Vacuum,enum) + 0 ==
                if{ (A:Airspeed Indicated,knots) }
                els{ 0 }
            </ANIM_CODE>
            <ANIM_LAG>320</ANIM_LAG>
            <ANIM_LENGTH>170</ANIM_LENGTH>
        </UseTemplate>

So at keyframe 10 I line up the needle with 10 on the dial, at keyframe 20 line it up with 20 on the dial and so on up to the ANIM_LENGTH. Life's too short to do it any other way.

I presume the default airspeed code essentially does the same as my code above. You just program any non-linearity into the keyframes.
 
Messages
503
Country
france
I just keyframe any non-linear into the needle animation itself and then use this code:

Code:
        <UseTemplate Name="ASOBO_GT_Anim_Code">
            <ANIM_NAME>tm_Airspeed_knots</ANIM_NAME>
            <ANIM_CODE>
                (A:Partial Panel Airspeed,enum) (A:Partial Panel Vacuum,enum) + 0 ==
                if{ (A:Airspeed Indicated,knots) }
                els{ 0 }
            </ANIM_CODE>
            <ANIM_LAG>320</ANIM_LAG>
            <ANIM_LENGTH>170</ANIM_LENGTH>
        </UseTemplate>

So at keyframe 10 I line up the needle with 10 on the dial, at keyframe 20 line it up with 20 on the dial and so on up to the ANIM_LENGTH. Life's too short to do it any other way.

I presume the default airspeed code essentially does the same as my code above. You just program any non-linearity into the keyframes.
I see. I will see this with my colleague who works on the 3D model.
Thanks.
 
Messages
927
Country
australia
I just remembered, back in the day (FSX development and earlier) 2D xml gauges had non-linearity tables which would allow you to program in non-linearity (if input it 10, output is 20 for example). I think Lagaffe's example of the ASOBO_GT_Helper_Non_Linear_Animation_Code would be the equivalent of the old non-linearity tables in 2D gauges.

But I never used non-linearity (and seldom made 2D gauges) preferring to just use keyframes in the model because it's easy to understand and easy to do.
 
Messages
503
Country
france
Yes, this is what I understood. The problem is that I am not the author of the 3D model, I just can modify the interior model XML file, so I have no way to change the keyframes.
That's why I have to manage this with the 3D modeling guy :)
 
Messages
503
Country
france
FYI, I worked with the 3D modeler and finally could do what I was looking for. I understood how the needle animation depends on the key frame definition, and it now works perfectly.

Thanks for your help,
Eric
 
Top