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

Custom Animation Tag?

For FSX:
Find the modeldef.xml in the Gmax gamepack, then add this above the </ModelInfo> tag:

Code:
<Animation name="[Your animation name]" guid="[GUID]" length="[Length of the animation]" type="Sim" typeParam2="[Your animation name]" typeParam="AutoPlay" />

<PartInfo>
<Name>[Your animation name]</Name>
<AnimLength>[Length of the animation]</AnimLength>
<Animation>
<Parameter>
<Code>[Your animation code]</Code>
<Lag>[Lag parameter]</Lag>
</Parameter>
</Animation>
<MouseRect>
<Cursor>Hand</Cursor>
<TooltipText>[Tooltip Text]</TooltipText>
<MouseFlags>LeftSingle</MouseFlags>
<CallbackCode>
[Code To Be Executed Upon Mouse Click]
</CallbackCode>
</MouseRect>
</PartInfo>

Replace the placeholders with the names and numbers you need for your undertaking and you should be able to find your new animation in the Animation Manager after you restart GMax.

Notes:
[Your animation name] - The name of your animation. Keep it short, use underscores instead of spaces, e.g. "my_first_custom_anim"
[GUID] - animations require a GUID. Generate one here: https://www.guidgenerator.com/
[Length of the animation] - Length of the animation in keyframes. Usually 50 for switches. Can be more for other stuff.
[Your animation code] - The code that drives your animation. Make sure that the processing results of the code are within the keyframe range.
<Lag>...</Lag> - Remove this line if you're not dealing with switches. This will add some visual lag to switches that will otherwise immediately jump from "off" to "on" after clicking.
[Lag parameter] - Forumla used for determining a value for the lag parameter: [animation duration in seconds]=[number of keyframes for animation]/[lag value], e.g. 0.125 sec = 50 keyframes/400
<MouseRect>...</MouseRect> - Remove this section if you're not dealing with a switch or knob or lever. Mouserect code has to be attached
[Tooltip Text] - A custom tooltip text for your switch, knob or lever.
[Code To Be Executed Upon Mouse Click] - What happens when you click the button, knob or lever.


If you need something to become visible or invisible based on some code, add this above </ModelInfo>. You can the pick it from the "Visibility" section in the Attachpoint Tool.
Code:
<PartInfo>
<Name>[Your visibility name]</Name>
<Visibility>
<Parameter>
<Code>
[Your visibility code]
</Code>
</Parameter>
</Visibility>
</PartInfo>

Notes:
[Your visibility name] - Same rules as for the animation name.
[Your visibility code] - The code that determines the visibility of your part. Keep in mind that the result of any evaluation for visibility is either 1 (= visible) or 0 (=invisible).


Variables in FSX that you can use as input for your code:
https://msdn.microsoft.com/en-us/library/cc526981.aspx
Variables to interact with FSX' systems or cockpit elements:
https://msdn.microsoft.com/en-us/library/cc526980.aspx
Expression evaluation basics for FSX:
https://msdn.microsoft.com/en-us/library/cc526953.aspx#Expression_Evaluation


Custom animation code for FS9 is slightly different in terms of tags used and available input variables. You'll have to wait for any FS9 devs to provide examples.
 
FS2004 syntax is simpler. The custom animations are located in the makemdl.parts.xml file.

The format can be gleaned from that file, but here is an example:

Code:
<part>
    <Name>lever_propliner_blower1</Name>
    <Animation>
       <Parameter>
       <Code> (L:supercharger control 1,bool) 100 * </Code>
        <Lag>100</Lag>
       </Parameter>
    </Animation>
<MouseRect>
       <Cursor>Hand</Cursor>
       <Tooltip_Text>Supercharger 1 %((L:supercharger control 1,bool))%{case}%{:1}HIGH%{:0}LOW%{End}</Tooltip_Text>
        <mouse_flags>LeftSingle+LeftDrag</mouse_flags>
        <Callback_Code>
             (L:supercharger control 1,bool) ! (&gt;L:supercharger control 1,bool) }
          </Callback_Code>
    </MouseRect>
</part>
 
Thanks Heretic and tgibson by your replies

[Your animation code] - The code that drives your animation. Make sure that the processing results of the code are within the keyframe range.

So here basicly I just write a code that will always return a number within my keyframe range right?, I have another question here:

How can I write a code that would play my animation in a loop? without using any AIRCRAFT variable?, that would play my animation from keyframe 0 to let's say keyframe 50 which is my keyframe's length. How could I make it play a single time, and then how can I make it play in a loop? o_O

