plane icon Welcome to Microsoft Flight Simulator’s SDK Q&A Platform!

You have questions regarding the SDK? DevMode Tools? SimConnect? You would like to submit an idea for future improvements, seek help or exchange knowledge? You’re in the right place.


Please take a moment to read the platform’s guidelines before you get started!


question

conradsm avatar image
conradsm asked mamudesign answered

don't understand the logic of template

Hi all, I'm trying to do the animation of my altimeter gauge.

in a free aircraft I have found that instrucion :

<UseTemplate Name="ASOBO_INSTRUMENT_Altimeter_Template">

<MIN_VALUE_STRIP>27.9</MIN_VALUE_STRIP>

<MAX_VALUE_STRIP>31.6</MAX_VALUE_STRIP>

<MIN_VALUE_KNOB>28.2</MIN_VALUE_KNOB>

<MAX_VALUE_KNOB>31.3</MAX_VALUE_KNOB>

<HIGHLIGHT_NODE_ID>INSTRUMENT_Altimeter_Highlight_1</HIGHLIGHT_NODE_ID>

<KNOB_HIGHLIGHT_NODE_ID>INSTRUMENT_Knob_Altimeter_Visual_1</KNOB_HIGHLIGHT_NODE_ID>

</UseTemplate>

now I have to animate in blender in order:

100 ft needle

1000 ft needle

10000 tf needle

rotary knob

barometric rotating scale

but how I have to match these animations with few instructions lines of this template.

I don't understand wich names I have to use in blender for each animation, I don't understand if I have to use other anim xml instruction as following :

<Animation name="needle_vsi" guid="a3e143eb-86e0-455b-a6fc-b8364e1598a1" length="100" type="Sim" typeParam2="needle_vsi" typeParam="AutoPlay" />



<PartInfo>

<Name>needle_vsi</Name>

<AnimLength>100</AnimLength>

<Animation>

<Parameter>

<Code>(A:Vertical speed, m/s) 3 * 50 +</Code>

</Parameter>

</Animation>

</PartInfo>

these part of code I used for vertical speed animation.

I need someone could explain me how to clear my mind . Help. Thanks..

gauges
10 |10000

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

B21 avatar image
B21 answered

Top tip: an altimeter is sufficiently simple that it's worth making an effort to use the generic ASOBO_GT_Anim template to move the needles.

You can either learn that, or you can learn how to dive into the Asobo Official packages source code structure to study the 2000 lines of XML that each of those pre-defined templates expand into. There is no documentation for what the node or animation names that Asobo hard-coded into their templates, or what the parameters in a given template might be called to allow you to tailor the behaviour of the template.

Of course once you get a particular template "working" you will have a great sense of achievement and move on the the next thing, but once you get some of the more generic templates "working" you will find many of the function-specific Asobo templates don't really add much at all except to contain a great deal of plane-specific logic related to the aircraft Asobo has provided.

If it's any help at all, here's the behaviours XML for the altimeter in one of my freeware aircraft (AS33 glider). I'm using "Z:" variables to animate the needles (you won't need to, use A:INDICATED ALTITUDE instead) because in my case the 0..100 animation values are actually provided by html/js code behind the scenes so my gauges have one-click support to toggle from imperial to metric.

For the ANIM_CODE to work using INDICATED ALTITUDE, e.g. for the 100-frame needle that does a complete sweep every 1000 feet, you'd use

<ANIM_CODE>(A:INDICATED ALTITUDE, feet) 1000 % 10 /</ANIM_CODE>

i.e. get alt in feet, find the remainder after dividing by 1000, then divide that by 10 will give you a 0..100 animation value for a needle. So to be truthful you do need to learn the generic template (easy) but also how to put simple formulas into the ANIM_CODE sections (basic is quite easy, but RPN can get more complicated if you want more complex behavior). It's easy to test your animation by just putting a number at the end of your ANIM_CODE, such as 66, and checking that forces the needle to move where you'd expect. A more elite method is to end your ANIM_CODE as below to copy the anim value into an L: var and use the SDK Windows - Behaviours - LocalVariables to give you real-time reading of that value (put XXXX as that window "Filter" value):

