1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

FSX Help 3D gauge Creation in C++

Discussion in 'Gauges' started by Vylsain, 27/4/12.

  1. Vylsain

    Vylsain

    Joined:
    11/1/12
    Messages:
    51
    Country:
    france
    Hello everyone.

    I introduce myself, I am Sylvain Melin, intern at the “Atelier Industriel de l’Aéronautique” at Clermont-Ferrand, France. It is a structure of the “Armée de l’Air” in charge of the aircrafts maintenance. We are exploring the possibility of using FSX as a training tool for our personnel.

    I am in charge of creating a tutorial for FSX’s SDK and some examples. In this context, I want to create one of the HMI of the Mirage 2000, composed of buttons and a numerical display.
    I got a few questions to ask because for the moment I just made a 3D Dodane stopwatch and this HMI is another level !

    If I got it right, I have to create the numerical display as a 2D gauge et integrate it to my 3D object via the panel.cfg file. I see how to do it in XML but I would like to make this one in C++.

    - My first question is about coding. Is it possible to make a 3D gauge in full C++ ? I read on a forum that only a mix of XML/C++ was possible but I would like to be sure.

    - In that event, how is the communication between the two parts done ? I would have liked to do this as a single gauge, following a Model-View-Controller principle but is it therefore impossible ? I guess that only the Model-View part can be done in C++ and that the Controller (3D buttons) must be done in XML and should fetch the created C++ variables of the 2D gauge. How is this fetching from XML to C++ and vice versa done ?

    - Finally, for the 2D gauge making, which method is the best ? I saw that there are several possibilities : GDI+, Ace… Which one is adapted to C++ ?

    That’s all for the moment, thank you in advance for your precious answers.
  2. Naruto-kun

    Naruto-kun

    Joined:
    24/6/10
    Messages:
    603
    Country:
    southafrica
    3D gauges are not "gauges" as such, merely animated parts of the 3D model. Sort of like the stick or throttle or rudder pedals and as such they can only be coded in XML which is then converted into some binary format in export to MDL. You can however, use a C++ gauge to control the variables used in the animation. There is a article in the wiki on controlling XML variables with C++.

    As for the 2D gauges, Ace tool only supports XML. As such you will need to use GDI+ if you wish to do the 2D gauges in C++.
  3. Naruto-kun

    Naruto-kun

    Joined:
    24/6/10
    Messages:
    603
    Country:
    southafrica
    Also GDI+ has a lot more freedom when it comes to drawing graphics than XML and it can also be optimised to a far higher level for better performance than XML.
  4. darrenecm

    darrenecm

    Joined:
    5/5/05
    Messages:
    9
    Country:
    unitedkingdom
    GDI+ certainly does provide greater flexibility and is definitely worth the effort to learn how to use for your gauge evelopment needs, especially if your future requirements involve developing your training software around the more 'glass cockpit-oriented' avionics instruments.

    I've returned to FSX and C++ coding after some time away and I'm currently developing a Direct2D method for gauge drawing which, I hope, will yield superior rendering performance over GDI+. It's still early days learning the API and brushing up on the latest C++ 11 developments though so I have no definitive figures yet :)

    Some have pointed out that gauges using Direct2D would limit products to customers who are running Vista or Wndows 7 because Direct2D is not available on WindowsXP and they are right, but I feel WindowsXP has too many disadvantages against it now as a platform for running FSX / Prepar3D / X-Plane etc. Besides, I'm looking to architect my Direct2D renderer so that it can be swapped in or out with a GDI+ renderer at run-time depending on the operating system that's detected. Speaking of Perpar3D, is Atelier Industriel de l’Aéronautique a French ministry of defense organisation? If so I'd investigate the suitability of Lockheed Martin's Prepar3D platform over that of FSX with your superiors. FSX development has ended and the FSX SDK is no longer beiong developed, whereas Prepar3D benefits from continous development and is probably a more suitable platform going forward.

    Also, if you're still in the early stages of deciding on the right tools for your training program, I strongly reccommend you choose Windows 7 64-bit as your operating system of choice for running FSX / Prepar3D for the following reasons:

    1. Large Address Aware
    FSX has been written and compiled by the development team with the Large Address Aware flag set, meaning the FSX process (and any C++ gauge DLLs / modules you choose to create and attach to the FSX process) can access all of the avialable memory in a 64bit operating system. This is true even even though the FSX process is itself a 32bit application running on a 64bit system. If you're on a 32bit version of Windows, the FSX process will be limited to ~3Gb of memory even though you may have more Ram installed. It's a limitation imposed by the operating system's 32bit architecture. 32bit address space limitations can cause problems as users add more and more complex add-ons such as gauge DLLs or Modules to the FSX process because they will eat away at the total available 3Gb memory space.

    If you're on a 64bit version of Windows this memory limitation is gone and the FSX process (and your gauges and modules remember) can access the full range of whatever additional Ram a user has installed in their system. As for Vista, best steer clear of that as the general consensus amongst almost everyone from users to sotware developers is not a good one :)

    2. WindowsXP End of Lifecycle
    WindowsXP is now out of it's product lifecycle at Microsoft and there will be very few (if any) maintenence releases or service packs to address stability or security issues that may arise now and in the future. Then 64bit version of WindowsXP also has terrible support for 64bit drivers from third-party hardware vendors too :(

    3. General Performance Benefits
    FSX will benefit from decent performance boosts under Windows 7 withh any DirectX 10 or DirectX 11 hardware you have installed. There have been quite good improvements to the DX10 and 11 APIs and even though FSX is a DirectX 9 application, it still benefits from the optimisations and advances made in the DX10 and 11 APIs even though the API is internally dropping back to DirectX 9 backward compatability modes. Of course the FSX Acceleration Pack introduced the DirectX10 Preview mode but I'm not sure that feature is being used too much due to incomplete implementation and glitches. I may be wrong here so if anyone has thoughts on the DX10 preview mode, feel free to enlighten me.

    4. Windows 8 incomming!
    With Windows 8 looming on the horizon, the cost of upgrading from WindowsXP to Windows 7 should hopefully become more wallet / credit card-friendly.
    Last edited: 30/4/12
  5. Naruto-kun

    Naruto-kun

    Joined:
    24/6/10
    Messages:
    603
    Country:
    southafrica
    Darren PLEEASE contact me when you start having some success! I have been attempting to do D2D myself but am finding it a little tricky to figure out.
  6. darrenecm

    darrenecm

    Joined:
    5/5/05
    Messages:
    9
    Country:
    unitedkingdom
    Sent you private message and Gmail.
  7. taguilo

    taguilo Resource contributor

    Joined:
    20/10/06
    Messages:
    1,050
    Country:
    argentina
    Hi,

    For developing gauges the options you have are these:

    VC 3D animated parts (as stated above, not true gauges) must be coded in XML. Not much difficult to write having some medium knowledge of XML's scripting system.

    VC and Standard Cockpit 2D gauges may be coded in XML or C++, and the election will depend on many factors, for example:

    -If you want/need to keep your code off undesired watchers, you must work in C++, essentially. Otherwise,
    -If you are going to work with plenty of glass stuff, C++ with GDI+ would be a good choice, providing you have some good knowledge of this tool. If you don't, still you can make decent code with a mix of XML CustomDraw methods, C++ and standard XML tags and scripts.
    -For classic gauges, if you understand FSX XML logic, it would be a good choice as well, depending on your project's schedules. For a same level of knowledge in both C++ and XML, XML would be faster to code and test, though it could be a nightmare if you don't get well with RPN's scriptying style.

    So, my final advice is don't stick to a fixed platform, just evaluate the project in a whole and then decide which part would be better to code using C++ or XML.



    Actually you will be able to access 4 GB of RAM max, leaving the rest for Windows OS and other applications. For example, if you have FSX plus a bunch of external addons (like ActiveSky, etc) and 8 GB of RAM installed, FSX will use up to 4GB and the addons part of the rest. This is a great improvement in using 64 bit OS compared with a standard 32 bit, where the limit for everything in RAM is 4 Gb, 2 GB per application.

    Tom
  8. Vylsain

    Vylsain

    Joined:
    11/1/12
    Messages:
    51
    Country:
    france
    Thank you all for this advice. :)

    I'll check the wiki about controlling XML variables with C++.
    Your help give me a pretty good view of how I'll proceed.
    I'll do the display as a 2D gauge with GDI+ and C++, and all the knobs (numeric keyboard, switches...) in 3D/XML using the wiki to make an interface.

    @darrenecm : "is Atelier Industriel de l’Aéronautique a French ministry of defense organisation?"

    Yes it is. For the moment what I am doing is experimental but if the results are good enough for my hierarchy, I hope it will be continued and the question of using Prepar3D will be advised.

    And I'm working on a Win 7 64 platform.

    Thank you again for your help ! ;)
  9. Naruto-kun

    Naruto-kun

    Joined:
    24/6/10
    Messages:
    603
    Country:
    southafrica
    If you go with Prepar3D though you may want to dump GDI+ for the glass gauges and use DirectX as they have support in their SDK for DirectX gauges which are far more efficient and frame friendly. And a lot more powerful.
  10. lionheart

    lionheart

    Joined:
    24/10/05
    Messages:
    6,620
    Country:
    us-arizona
    Interesting....
  11. darrenecm

    darrenecm

    Joined:
    5/5/05
    Messages:
    9
    Country:
    unitedkingdom
    My bad, Tom is right.

    As a 32-bit process FSX is indeed limited to a 4Gb maximum running under 64bit Windows, but thankfully still better than what you get running under 32bit Windows. Every little bit of Ram helps.
  12. darrenecm

    darrenecm

    Joined:
    5/5/05
    Messages:
    9
    Country:
    unitedkingdom
    This is correct. It seems the Prepar3D software engineers have hellpfully exposed directx rendering for gauge programmers. Something I wish the FSX devs had bothered to do.

    Too bad this isn't available to those of us stuck in the somewhat restrictive land of FSX SDK :(

    I'm surprised that the Prepar3D engineers haven't gone further and started cleaning some of the old ESP headers files of all those evil function macros and replacing a lot of them with inline functions. Macros have their place but they seemed totally abused in the FSX / ESP SDK.
    Last edited: 2/5/12
  13. Naruto-kun

    Naruto-kun

    Joined:
    24/6/10
    Messages:
    603
    Country:
    southafrica
    It is possible in FSX but it seems that a good knowledge of DirectX is required and some minor reverse engineering skills. Darren and i are looking into it however my DirectX abilities are minimal at this time....
  14. nirgal76

    nirgal76

    Joined:
    15/2/11
    Messages:
    5
    Country:
    france
    the payware gauge FSMap use Direct2d successfully on Win7 (and GDI+ on XP). but on Direct 2D, ressources are store into the Ram of the graphic adapter (and so shared with FS graphical engine), not into the system memory, so you will have less memory available for graphical ressources (that's the main problem of FSmap because this gauge is using huge bitmaps for displaying its moving map, and some bitmaps working with WinXp crash with Win 7). But you're right, Direct2D gauge is the best option for performance.

    Wrong.

    - 32bit OS :
    a 32 bit executable will be limited to ~3Gb with LAA and 2 Gb without LAA.

    - 64bit OS :
    A 32 bit executable (and all dll attached to him) will be limited to 4Gb with LAA and 2 Gb without LAA.

    A 32 bits executable with LAA (like MSFS) will never be able to address more than 4 Gb.
    Last edited: 4/6/12
  15. adino

    adino

    Joined:
    24/10/08
    Messages:
    1
    Country:
    netherlandsantilles
    Hi all,
    I have used this guy tutorials and source examples for developing standalone guages that work over the network for FSX and believe me this has help me wel. (http://www.learjet45chimera.co.uk/)

    l so far I have develop the whole Engine instrument system gauge for the Citation XLS pit I'm building based on his turtorial. The idea is to use Allegro graphic programming platform with C or C++ but you can use other compilers as well, see www.allegro.cc for anything else you need to know. it was a steep curve for me but Im glad so far with all I was able to do so far. Will share the gauge with the code soon I'm finished.hope this help a bit and see other develop freeware stuff. you can visit my site for progress update but I will need to dust it off a bit since I have not update in years so keep pending
    http://c560xl.webs.com/
    rgds,
  16. Vylsain

    Vylsain

    Joined:
    11/1/12
    Messages:
    51
    Country:
    france
    Thank you for the tutorial. :)

Share This Page