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

FSX XML in FSX.....

Messages
118
Country
wales
Hi again - can I ask a basic question concerning, I think, using XML in FSX? I'd like to control the 'visibility' of a rotor (i.e. still/slow/blurred) using KIAS. I know I can attach 'visibility' to parts like prop0, prop1 etc in the normal way, but I'd like to animate the rotor for an autogyro model.

I hope I'm not trying to be too clever - do, please, put me right if I am! Any pointers gratefully received as usual. Thanks for reading... ;)

Cheers - Dai (EGFE). :cool:
 
Create a custom XML script for the three you want, substituting A:Airspeed Indicated,knots for the <code> variable.

Here's an example for "autogyro_still" to give you an idea from which to experiment... ;)
Code:
<Animation name="autogyro_still" guid="2df952e2-9e61-4905-c2ba-46a2c07b8bdf" length="100" type="Sim" typeParam2="autogyro_still" typeParam="AutoPlay" />

  <PartInfo>
    <Name>autogyro_still</Name>
    <AnimLength>100</AnimLength>
    <Visibility>
      <Parameter>
        <Code>
          (A:Airspeed Indicated,knots) 10 &lt; if{ 1 } els{ 0 }
        </Code>
      </Parameter>
    </Visibility>
    <Animation>
      <Parameter>
        <Sim>
              <Variable>RELATIVE WIND VELOCITY BODY Z</Variable>
              <Units>knots</Units>
        </Sim>
      </Parameter>
    </Animation>
  </PartInfo>
 
Thanks for that, Bill - seems promising! Now for the embarassing bit - where do I find the xxx.XML file to put your script in?!? :confused:

O.K. - I did (honest!) spend some time looking through the FSX files for possible xxx.XML candidates, but, I'm sorry to say that I couldn't.... So, if you can give me further clues, I'll get back on the case! :rolleyes:

Thanks again - cheers - Dai (EGFE). :cool:
 
You would insert your XML code in the modeldef.xml file in the SDK

For Windows XP, default installation:

C:\Program Files\Microsoft Games\Microsoft Flight Simulator X SDK\SDK\Environment Kit\Modeling SDK\bin\modeldef.xml



Thanks for that, Bill - seems promising! Now for the embarassing bit - where do I find the xxx.XML file to put your script in?!? :confused:

O.K. - I did (honest!) spend some time looking through the FSX files for possible xxx.XML candidates, but, I'm sorry to say that I couldn't.... So, if you can give me further clues, I'll get back on the case! :rolleyes:

Thanks again - cheers - Dai (EGFE). :cool:
 
Now were getting somewhere! ;)

From your posts, Bill, I think I'll need the following pasted into the modeldef.xml file:

<Animation name="autogyro_still" guid="......." length="100" type="Sim" typeParam2="autogyro_still" typeParam="AutoPlay" />

<Animation name="autogyro_slow" guid="....?....." length="100" type="Sim" typeParam2="autogyro_slow" typeParam="AutoPlay" />

<Animation name="autogyro_blurred" guid="....?....." length="100" type="Sim" typeParam2="autogyro_blurred" typeParam="AutoPlay" />


And, in addition, the following xml code for each (still/slow/blurred):

<PartInfo>
<Name>autogyro_still</Name>
<AnimLength>100</AnimLength>
<Visibility> ..... etc......


Now, I think I understand the mechanism here (but then, I could be completely wrong!! :rolleyes: ). You're introducing three 'new' variables (or whatever XML calls them) in the first three lines and then, further down, setting the logic/math code for animation/visibility?

Before I attempt anything (sharp intake of breath..... :eek: ) I'm worried about the guid's for each variable. Do I use a GUID Generation program - if there is one - or what? I guess the guid you used in your previous example came from somewhere?!? :D

Many thanks again for your help. ;)

Cheers - Dai (EGFE). :cool:
 
There are dozens of "GUID Generators" available. This is one I use whenever I need a bunch of random ones generated quickly. Understand that GUIDs may be formated in a number of ways. This site happens to be the format FSX uses, which makes it rather handy:

http://www.guidgenerator.com/online-guid-generator.aspx

In one quick click it generated these 10 for me:

Code:
87d9d81a-5f53-4b1e-95eb-a103cf986e19
38eb2dae-adb1-4947-ad9d-6a7749aabfe8
afb9c7c4-fd94-43e8-a6c2-345d14c1b431
400e304b-ed72-49c3-a489-c8412edaa181
2f294665-d286-429b-9a91-3fa8d96f10d2
681259ef-0799-4087-bf8d-91243b89cc63
13752505-31ad-4de9-84af-b2ff28fbd6a7
079ce82a-5186-43f5-a339-02408068398d
0c334098-42e2-47a5-98f6-aa6e913e0acd
47206d6b-b6c9-4ccc-914d-4a50fa415bc1

I copy/paste 'em into a notepad.exe window, then cut/paste 'em as needed into whatever I'm working on at the moment.

The one in the example I simply created by randomly changing a few numbers between 0 and f... :cool:

Okay, the first part of the XML script controls when the part will be seen:
Code:
    <Visibility>
      <Parameter>
        <Code>
          (A:Airspeed Indicated,knots) 10 &lt; if{ 1 } els{ 0 }
        </Code>
      </Parameter>
    </Visibility>

In the case above, the part will only be visible if the airspeed is less than 10 kias.

The second part is where you write a "script expression" that will translate sim variable(s) into keyframe animations. It is a bit tricker, but in essense it works like this:

SIM: Converts simvar to keyframes: simvar * scale + bias = keyframes
Code:
    <Animation>
      <Parameter>
        <Sim>
              <Variable>RELATIVE WIND VELOCITY BODY Z</Variable>
              <Units>knots</Units>
        </Sim>
      </Parameter>
    </Animation>