<Lag>...</Lag> - Remove this line if you're not dealing with switches. This will add some visual lag to switches that will otherwise immediately jump from "off" to "on" after clicking.
[Lag parameter] - Forumla used for determining a value for the lag parameter: [animation duration in seconds]=[number of keyframes for animation]/[lag value], e.g. 0.125 sec = 50 keyframes/400
<MouseRect>...</MouseRect> - Remove this section if you're not dealing with a switch or knob or lever. Mouserect code has to be attached
[Tooltip Text] - A custom tooltip text for your switch, knob or lever.
[Code To Be Executed Upon Mouse Click] - What happens when you click the button, knob or lever.

So I can omit these if I'm writting a tag for a external model (not virtual cockpit) am I right?

Notes:
[Your visibility name] - Same rules as for the animation name.
[Your visibility code] - The code that determines the visibility of your part. Keep in mind that the result of any evaluation for visibility is either 1 (= visible) or 0 (=invisible).

If my part is a skinned mesh driven by a bone, then does this visibility attribute could make my mesh invisible/visible?

Thanks, again

Manuel :duck:
 
Hi,

You can't make your animation play a single time without some triggering variable, other than at aircraft load. To make it play once on aircraft load, check this and the gauges forum for several posts on how make something happen once upon aircraft load. Basically you test a custom variable for the value 0 (which they all are at aircraft load) and once detected and your keyframe sequence run, set that variable to 1.

To make it loop, just write the code without any variable test - the code will be run over and over again (up to 18 times a second or thereabouts). Use a Lag statement to slow down the animation if needed. If you are worried about memory, add a test that the code has finished its run before allowing it to start over again. You could check the value of the variable holding the keyframe number and wait for it to reach the final number, for example. I doubt that this is needed though.

You can eliminate all the mouse stuff, but the Lag statement can still be useful in the exterior model.
 
So here basicly I just write a code that will always return a number within my keyframe range right?

For an animation, yes.
If you have a boolean type input variable you need to multiply the result according to your keyframe range.

How can I write a code that would play my animation in a loop? without using any AIRCRAFT variable?, that would play my animation from keyframe 0 to let's say keyframe 50 which is my keyframe's length. How could I make it play a single time, and then how can I make it play in a loop? o_O

Drive an animation with a L: type custom variable and then use a controller type polygon (polygon or triangle with a visibility tag) with code like this:

Code:
(L:Animation variable, number) ++ 51 % (>L:Animation variable, number)

By taking modulo, the variable will reset to zero at 51. Note that the incrementation is done at framerate. Might be worth to execute the looping code in a 2D gauge since it runs at a default frequency of 18.2 Hz.

So I can omit these if I'm writting a tag for a external model (not virtual cockpit) am I right?

Yep. Except for P3Dv3 maybe as it does seem to support clickable exterior models.

If my part is a skinned mesh driven by a bone, then does this visibility attribute could make my mesh invisible/visible?

I think visibility and bones don't mix, but I could be wrong.
 
You can make some really cool animation tags and start sharing/interacting in their programming with gauges, even hidden gauges. The possibilities will seem endless..
 
Drive an animation with a L: type custom variable and then use a controller type polygon (polygon or triangle with a visibility tag) with code like this:

Code:
(L:Animation variable, number) ++ 51 % (>L:Animation variable, number)

Yes that's exactly what I was looking for, then my variable would be running in a DLL that increases it every visual frame and the MDL animation code would just take it to the modulo and restrict the keyframes to a certain range.

I got another question, are the MDL files exported by the Prepar3d plugin backward compatible with FSX?

Thanks, Again

Manuel Ambulo
 
Be aware that variables in C++ gauges are an entirely different animal than ones for XML.

Yes, the P3D v1.4 compiler produces models that work in FSX.
 
Digging up an old topic, sorry. I suppose the process for creating ones own customer animation is similar for blendertools?

Only problem that I am anticipating in my case is that my final process involves using MCX to process my models (some tweaks being made to my animation and .x files after export from blender). I take it that MCX won't read the custom animations -- or will they? Is it a function of simply changing the ModeldefPath to a new modeldef.xml file?
 
If using FSX and later if you point MCX to the modeldef file it will read them, AFAIK.

Options/FS Related Settings/ModeldefPath
 
OK, now I just need to decide on my code.

Trying to animate an external object (AI ship) while flying my airplane/helicopter so I guess I will need to use some kind of gauge for that. not sure.

Really I would be fine with a simple user key press as a trigger. Going to have to research how to do that.
 
Back
Top