<ANIM_CODE>(A:INDICATED ALTITUDE, feet) 1000 % 10 / d (&gt;L:XXXX)</ANIM_CODE>
<!-- ******************************* -->
<!--              ALTIMETER          -->
<!-- ******************************* -->

        <Component ID="gauge_alt_hundreds">
            <UseTemplate Name="ASOBO_GT_Anim">
                <ANIM_NAME>gauge_alt_hundreds</ANIM_NAME>
                <!-- note the needle is animated using html/js because we swap imperial/metric -->
                <ANIM_CODE>(Z:B21_ALTIMETER_NEEDLE_1, number)</ANIM_CODE>
            </UseTemplate>
        </Component>

        <Component ID="gauge_alt_thousands">
            <UseTemplate Name="ASOBO_GT_Anim">
                <ANIM_NAME>gauge_alt_thousands</ANIM_NAME>
                <!-- note the needle is animated using html/js because we swap imperial/metric -->
                <ANIM_CODE>(Z:B21_ALTIMETER_NEEDLE_2, number)</ANIM_CODE>
            </UseTemplate>
        </Component>

<Component ID="gauge_alt_10_thou_visibility" Node="gauge_alt_10_thou">
            <UseTemplate Name="ASOBO_GT_Anim">
                <ANIM_NAME>gauge_alt_10_thou</ANIM_NAME>
                <!-- note the needle is animated using html/js because we swap imperial/metric -->
                <ANIM_CODE>(Z:B21_ALTIMETER_NEEDLE_3, number)</ANIM_CODE>
            </UseTemplate>
<UseTemplate Name="ASOBO_GT_Visibility_Code">
<VISIBILITY_CODE>(Z:B21_ALTIMETER_SHOW_NEEDLE_3, number)</VISIBILITY_CODE>
            </UseTemplate>
</Component>

<Component ID="gauge_alt_knob" Node="gauge_alt_knob">
            <UseTemplate Name="ASOBO_GT_Anim">
<ANIM_NAME>gauge_alt_knob</ANIM_NAME>
<ANIM_CODE>(A:KOHLSMAN SETTING MB, millibars) 20 % 5 *</ANIM_CODE>
            </UseTemplate>
<UseTemplate Name="ASOBO_GT_Interaction_WheelAndContinuousLeft_LeftSingle">
<WRAP>False</WRAP>
<ANTICLOCKWISE_CODE>
                    1 (&gt;K:KOHLSMAN_DEC) 1 (&gt;K:KOHLSMAN_DEC) 1 (&gt;K:KOHLSMAN_DEC)
</ANTICLOCKWISE_CODE>
<CLOCKWISE_CODE>
                    1 (&gt;K:KOHLSMAN_INC) 1 (&gt;K:KOHLSMAN_INC) 1 (&gt;K:KOHLSMAN_INC)
</CLOCKWISE_CODE>
                <LEFT_SINGLE_CODE>1 (&gt;K:BAROMETRIC)</LEFT_SINGLE_CODE>
<TOOLTIPID>BARO %((A:KOHLSMAN SETTING MB:1, Millibars))%!4.0f!</TOOLTIPID>
</UseTemplate>
</Component>

Note the animations need an animation name, not a node, but the INTERACTIONS (i.e. this Kohlsman knob) needs the node name to register the mouse input.

Component ID's can be anything unique in your file, Node and Animation id's just have to match whatever you put in the model. Possibly the main benefit from the old "Animation" method is that MSFS generates the GUID's so you don't need to bother with those at all.

To be clear, Asobo's templates are mostly to mangle your template reference and parameter settings back into the original FSX Animation / PartInfo / MouseArea XML.

10 |10000

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

conradsm avatar image
conradsm answered

Hi B21,

as first , thanks for your reply.