Now I honestly have no idea at all whether the above will actually work, but it's a place to start...

You may have better/faster results adapting the anemometer script from FS9's makemdl.parts.xml file:

Code:
      <Animation>
         <Parameter>
            <!--
			Following uses Anemometer Percent as Anemometer RPM.  This is bogus but effective.
			Rotation at time T seconds in degrees is 6 * RPM * T % 360
			-->
            <Code>
                (A:ANEMOMETER PCT RPM,percent) 6 * (E:ABSOLUTE TIME, second) * 360 % dgrd
            </Code>
         </Parameter>
      </Animation>
 
Last edited:
Excellent - just what the doctor ordered! Thanks, Bill. ;)

Will now proceed with amending the modeldef.xml file........

Cheers - Dai (EGFE). :cool:
 
Excellent - just what the doctor ordered! Thanks, Bill. ;)

Will now proceed with amending the modeldef.xml file........

Cheers - Dai (EGFE). :cool:

I've updated my previous reply with some additional details, so you might like to check again... ;)
 
Another question (or two...) - although I get the gist of what to do, I'd like guidance on the relationship between variable names in the modeldef.xml file and the relevant part(s) in the gmax model. For example, the line:

(A:Airspeed Indicated,knots) 10 &lt; if{ 1 } els{ 0 }

uses a variable (my term) Airspeed Indicated. Now, there's no entry like this in the existing modeldef.xml file, so, how does this work in the sim (FSX). Or, have you just introduced the variable with a convenient 'name'? Sorry to be out of synch! :rolleyes:

Also, I cant find any existing variable in the modeldef.xml that bears any possible relationship to KIAS. As this is such a fundamental variable within the sim, I'm surprised I can't find it - well, knowing me, that's not really true.... :D

Anyway, thanks for reading - hope you can help - again! ;)

Cheers - Dai (EGFE). :cool:
 
umm, (A:Airspeed Indicated,knots) is the KIAS variable. Its being referenced inside of an animation script. The variable itself is being provided by the simulation engine (the A: means its an aircraft simvar, there are a couple of other prefixes, but I'm not sure which ones are valid in the modeldef.xml off the top of my head.

ModelDef.XML isn't a list of variables, its a list of animation scripts, which can be linked by name with parts in your model (that part I have no idea how to do though, so hopefully someone else jumps in on that). The scripts provide the translation between SimVar value and animation keyframe to use.

The entire fragment you posted looks like it enables/disables an animation depending on if KIAS is above or below 10 knots.

Tim
 
<PartInfo>
<Name>switch_ignition_magnetos3</Name>
<Copy>switch_ignition_magnetos</Copy>
<AnimLength>75</AnimLength>
<Animation>
<Parameter>
<Code>(A:OLD ENG STARTER:4, enum) 0 max 4 min 25 *</Code>
</Parameter>
</Animation>
<MouseRect>
<CallbackJumpDragging>
<XMovement>
<EventIdInc>MAGNETO4_INCR</EventIdInc>
<EventIdDec>MAGNETO4_DECR</EventIdDec>
</XMovement>
</CallbackJumpDragging>
</MouseRect>
</PartInfo>

For learning purposes, your PART NAME in the modelling program is "switch_ignition_magnetos3"

the VARIABLE that is the object of the script is "OLD ENG STARTER:4".

In this example, you would name your part in the modelling program "switch_ignition_magentos3"

Now, having said the above, in gmax/max, you use the animation tool to associate the part name with the animation tag, so you could easily name your switch as "Harry" and as long as you associate "Harry" with "switch_ïgnition_magnetos3" it will act according to the animation script...
 
Dai, it might help if you think of the XML scripts in modeldef.xml as if they were gauge "code..."
 
Thanks for the pointers, Bill & Felix, and for the A:Airspeed Indicated,knots explanation, Tim - very helpful. :)

O.K., so I introduced three autogyro elements (my term!) to modeldef.xml:

<Animation name="autogyro_still" guid="0fc9cf9e-57d9-416f-97ab-798e5aa25174"
length="100" type="Sim" typeParam2="autogyro_still" typeParam="AutoPlay" />
<Animation name="autogyro_slow" guid="b9595561-7271-4a01-ab5a-f7088284b3d4"
length="100" type="Sim" typeParam2="autogyro_slow" typeParam="AutoPlay" />
<Animation name="autogyro_blurred" guid="647a4477-9953-4f00-8042-025270156cfa"
length="100" type="Sim" typeParam2="autogyro_blurred" typeParam="AutoPlay" />


And used a modified version of the prop0_still/slow/blurred visibility/animation code - i.e.:

<PartInfo>
<Name>autogyro_slow</Name>
<Copy>prop_anim</Copy>
<AnimLength>100</AnimLength>
<Animation>
<Parameter>
<Sim>
<Variable>PROP ROTATION ANGLE:1</Variable>
</Sim>
</Parameter>
</Animation>
<Visibility>
<Parameter>
<Code>
(A:Airspeed Indicated,knots) 10.0 &gt;
if{
(A:Airspeed Indicated,knots) 25.0 &lt; if{ 1 } els{ 0 }
} els{ 0 }
</Code>
</Parameter>
</Visibility>
</PartInfo>


And, well........

It works - so that's brilliant - thanks again!

Now that I've got the basic autogyro 'dynamics' right, I'll get back to the airframe design and texturing. Oh Yes, here's a snap.....

Rupert's auto-gyro in flight.jpg

More when I get some progress..... ;)

Cheers - Dai (EGFE). :cool:
 
Back
Top