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

FSXA Complete noob: C++ vs XML

Messages
217
Country
azerbaijan
OK, we have partnered to make a prop aircraft applying the knowledge from SDK and various tutorials here and there. Especially Bill's and Dai's tutorials are of great help (thank you, gentlemen!!!).

The fuselage and VC are complete and now we need to make animations and gauges (must be made as DLL). But SDK is sometimes misleading in providing the linkage between the chapters. I don't even know how to properly ask questions here. So, please bear with me:

1- modeldef.xml

Is it for animations only? I can see that it can be customized and the values of internal sim variables can be calculated in between the tags. But what I can't see in SDK is the linkage between this file and actual DLL. In other words, i) can one make a gauge without modeldef? If yes, how? Can you guide me to resources where I can read more about this? ii) why does one need modeldef.xml if the resultant gauge will be made in C++?

2. XML seems a bit more intuitive and "easier" for gauge development which is also recommended in SDK. But does it provide facilities for code protection? This is one of the reasons my partner has chosen to make a DLL gauge. So, can I make an XML gauge and then "convert" (probably not a good term) it to a dynamic library?

That's it for now... I will highly appreciate your answers!!!
 
1. Modeldef.XML is for animations only and has nothing to do with gauges unless you want to make 3d gauges which are actually animations. A c++ gauge does not need modeldef.XML AFAIK but can control 3d gauges which need it.

2. XML codes can NOT be compiled into a DLL as it's not actually a programming language. Anyway for code protection and maybe to decrease loading time you can compile it into an .spb file using the simpropcompiler. Have alook at the SDK doc for this.
 
The modeldef is not just animations. It includes visibility tags (show/hide parts of the mesh) and mouse tags (clickspots on controls). Animations and viztags can be controlled by a dll through "L:" vars in the XML script. These vars can be read from and written to by the dll (see http://www.fsdeveloper.com/wiki/index.php?title=C:_XML_Variables_in_C_Gauges).

Mouse click events can either be transmitted via L vars, or hex events (see register_key_event_handler in the C++ gauges SDK) from the mouse tags.

SPB files are easily decompiled so not that secure. The modeldef is compiled into the aircraft's MDL file but still isn't totally secure.

Overall, XML is rather limited so for best results keep the XML part for the modeldef as simple as possible and do the grunt work of the logic in the dll.
 
Thank you for your prompt replies!!!

One more question to clarify if I understood you correctly: Can I still do animations part without modeldef.xml? Say similar to default Beech_Baron.cab - putting all lo/hi res textures and coding (incl. variable read/write and calculations) into the CAB file and writing necessary "gaugeXX" lines into panel.cfg...
 
Thank you for your prompt replies!!!

One more question to clarify if I understood you correctly: Can I still do animations part without modeldef.xml? Say similar to default Beech_Baron.cab - putting all lo/hi res textures and coding (incl. variable read/write and calculations) into the CAB file and writing necessary "gaugeXX" lines into panel.cfg...

What you describe does not need the modeldef.xml file. But be careful when calling this "animation". This can cause confusion. It is the panel/gauges part.
 
1. Modeldef.XML is for animations only and has nothing to do with gauges unless you want to make 3d gauges which are actually animations. A c++ gauge does not need modeldef.XML AFAIK but can control 3d gauges which need it.
Good catch, Dave!

If I read right, the SDK remains silent about binding C++ code to animated 3D model. Most of the switches in our aircraft are made in 3D too. Now as a starter, I want to write a "simple" code for a custom NAV1/NAV2 switch which basically must turn on NAV1 receiver in one state and NAV2 in the other. For instance, in this video animation is attached to an airspeed needle through FSX Gmax pack using modeldef.xml. But how can this be done in C++? Am I missing something in SDK?

I don't ask for the code. If you can guide me to any tutorial on the subject that will be fine!

Thanks!
 
There is no way of using C++ for directly coding animations.
The most "direct" way is to code a simple animation in modeldef.xml which just follows a variable and a DLL can set it.
Vice versa for mouse areas. While the area is clicked a variable is set to true and the DLL uses this info.
I hope this is what you were looking for.

Dave
 
If you are talking about 3D animations, the modeldef is an absolute MUST.
 
After some reading in SDK and Nick Pike's XML tutorials (no C++ for now), this is what I'm trying to do - a basic ADF1 / ADF2 switcher for the APK-9 radio unit. But for some reason it doesn't work at all. Can you show me the mistakes please?:

Code:
<Animation name="apk9ADFswitch" guid="835C70C1-9514-4667-8B4C-5EE8F1271AAC" length="100" type="Sim" typeParam2="apk9ADFswitch" typeParam="AutoPlay" />
<PartInfo>
<Name>adf_switch</Name>
<AnimLength>50</AnimLength>
<Animation>
  <Parameter>
    <Sim>
      <Variable>ADF AVAILABLE</Variable>
      <Units>bool</Units>
      <Scale>50</Scale>
    </Sim>
    <Lag>400</Lag>
  </Parameter>
</Animation>
<MouseRect>
  <Cursor>Hand</Cursor>
  <CallbackCode>(A:CIRCUIT GENERAL PANEL ON, bool) (A:CIRCUIT AVIONICS ON,bool) if{ 5 (&gt;L:RadioLineSelect,number) } &amp;&amp;</CallbackCode>
  <HelpID>HELPID_RADIO_ADF_RADIO</HelpID>
  <TooltipID>TOOLTIPTEXT_RADIO_ADF1_SELECT_SWITCH</TooltipID>
  <EventID>ADF_COMPLETE_SET</EventID>
</MouseRect>
</PartInfo>
 
First, ADF AVAILABLE indicates whether there's a valid signal on the ADF radio... don't think you want to use that for a knob/switch position control.
Second, ADF_COMPLETE_SET sets the frequency for ADF 1, but you didn't tell it WHAT to set it to.

In short, none of your code does what you're wanting to do. You need a strong understanding of what the variables and events do.
 
In addition to what Ed wrote, the names used must be identical!
<Animation name="apk9ADFswitch" guid="835C70C1-9514-4667-8B4C-5EE8F1271AAC" length="100" type="Sim" typeParam2="apk9ADFswitch" typeParam="AutoPlay" />
<PartInfo>
<Name>adf_switch</Name>
Clearly the names do not match... :confused:
 
Back
Top