I still don't understand well the templates. just as example I have done the animation of my altimeter , it's works and I have used this template ( as I wrote before ) :

<UseTemplate Name="ASOBO_INSTRUMENT_Altimeter_Template">

<MIN_VALUE_STRIP>27.9</MIN_VALUE_STRIP>

<MAX_VALUE_STRIP>31.6</MAX_VALUE_STRIP>

<MIN_VALUE_KNOB>28.2</MIN_VALUE_KNOB>

<MAX_VALUE_KNOB>31.3</MAX_VALUE_KNOB>

<HIGHLIGHT_NODE_ID>INSTRUMENT_Altimeter_Highlight_1</HIGHLIGHT_NODE_ID>

<KNOB_HIGHLIGHT_NODE_ID>INSTRUMENT_Knob_Altimeter_Visual_1</KNOB_HIGHLIGHT_NODE_ID>

</UseTemplate>

BUT ..... this template works for me only because I have found this information from an old document for FSX where are written the names to use for Blender anim... but for example I have not found any documentations for these names as you told.

the names are...


Instrument_Altimeter_100_1

Instrument_Needle_Altimeter_100_1


Instrument_Altimeter_1000_1

Instrument_Needle_Altimeter_1000_1


Instrument_Altimeter_10000_1

Instrument_Needle_Altimeter_10000_1

that's works for me but I'm still in confusion.

but how do you have learned about how to use the template Asobo GT ANIM ?

nowI try to understand the code you wrote.


10 |10000

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

mamudesign avatar image
mamudesign answered

The documentation Asobo is providing is becoming richer every day

The Template Explorer will guide you through template understanding

https://docs.flightsimulator.com/html/Content_Configuration/Models/ModelBehaviors/TemplateExplorer/Template_Explorer.html


If you search the Asobo_Instrument_Altimeter_Template,

The template reference to another template:

Asobo_Instrument_Altimeter_SubTemplate

That is piggy tailed to this one for the needles:

ASOBO_INSTRUMENT_Needle_Altimeter_SubTemplate


In the template, you get the naming for all the parts within the Anim_name and part_id tags


Is that easy? No. But remember that the goal of Asobo is to provide the tools to create A LOT of assest, making those templates can simplify the Dev work, you only need to understand the template themselves


[Code]

<Template Name="ASOBO_INSTRUMENT_Needle_Altimeter_SubTemplate">

<Parameters Type="Default">

<NODE_ID>INSTRUMENT_Needle_Altimeter_#FEET##SUFFIX_ID#</NODE_ID>

<ANIM_NAME>INSTRUMENT_Needle_Altimeter_#FEET##SUFFIX_ID#</ANIM_NAME>

<PART_ID>INSTRUMENT_Needle_Altimeter</PART_ID>

<BARO_ID>0</BARO_ID>

</Parameters>

<Parameters Type="Default">

<UNITS>feet</UNITS>

</Parameters>

<EditableTemplateParameters>

<AddParams>

<FEET/>

<ANIM_NAME/>

<NODE_ID/>

</AddParams>

</EditableTemplateParameters>

<Component ID="#NODE_ID#" Node="#NODE_ID#">

<UseTemplate Name="ASOBO_GT_Anim_Code">

<ANIM_CODE>

(A:INDICATED ALTITUDE:#BARO_ID#, #UNITS#) 0 &gt;=

if{ (A:INDICATED ALTITUDE:#BARO_ID#, #UNITS#) #FEET# 10 / / 100 % }

els{ (A:INDICATED ALTITUDE:#BARO_ID#, #UNITS#) #FEET# 10 / / 100 % 100 + }

</ANIM_CODE>

<Condition Check="HIGHLIGHT_NODE_ID">

<PART_ID/>

</Condition>

</UseTemplate>

</Component>

</Template>


[/Code]




10 |10000

Up to 5 attachments (including images) can be used with a maximum of 4.8 MiB each and 23.8 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 5 attachments (including images) can be used with a maximum of 19.1 MiB each and 23.8 MiB total.